我从常规PowerShell控制台通过Rake运行msbuild.exe
。这是从诊断级别运行打印的命令
“C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ msbuild.exe”“D:/Projects/machine.specifications/Source/Machine.Specifications/Machine.Specifications.csproj31881140”/ maxcpucount / target:构建/详细程度:诊断/属性: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属性。请检查以确保您为此项目指定了Configuration和Platform的有效组合。 配置='调试'平台='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在我的PowerShell配置文件中使用C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64
的64位Visual Studio工具(Invoke-BatchFile
)。这可能是罪魁祸首吗?
为什么msbuild会故意选择x64? 32位版本不会为您选择x86。
* 1:PowerShell控制台位于%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
* 2:我正在运行MSpec版本(此处为rakefile和msbuild call)
答案 0 :(得分:18)
启动Visual Studio x64命令窗口时,它会设置一个环境变量:
Platform=X64
这与32位命令窗口的区别在于,未定义此环境变量,然后MSBuild使用条件逻辑来使用默认平台。
您可以删除批处理文件中的Platform环境变量,也可以将显式的Platform属性作为参数传递给MSBuild。