简体   繁体   中英

Detect solution configurations in Visual Studio 2010

In my C# code I can do the following in the AssemblyInfo.cs file:

#if DEBUG
[assembly: AssemblyInformationalVersion("0.7.7 Debug")]
#else
[assembly: AssemblyInformationalVersion("0.7.7 Release")]
#endif

Then I can batch build and get both debug and release version built with the correct version identifier. Is there anyway to use the #elif and detect different build configurations to do something like:

#if OPTION1 //x86 build profile
[assembly: AssemblyInformationalVersion("0.7.7 X86")]
#elif OPTION2 //x64 build profile
[assembly: AssemblyInformationalVersion("0.7.7 X64")]
#elif OPTION3 //etc
[assembly: AssemblyInformationalVersion("0.7.7 OtherPlatform")]
#endif

This way I can build all my versions at once and be able to identify exe's even if they get re-named or moved around.

It should work, just go into Configuration Manager and add a new configuration (for Solution or for individual projects, depending on your needs). Then in the Properties of each project, select the configuration you want at the top, and you can define Conditional Compilation Symbols like OPTION1 or whatever you want to call them. You can define more than one for a given project by separating them with semicolons. Then select whatever build configuration you want for that Configuration (like x86, etc.) and you should be all set. See also the MSDN page on this .

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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