4.5.2 的 msbuild 失败

msbuild fails for 4.5.2

我正在尝试为使用框架版本 4.5.2 的项目获取部署脚本 运行。 不幸的是,当我尝试使用 msbuild 构建项目时出现构建错误。它在我使用新 "shortcuts" 的任何地方抱怨,例如 exception?.ToString()

显然构建时的框架配置错误。据我了解 https://msdn.microsoft.com/en-us/library/ms164311.aspx 的命令行参考,我的调用应该是正确的。

%MSBUILD_HOME%\msbuild "%REPOSITORY_DIR%\Project.csproj" /p:Configuration=Release;TargetFrameworkVersion=v4.5.2;VisualStudioVersion=14.0

我在这里错过了什么?

请确保您使用的是 VS2015 附带的 msbuild.exe。 默认情况下是 c:\Program File(x86)\MSBUILD.0\bin\msbuild.exe

所以你的%MSBUILD_HOME% should be c:\Program File(x86)\MSBUILD.0\bin

One final point to mention about all the C# 6.0 features is that although they obviously require the C# 6.0 compiler, included with Visual Studio 2015 or later, they do not require an updated version of the Microsoft .NET Framework. Therefore, you can use C# 6.0 features even if you’re compiling against the .NET Framework 4, for example. The reason this is possible is that all features are implemented in the compiler, and don’t have any .NET Framework dependencies. https://msdn.microsoft.com/en-us/magazine/Dn879355.aspx