I am writing game in XNA 4 and this version have two profiles hi-def and reach. My problem is that I need to have my game code for each of these profiles and is very uncomfortable to have two projects and do all changes in both of them. My idea was to use preprocessor directive (i am not sure about name of this, http://msdn.microsoft.com/en-us/library/ed8yd1ha%28v=vs.71%29.aspx) and use IF statement at places with problems with profile. There is only problem that program needs to be compiled two times (for each profile) and manually changed directive and project settings to another profile. And my questions are: Is that good way? Is there better and cleaner way how to do this?
I got this working, but you need to use some MSBuild magic to do it. I strongly recommend you backup your project, as you might easily break something if you do this wrong.
First things first, you need to open up the configuration manager(
ALT + B + O).
Then you need to create four build configurations for your game project. I chose to name mine
After doing this, you save your project, right-click the project in the solution explorer and then hit
Unload Project. Now, you right-click the project again, and hit
Edit <projectname>.csproj. This is the raw MSBuild configuration of your project.
In the first
PropertyGroup node, you need to find the child node
XnaProfile ann then delete the line. Next you need to find the
PropertyGroup nodes that look like this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugReach|x86' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseReach|x86' ">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugHiDef|x86'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseHiDef|x86'">
ReleaseReach you add the following node:
ReleaseHiDef you add the following node:
After that, you save the file, close it, then right-click the project and click reload. Now depending on the build configuration you use, you'll either use Debug or HiDef. Please note that opening up
Properties does not reflect the difference, but you can test it when you build.