Как заставить MSBuild скомпилировать для 32-битного режима?

31
задан Peter Mortensen 23 June 2012 в 17:10
поделиться

4 ответа

If the assemblies themselves are always going to be 32 bit, why not add the setting to the .vbproj file? That will take MSBuild out of the equation.

Just add the following line to the initial PropertyGroup in the .vbproj file

<PlatformTarget>x86</PlatformTarget>
20
ответ дан 27 November 2019 в 21:37
поделиться

According to MSDN, you're doing the right thing. Looks like /p:Platform=x86, but actually, maybe it's /p:PlatformTarget=x86.

Try to just invoke MSBuild directly with that parameter (make sure it's not an issue with your NAnt file. Look at the build output for the right build configuration (Debug / Release).

47
ответ дан 27 November 2019 в 21:37
поделиться

In Solution Explorer, right click the root node → Configuration Manager. You need to define a solution-wide configuration that instructs each project within to build as 32-bit. (Note: you probably already have one if you've ever set at least one project to build as 32-bit.) For a step-by-step walkthrough, see the MSDN blog post Solution Configurations.

Then, you specify the desired "platform" and "flavor" in your Team Build .proj / .targets files. For example:

<ConfigurationToBuild Include="Release|x86">
    <FlavorToBuild>Release</FlavorToBuild>
    <PlatformToBuild>x86</PlatformToBuild>
</ConfigurationToBuild>

You can specify more than one of these property sections to have several combinations built. I would copy/paste the "Release|x86" string (or whatever it looks like) directly from your .sln file to ensure it matches exactly — you can't get it directly from Solution Explorer.

Regarding your comment:

MSBuild property evaluation is pretty complex since it mixes declarative and imperative styles. See the blog post MSBuild Property Evaluation for details. I prefer not to rely on its subtleties.

It's true that properties specified on the command line should override everything else, but Team Build has another layer of complexity. The ComputeConfigurationList task is called repeatedly via a recursive MSBuild invokation, not as an ordinary task. The way it pulls this off is to take the ordinary properties like PlatformToBuild and wrap them in a set of global properties called ConfigurationToBuild.PlatformToBuild (etc.) which are generated on the fly, once for each configuration. This makes the Team Build engine much more flexible internally, but it also makes hacking the command line behavior you want harder.

You could try setting ConfigurationToBuild.PlatformToBuild on the command line directly — it might work, I'm not sure. But it will definitely prevent you from ever building more than one configuration in a single build definition. For this reason, I'm sticking with my advice above.

3
ответ дан 27 November 2019 в 21:37
поделиться

После возникновения точно такой же проблемы, я перешел с использования версии MSBuild по адресу C:\WINDOWS\Microsoft.NET\Framework64... на версию по адресу C:\WINDOWS\Microsoft.NET\Framework (без 64) и все скомпилировалось просто отлично.

2
ответ дан 27 November 2019 в 21:37
поделиться
Другие вопросы по тегам:

Похожие вопросы: