如何指定MSBuild平台? [英] How do I specify the platform for MSBuild?

查看:94
本文介绍了如何指定MSBuild平台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to use MSBuild to build a solution with a specified target platform (I need both binaries, x86 and x64). This is how I tried it:

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

但是,如果平台与"Any CPU"不同,则构建总是会失败.我在做什么错了?

However the build always fails if the platform is different from "Any CPU". What am I doing wrong?

这是MSBuild输出的输出:

This is the while output MSBuild prints:

C:\ WINDOWS \ Microsoft.NET \ Framework \ v3.5> MsBuild SolutionPath \ Solution.sln/t:重建 /p:配置=发布 /p:Platform ="x86" Microsoft(R)构建 引擎版本3.5.30729.1 [Microsoft .NET Framework版本 2.0.50727.3082]版权所有(C)Microsoft Corporation2007.保留所有权利. 保留.

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.

构建于1.7.2010 8:28:10开始. 项目"SolutionPath \ Solution.sln"位于 节点0(重建目标t(s)). SolutionPath \ Solution.sln:错误 MSB4126:指定的解决方案 配置"Release | x86"为 无效的.请指定一个有效的 解决方案配置使用 配置和平台属性 (例如MSBuild.exe Solution.sln /p:配置=调试 /p:Platform ="Any CPU")或保留这些 属性空白为使用默认值 解决方案配置.完成大厦 项目"SolutionPath \ Solution.sln" (重建树状目录)-失败.

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.

构建失败.

"SolutionPath \ Solution.sln"(重建 目标)(1)-> (ValidateSolutionConfiguration目标) -> SolutionPath \ Solution.sln:错误MSB4126:指定的解决方案 配置"Release | x86"为 无效的.请指定一个有效的 解决方案配置使用 配置和平台属性 (例如MSBuild.ex e Solution.sln /p:配置=调试 /p:Platform ="Any CPU")或保留这些 属性为空白以使用默认值 解决方案配置.

"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)

经过的时间00:00:00.03

Time Elapsed 00:00:00.03

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

If I try to build it for x86/x64 with devenv it works perfectly, however I am trying to set up a build server without installing all the necessary versions of Visual Studio. By the way, if there is a better free tool (that supports .NET framework 4) out there, I'd love to hear about it.

推荐答案

如果要为 x86 x64 构建解决方案,则必须同时为这两种解决方案配置解决方案平台.实际上,您只有一个任何CPU 配置.

If you want to build your solution for x86 and x64, your solution must be configured for both platforms. Actually you just have an Any CPU configuration.

要检查给定项目的可用配置,请打开项目文件(例如*.csproj),然后使用正确的Condition查找PropertyGroup.

To check the available configuration for a given project, open the project file (*.csproj for example) and look for a PropertyGroup with the right Condition.

如果要为x86Release模式构建,则项目文件中必须包含以下内容:

If you want to build in Release mode for x86, you must have something like this in your project file:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
  ...
</PropertyGroup>

如何在Visual Studio中创建和编辑配置


(来源:

How to create and edit the configuration in Visual Studio


(source: microsoft.com)


(来源:
msdn.com ) >


(source: msdn.com)


(来源: msdn.com ) >


(source: msdn.com)

如何创建和编辑配置(在MSDN上)

这篇关于如何指定MSBuild平台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆