msbuild - 如何指定 MSBuild 的平台?

标签 msbuild

我正在尝试使用 MSBuild 构建具有指定目标平台的解决方案(我需要二进制文件,x86 和 x64)。这是我尝试的方法:

C:\WINDOWS\Microsoft.NET\Framework\v3.5>MsBuild SolutionPath\Solution.sln /t:Rebuild /p:Configuration=Release /p:Platform="x86"

但是,如果平台与“任何 CPU”不同,构建总是会失败。我做错了什么?

这是 MSBuild 打印的 while 输出:

C:\WINDOWS\Microsoft.NET\Framework\v3.5>MsBuild SolutionPath\Solution.sln /t:Rebuild /p:Configuration=Release /p:Platform="x86" Microsoft (R) Build Engine Version 3.5.30729.1 [Microsoft .NET Framework, Version 2.0.50727.3082] Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 1.7.2010 8:28:10. Project "SolutionPath\Solution.sln" on node 0 (Rebuild targe t(s)). SolutionPath\Solution.sln : error MSB4126: The specified sol ution configuration "Release|x86" is invalid. Please specify a valid solution c onfiguration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those prope rties blank to use the default solution configuration. Done Building Project "SolutionPath\Solution.sln" (Rebuild t arget(s)) -- FAILED.

Build FAILED.

"SolutionPath\Solution.sln" (Rebuild target) (1) -> (ValidateSolutionConfiguration target) -> SolutionPath\Solution.sln : error MSB4126: The specified s olution configuration "Release|x86" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.ex e Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those pro perties blank to use the default solution configuration.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.03

如果我尝试使用 devenv 为 x86/x64 构建它,它可以完美运行,但是我尝试设置构建服务器而不安装所有必需版本的 Visual Studio。顺便说一句,如果有更好的免费工具(支持 .NET Framework 4),我很想听听。

最佳答案

在 MSBuild 或 Teamcity 中使用命令行

MSBuild yourproject.sln /property:Configuration=Release /property:Platform=x64

或使用较短的形式:

MSBuild yourproject.sln /p:Configuration=Release /p:Platform=x64

但是您无论如何都需要在项目中设置平台,请参阅 Julien Hoarau 的答案。

关于msbuild - 如何指定 MSBuild 的平台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3155492/

相关文章:

c++ - 如何从 C++ 项目构建/复制资源文件到调试目标路径?

c++ - 更改包含路径

c++ - msbuild:在命令行中设置特定的预处理器#define

msbuild - TopShelf MSDeploy 安装错误退出代码

c# - 我可以在 .net 4.5 项目上使用分析器吗?

msbuild - 如何扩展 msbuild `ItemGroup` 中每个项目的列表属性?

c - 在 Visual Studio 中构建大量小工具有什么好方法?

.net - 如何将 IIS 7 Web 部署与 MSBuild 集成 (TeamCity)

visual-studio-2010 - 自动化 VS 2010 "Publish"配置文件替换

visual-studio - FSharp 项目构建在 TeamCity 中的 MSBuild 中失败