我刚刚在我的 win2008 R2 64 位服务器上安装了 VS2012。然后创建了简单的 hello world CLI/C++ 项目。当我尝试编译它时,出现以下错误:
stdafx.cpp : fatal error C1197: cannot reference 'c:\windows\microsoft.net\framework
\v2.0.50727\mscorlib.dll' as the program has already referenced '
c:\program files (x86)\reference assemblies\microsoft\framework\.netframework
\v4.5\mscorlib.dll' [C:\Users\simbuildop\Documents\Visual Studio 2012\Pr
ojects\ConsoleApplication10\ConsoleApplication10\ConsoleApplication10.vcxproj]
对 msbuild 创建的 C++ 编译器的调用是:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /AI"C:\Program
Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramew
ork\v4.5\\" /AI"C:\Program Files (x86)\Windows Kits\8.0\References
\CommonConfiguration \Neutral" /AI"C:\Program Files (x86)\Reference Assemblies\Mic
rosoft\Framework\.NETFramework\v4.5\Facades\\" /Zi /clr /nologo /W3 /WX- /Od /Oy- /D
WIN32 /D _DEBUG /D _UNICODE /D UNICODE /EHa /MDd /GS /fp:preci
se /Zc:wchar_t /Zc:forScope /Yc"stdafx.h" /Fp"Debug\ConsoleApplication10.pch"
/Fo"Debug\\" /Fd"Debug\vc110.pdb" /TP /FUC:\Windows\Microsoft.NET\Fra
mework\v2.0.50727\mscorlib.dll /FU"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /FUC:\Window
s\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /FUC:\Windows\Microsoft.NET
\Framework\v2.0.50727\System.Xml.dll /analyze- /errorReport:queue /
clr:nostdlib stdafx.cpp
stdafx.cpp
msbuild 试图将 .net 2.0 和 .net 4.5 拉到构建中真的很奇怪。
怎么了?
问候迈克尔