2011-12-26 3 views
10

VS2010에서 개발 된 C++ 프로젝트 (콘솔 32 비트 응용 프로그램의 일종)가 내 PC (Windows 7 32 비트)에서 올바르게 구현됩니다. . 내 PC에는 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] 

I을 이 문제는 msbuild가 "E:\Program Files\Microsoft SDKs\Windows\v7.1"에 설치된 Microsoft SDK를 찾을 수 없다는 것과 관련 있다고 가정합니다. HKCUHKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1에서 레지스트리의

  1. 복사 부분 (WindowsSdkDir is not set correctly in Visual Studio 2008? 참조)

    는 웹에서이 문제가 사용할 수 처리하는 방법을 몇 가지 조언이 있습니다. 너무 추한 것처럼 보이고 빌드 프로세스가 SYSTEM 계정 자격 증명으로 실행되므로이 ​​해결 방법을 시도하지 않았습니다.

  2. TeamCity and MSBuild Quirks #1에서 제안 된대로 MSBuild의 추가 매개 변수로 WindowsSDKDir을 전달하십시오.
  3. answer에서 Include Search Paths in TeamCity build Configurations으로 제안 된대로 VCProjectEngine.dll.config.xml을 수정했습니다 (Windows SDK가 설치된 PC에서는 이러한 파일을 찾을 수 없습니다).
  4. the answer에서 WindowsSdkDir is not set correctly in Visual Studio 2010으로 제안 된대로 프로젝트 속성에서 플랫폼 도구 집합을 변경합니다. 내 PC에 Windows SDK 7.1이 설치되어 있지 않기 때문에 도움이 될 것으로 생각됩니다. 사실

CL.EXE 모든 것을 컴파일 (I 정의 INCLUDELIB 변수가 있기 때문에), 그래서 사용 msbuild를 강제로 해결 될 것/

있다 ... 환경 변수를 전달할 잘 간다 유사한 문제 :

어쨌든 사람은 윈도우 SDK와 PC가 설치에서 Visual C++ 2010 개 프로젝트를 구축 성공했다?

답변

11

마지막으로이 문제에 대해 일종의 의미 있고 효과적인 해결 방법을 발견했습니다. "Can we build *.vcxproj(c++ project) using MSBuild 4.0 without installing the Visual Studio 2010?" 안에 있습니다.
요약 : VS2010이없는 PC에서 솔루션을 빌드 할 때 Platform Toolset을 명시 적으로 지정해야합니다. 당신은 아마 당신의 프로젝트가 플랫폼 도구 집합으로 지정 v100 또는 v90가있는 경우 같은 길을 갈 필요가

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

: 같은 명령은 볼 것이다.

TeamCity 애호가를위한 힌트로, 독창적 인 Windows SDK가 설치된 PC에서 서버를 실행하는 것입니다.
모든 빌드 단계를 수정하는 대신 에이전트 속성에 Platform Toolset을 지정하면 충분합니다. 는 ?:\TeamCity\buildAgent\conf\buildAgent.properties에 그 추가 다음 행을 수행합니다

system.PlatformToolset=Windows7.1SDK 

해피 건물! :)

+0

안녕하세요, Visual Studio 2010을 실행하는 방법을 더 잘 지정할 수 있습니까? C++ Team City Agent를 사용하여 빌드 서버에 프로젝트로드 Visual Studio 2010 솔루션 빌드 단계를 사용하면 작동하지 않습니다. MSBuild가 누락 된 mspdb100.dll DLL – Stefano

+0

@Stefano에 의존하는 경우 일반적으로 적절한 해결책은'% PATH % '에'mspdb100.dll'디렉토리를 추가하는 것입니다. – AntonK

1

또한이 노드 & 값을 레지스트리에 추가 할 수 있습니다 (설치 디렉토리 & 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 (86)의

% \ MSBuild를 \ 마이크로 소프트 .Cpp \ v4.0 \ Platforms \ Win32 \ PlatformToolsets \ Windows7.1SDK \ Microsoft.Cpp.Win32.Windows7.1SDK.props "VSInstallDir 검색