【发布时间】:2012-02-06 08:09:01
【问题描述】:
我正在通过 Rake 从常规 PowerShell 控制台运行 msbuild.exe。这是从诊断级别运行打印的命令
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "D:/Projects/machine.specifications/Source/Machine.Specifications/Machine.Specifications.csproj31881140" /maxcpucount /target:构建 /verbosity:diagnostic /property:Configuration=Debug /property:TrackFileAccess=false /property:BuildInParallel=false /property:BuildRunner=Rake
构建失败是因为 msbuild 选择 x64 作为 Platform。
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9):错误:未为项目“Machine.Specifications.csproj37103470”设置 OutputPath 属性。请检查以确保您为此项目指定了有效的配置和平台组合。 配置='调试'平台='X64'。您可能会看到此消息,因为您正在尝试构建一个没有解决方案文件的项目,并且指定了该项目不存在的非默认配置或平台。
我没有通过命令行(或脚本)传递它。 csproj 有一个默认配置
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
还有两个具体的配置
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
所以,我希望选择AnyCPU 平台。但是,出于某种原因,有些东西正在x64 中挑选或发送。我认为 Rake 系统在这里不是问题,我之前在对 msbuild 的原始 cmd 行调用中看到过这种行为(但我没有记录它们)。
我在 64 位 Windows 7 上,调用 msbuild 4.0。我不知道这是否相关。
我是 loading 64 位 Visual Studio 工具 (C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64),在我的 PowerShell 配置文件中使用 Invoke-BatchFile。这会是罪魁祸首吗?
为什么msbuild会故意选择x64? 32位版本不会为你选择x86。
*1:PowerShell 控制台位于%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
*2:我正在运行MSpec 构建(这里是rakefile 和msbuild call)
【问题讨论】:
-
MSBuild my.sln /p:Configuration=Release /p:Platform=Any CPU是另一种方式(来自 powershell 提示符)