2011-12-26 136 views
10

我有一个在VS2010中开发的C++项目(某种控制台32位应用程序),在我的PC(Windows 7 32位)上构建得很好, 。我的电脑安装了Microsoft SDK 7.0A,我认为它与VS2010捆绑在一起。
我尝试在没有安装Visual Studio的构建服务器上构建项目 - 只有Microsoft SDK 7.1存在。
我尝试建立与的MSBuild帮助项目(这将最终成为TeamCity的亚军任务),并且在构建服务器我得到下面的错误(详细日志提供):在Windows SDK 7.1但无VS2010的PC上构建C++项目

Project "E:\win\core.sln" on node 1 (default targets). 
ValidateSolutionConfiguration: 
    Building solution configuration "Debug|Win32". 
Project "E:\win\core.sln" (1) is building "E:\win\core_unittests.vcxproj" (2) on node 1 (default targets). 
Project "E:\win\core_unittests.vcxproj" (2) is building "E:\cpptest\win\cpptest.vcxproj" (3) on node 1 (default targets). 
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [E:\cpptest\win\cpptest.vcxproj] 
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [E:\win\cpptest.vcxproj] 
InitializeBuildStatus: 
    Touching "E:\cpptest\win\..\..\..\out\Debug\cpptest\cpptest.unsuccessfulbuild". 
ClCompile: 
    C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"E:\cpptest\win\..\..\..\out\Debug\cpptest\\" /Fd"E:\cpptest\win\..\..\..\out\Debug\cpptest\vc100.pdb" /Gd /TP /analyze- /errorReport:queue ../missing.cpp 
    missing.cpp 
e:\cpptest\missing.cpp(36): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory [E:\cpptest\win\cpptest.vcxproj] 

我假设问题与msbuild无法找到安装在"E:\Program Files\Microsoft SDKs\Windows\v7.1"中的Microsoft SDK有关。

很少有建议如何处理可用这个问题在网络上:HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1下注册的

  1. 复制部分HKCU(见WindowsSdkDir is not set correctly in Visual Studio 2008?)。我没有尝试这种解决方法,因为它看起来太难看了,并且构建过程将使用SYSTEM帐户凭据运行。
  2. 通过WindowsSDKDir作为MSBuild的额外参数(如在TeamCity and MSBuild Quirks #1中提出的)。
  3. 调整VCProjectEngine.dll.config.xmlanswerInclude Search Paths in TeamCity build Configurations(我没有在Windows SDK上的PC上找到这样的文件)中提出的。
  4. the answer中建议的项目属性中的平台工具集更改为WindowsSdkDir is not set correctly in Visual Studio 2010(我怀疑这会有所帮助,因为我的电脑没有安装Windows SDK 7.1)。

实际上CL.EXE一切当编译罚款(因为我已经定义INCLUDELIB变量),所以这将是一个变通方法来强制的MSBuild使用/通过环境变量...

有类似问题:

无论如何有谁成功地在装有Windows SDK的PC上构建Visual C++ 2010项目

回答

11

我终于找到了一种可行的和有意义的解决方法 - 在"Can we build *.vcxproj(c++ project) using MSBuild 4.0 without installing the Visual Studio 2010?"的问题。
简而言之:在没有VS2010的PC上构建解决方案时,我必须明确指定平台工具集。该命令将是这样的:

msbuild /p:PlatformToolset=Windows7.1SDK core.sln 

你可能需要去同样的方式,如果你的项目有指定的平台工具集v100v90

对于TeamCity的爱好者来说,在安装了Windows SDK的个人电脑上运行服务器还需要额外的提示。
而不是修改所有构建步骤,只需在代理的属性中指定平台工具集即可。 要做到这一点添加下面一行到?:\TeamCity\buildAgent\conf\buildAgent.properties

system.PlatformToolset=Windows7.1SDK 

快乐的建筑! :)

+0

嗨,你能更好地指定你如何运行Visual Studio 2010 C++在团队城市代理构建服务器上进行项目?使用Visual Studio 2010解决方案构建步骤不起作用,因为它看起来像s的MSBuild依赖于缺少的mspdb100.dll DLL – Stefano 2012-08-16 17:11:09

+0

@Stefano,通常你的情况下正确的解决方案是将'mspdb100.dll'的目录添加到'%PATH%'。 – AntonK 2012-08-21 17:44:52

1

此外,您可以将此节点&值添加到注册表(更正您的安装目录& win 32/64版本)。

---开始.reg文件---

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Setup\VS] 
"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\" 

---结束.reg文件---

因为MSBuild的脚本 的%ProgramFiles(x86)的%\的MSBuild \微软.Cpp \ v4.0 \ Platforms \ Win32 \ PlatformToolsets \ Windows7.1SDK \ Microsoft.Cpp.Win32.Windows7.1SDK.props“搜索VSInstallDir。