VS: Verify that MSBuild.exe and devenv.com exist before using them

This commit is contained in:
Brad King 2016-09-06 09:50:00 -04:00
parent a756c74da5
commit 042aca557d
2 changed files with 20 additions and 7 deletions

View File

@ -350,16 +350,22 @@ std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand()
std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
{
std::string msbuild;
std::string mskey =
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\";
std::string mskey;
// Search in standard location.
mskey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\";
mskey += this->GetToolsVersion();
mskey += ";MSBuildToolsPath";
if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
cmSystemTools::KeyWOW64_32)) {
cmSystemTools::ConvertToUnixSlashes(msbuild);
msbuild += "/";
msbuild += "/MSBuild.exe";
if (cmSystemTools::FileExists(msbuild, true)) {
return msbuild;
}
}
msbuild += "MSBuild.exe";
msbuild = "MSBuild.exe";
return msbuild;
}

View File

@ -150,13 +150,20 @@ std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand()
std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
{
std::string vscmd;
std::string vskey = this->GetRegistryBase() + ";InstallDir";
std::string vskey;
// Search in standard location.
vskey = this->GetRegistryBase() + ";InstallDir";
if (cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
cmSystemTools::KeyWOW64_32)) {
cmSystemTools::ConvertToUnixSlashes(vscmd);
vscmd += "/";
vscmd += "/devenv.com";
if (cmSystemTools::FileExists(vscmd, true)) {
return vscmd;
}
}
vscmd += "devenv.com";
vscmd = "devenv.com";
return vscmd;
}