浏览代码

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

Brad King 9 年之前
父节点
当前提交
042aca557d
共有 2 个文件被更改,包括 20 次插入7 次删除
  1. 10 4
      Source/cmGlobalVisualStudio10Generator.cxx
  2. 10 3
      Source/cmGlobalVisualStudio7Generator.cxx

+ 10 - 4
Source/cmGlobalVisualStudio10Generator.cxx

@@ -350,16 +350,22 @@ std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand()
 std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
 std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
 {
 {
   std::string msbuild;
   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 += this->GetToolsVersion();
   mskey += ";MSBuildToolsPath";
   mskey += ";MSBuildToolsPath";
   if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
   if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
                                        cmSystemTools::KeyWOW64_32)) {
                                        cmSystemTools::KeyWOW64_32)) {
     cmSystemTools::ConvertToUnixSlashes(msbuild);
     cmSystemTools::ConvertToUnixSlashes(msbuild);
-    msbuild += "/";
+    msbuild += "/MSBuild.exe";
+    if (cmSystemTools::FileExists(msbuild, true)) {
+      return msbuild;
+    }
   }
   }
-  msbuild += "MSBuild.exe";
+
+  msbuild = "MSBuild.exe";
   return msbuild;
   return msbuild;
 }
 }
 
 

+ 10 - 3
Source/cmGlobalVisualStudio7Generator.cxx

@@ -150,13 +150,20 @@ std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand()
 std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
 std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
 {
 {
   std::string vscmd;
   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,
   if (cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
                                        cmSystemTools::KeyWOW64_32)) {
                                        cmSystemTools::KeyWOW64_32)) {
     cmSystemTools::ConvertToUnixSlashes(vscmd);
     cmSystemTools::ConvertToUnixSlashes(vscmd);
-    vscmd += "/";
+    vscmd += "/devenv.com";
+    if (cmSystemTools::FileExists(vscmd, true)) {
+      return vscmd;
+    }
   }
   }
-  vscmd += "devenv.com";
+
+  vscmd = "devenv.com";
   return vscmd;
   return vscmd;
 }
 }