简体   繁体   English

MSBuild 忽略所需的配置

[英]MSBuild ignores the desired configuration

I'm trying to build a Visual Studio 2019 solution from command line (though a PowerShell script), I need to have 2 builds - one for 64-bit and one for 32-bit though the script.我正在尝试从命令行(通过 PowerShell 脚本)构建 Visual Studio 2019 解决方案,我需要有 2 个构建版本 - 一个用于 64 位,另一个用于 32 位通过脚本。

From Configuration Manager I have added x86 and x64 platforms to the Platform:在 Configuration Manager 中,我已将 x86 和 x64 平台添加到平台: 在此处输入图片说明

And in the project properties I have set up the Platform target accordingly:在项目属性中,我相应地设置了平台目标: 在此处输入图片说明

I'm using the following command lines to build with MSBuild:我正在使用以下命令行使用 MSBuild 进行构建:

& $msbuildPath ../MyApp.Desktop.sln -t:Rebuild -p:Configuration=Release /p:Platform=x86
& $msbuildPath ../MyApp.Desktop.sln -t:Rebuild -p:Configuration=Release /p:Platform=x64

But it seems to ignore the /p:Platform because it does not matter if I state x86 or x64 it always builds the "Active" platform set in Configuration Manager.但它似乎忽略了/p:Platform因为无论我声明x86还是x64它总是构建在配置管理器中设置的“活动”平台。 But, if I put in platform an invalid value (for instance x123) the build would fail because that does not exist.但是,如果我在平台中输入一个无效值(例如 x123),构建将失败,因为它不存在。

How can I make MSBuild actually build with the stated /p:Platform ?我怎样才能让 MSBuild 用声明的/p:Platform实际构建?

If you build your sln file, you should change the solution platform rather than the project platform .如果您构建您的 sln 文件,您应该更改解决方案平台而不是项目平台

Please try the following steps:请尝试以下步骤:

1) first, delete every project platform and do a clean for your project.And only retain the platform Any CPU . 1)首先,删除每个项目平台,并为你的项目做一个清理。并且只保留平台Any CPU

在此处输入图片说明

2) add the new x64 and x86 platform for the solution platform 2)解决方案平台添加新的x64x86平台

在此处输入图片说明

3) close VS Instance, delete the bin and obj folder of every project 3)关闭VS Instance,删除每个项目的binobj文件夹

then run your powershell with /p:Platform=x64 or x86 .然后使用/p:Platform=x64 or x86运行你的powershell。 And it works well in my side.它在我身边运作良好。 And it can return x86 or x64 output files without any problems.它可以毫无问题地返回x86x64输出文件。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM