开发者

Different Assembly Name for Each Platform Target

I need to generate different assembly names depending on the platform target. For example, I have a console application "bob.exe". Instead of building for AnyCPU, I need to build explicitly for x86 and x64 and thus want "bob32.exe" and "bob64.exe". The Application tab in Visual Studio 2010 project options disables the Platform combobox. Build Events also don't allow options per platform so I can't rename it afterwards very easily.

Upd开发者_开发问答ate: Manually editing the project file seems to work best, no extra files are part of the build and the pdbs have a matching name.


The IDE cannot handle this, but msbuild.exe does. Edit the .csproj file with, say, Notepad. You'll see four PropertyGroups for the settings of x86/x64 and Debug/Release. The first one has an <AssemblyName> element. Copy and paste it into the other 3 groups. And rename their value.


You can add a Post-Built event to copy the executable using the $(PlatformName) macro.

You'll need to copy (not rename) or the debugger won't work.


I've tried @Hans Passant's solution but it hasn't worked in my case.

Moreover, I needed to highlight both Configuration and Platform pieces of information within the .EXE name in a scenario with four building options:

  • 1) Debug, x86
  • 1) Release, x86
  • 1) Debug, x64
  • 1) Release, x64

In order to get the desired result, I have created four XML elements AT THE END of the 1st <PropertyGroup> tag instance [the one that contains both <ProjectGuid> and <OutputType> tags]:

    <AssemblyName Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">MyExe_Debug_x86</AssemblyName>
    <AssemblyName Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">MyExe_Release_x86</AssemblyName>
    <AssemblyName Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">MyExe_Debug_x64</AssemblyName>
    <AssemblyName Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">MyExe_Release_x64</AssemblyName>

I've tested this solution on two different projects by working with VS2013 and VS2017.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜