问题
I have a c# windows application project. I want to build two .exe files, one is run as 64bit on 64 bit OS (by platform targeting 'Any CPU'), the other is run as 32 bit on 64 bit OS (by platform targeting x86).
Currently, I should change my build configuration whenever i need the other configuration, and rename the compiled file to distinguish between 32 and 64.
Is there an easier way to manage multiple configurations?
回答1:
Create a 32 bit build and 64 bit build. This will allow you to have them put in different folders.
Right click on the solution, choose "Configuration Manager" In the Active Solution Configuration choose "new" Call it 32-Bit Build Pick the 32 bit option in the CPU dropdown.
Repeat and name it 64-Bit build.
Now when you do a build it will go to C:\Development\ProjectName\Bin\32-Bit Build\programname.exe or similarly for 64 bit
回答2:
You can use a batch file to build the project. The file will use MSBuild and pass the target platform as a parameter. The property attribute will look like:
Properties="Configuration=Debug;Platform=Any CPU"
Properties="Configuration=Debug;Platform=x86"
Take a look at a few samples
MSBuild task configuration property MSBuild: Problems specifying platform for child builds
For MSBuild tutorial, see MSBuild Tutorials
来源:https://stackoverflow.com/questions/3442435/one-project-with-multiple-build-configurations-in-vs2010