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

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

问题描述

我从一个普通的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:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ msbuild.exe "D:/Projects/machine.specifications/Source/Machine.Specifications/Machine.Specifications.csproj31881140" / maxcpucount /目标:构建/详细程度:诊断/属性:配置=调试/属性:TrackFileAccess = FALSE /属性:BuildInParallel = FALSE /属性:BuildRunner =耙

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.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的是采摘 64 平台

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

C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Microsoft.Common.targets(483,9):错误:OutputPath属性不是为项目的Machine.Specifications.csproj37103470设置。请检查以确保您已指定配置和平台的有效组合为这个项目。 配置='调试'平台='X64'。您可能会看到这条消息,因为你正在试图建立没有一个解决方案文件的项目,并且已经指定了非默认配置或平台,不为这个项目的存在。

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.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 平台来进行选择。但是,由于某些原因,一些被采摘或发送的 64 。我不认为佣金制度是一个问题就在这里,我已经生CMD前行看到这种行为调用的MSBuild(但我没有记录过)。

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)的\微软的Visual Studio 10.0 \ VC \ BIN \ AMD64 )使用调用-批处理文件的我的PowerShell配置文件。莫非是罪魁祸首?

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

为什么的MSBuild特意选择64位呢? 32位版本不选86为您服务。

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

* 1:PowerShell控制台是的%SystemRoot%\ SYSTEM32 \ WindowsPowerShell \ V1.0 \ powershell.exe * 2:我运行 MSpec 版本(这里的的 Rake文件和<一href="https://github.com/machine/machine.specifications/blob/master/Tools/Rake/msbuild.rb#L40">msbuild调用)

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

推荐答案

当您启动Visual Studio的64位命令窗口,它设置一个环境变量:

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.

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

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