当我没有指定它而不是 AnyCPU 时,MSBuild 如何或为什么选择 x64 平台? [英] How or why is MSBuild choosing the x64 platform when I don't specify it instead of AnyCPU?

查看:29
本文介绍了当我没有指定它而不是 AnyCPU 时,MSBuild 如何或为什么选择 x64 平台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 Rake 从常规 PowerShell 控制台运行 msbuild.exe.这是从诊断级别运行打印的命令

I'm running msbuild.exe via Rake from a regular PowerShell console. This is the command as printed from a diagnostic level run

"C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.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

"C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe" "D:/Projects/machine.specifications/Source/Machine.Specifications/Machine.Specifications.csproj31881140" /maxcpucount /target:Build /verbosity:diagnostic /property:Configuration=Debug /property:TrackFileAccess=false /property:BuildInParallel=false /property:BuildRunner=Rake

并且构建失败,因为 msbuild 选择 x64 作为 Platform.

And the build is failing because msbuild is picking x64 as the Platform.

C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(483,9): 错误:未为项目Machine.Specifications.csproj37103470"设置 OutputPath 属性.请检查以确保您为此项目指定了配置和平台的有效组合.Configuration='Debug' Platform='X64'.您之所以会看到此消息,可能是因为您尝试在没有解决方案文件的情况下构建项目,并且为该项目指定了不存在的非默认配置或平台.

C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(483,9): error : The OutputPath property is not set for project 'Machine.Specifications.csproj37103470'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='X64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.

我没有在命令行(或从脚本中)传递它.csproj 有一个默认配置

I'm not passing it in on the command line (or from the script). The csproj has a default configuration

<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 行调用中看到过这种行为(但我没有记录它们).

So, I expected the AnyCPU platform to be selected. But, for some reason, something is picking or sending in x64. I don't think the Rake system is a problem here, I've seen this behavior before on raw cmd line calls to msbuild (but I haven't documented them).

我使用的是 64 位 Windows 7,调用 msbuild 4.0.我不知道这是否相关.

I'm on 64-bit Windows 7, calling msbuild 4.0. I don't know if that's relevant.

我正在加载 64 位 Visual Studio 工具(C:Program Files (x86)Microsoft Visual Studio 10.0VCinamd64) 在我的 PowerShell 配置文件中使用 Invoke-BatchFile.这可能是罪魁祸首吗?

I am loading the 64-bit Visual Studio tools (C:Program Files (x86)Microsoft Visual Studio 10.0VCinamd64) using Invoke-BatchFile in my PowerShell profile. Could that be the culprit?

为什么 msbuild 会故意选择 x64?32 位版本不会为您选择 x86.

Why would msbuild deliberately choose x64 anyway? The 32-bit version doesn't choose x86 for you.

*1:PowerShell 控制台位于 %SystemRoot%system32WindowsPowerShellv1.0powershell.exe*2:我正在运行 MSpec 构建(这里是 rakefilemsbuild 调用)

*1: The PowerShell console is at %SystemRoot%system32WindowsPowerShellv1.0powershell.exe *2: I'm running the MSpec build (here's the rakefile and the msbuild call)

推荐答案

当您启动 Visual Studio x64 命令窗口时,它会设置一个环境变量:

When you launch Visual Studio x64 command window, it sets an environment variable :

Platform=X64

这与 32 位命令窗口不同,后者没有定义此环境变量,然后 MSBuild 使用条件逻辑使用默认平台.

This is a difference from the 32 bit command window, where this environment variable is not defined, and MSBuild then uses the conditional logic to use default platform.

您可以删除批处理文件中的平台环境变量,也可以将显式平台属性作为参数传递给 MSBuild.

You can either remove the Platform environment variable in your batch file, or pass in explicit Platform property as a parameter to MSBuild.

这篇关于当我没有指定它而不是 AnyCPU 时,MSBuild 如何或为什么选择 x64 平台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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