How to maintain more than one WMAppManifest.xml files for different versions of your Windows Phone App

When we were to publish a free version of our new Windows Phone Game Photo Challenge I wanted to maintain both the free and paid version in the same Repository. I wanted the solution file and project file for the new free app to use the same source files as the paid app. This gave some headaches because there needs to be a physical WMAppManifest.xml file for each App. I googled various approaches but I finally made up an entirely different approach which I thought fitted our project best. Here is the steps I took:

I actually wanted to manipulate WMAppManifest.xml in the same way as I did AssemblyInfo.cs. But this turned out to be impossible. The WMAppManifest.xml file has to be physical – not a link. Instead I did this:

<XnaWindowsPhoneManifestTemplate>Properties\WMAppManifest.xml</XnaWindowsPhoneManifestTemplate>  

To this:

<XnaWindowsPhoneManifestTemplate>PropertiesPaid\WMAppManifest.xml</XnaWindowsPhoneManifestTemplate> 

Then I reloaded the project in Visual Studio, and did the same for the free project. But now refering to the PropertiesFree folder.

In the free version of WMAppManifest.xml I changed the Title and TokenId to match the AssemblyTitle and AssemblyProduct of AssemblyInfo.cs. Furthermore I changed the ProductId to match the Guid of the AssemblyInfo.cs.

The actual differences between the free and paid version in the source file I maintain using a new compilation symbol I made called “FREE” so I can make statements like this:

#if FREE  
//Some code  
#endif  

Altogether my approach seems to work extremely well to minimize maintainance of the two versions of the same app.

One small problem: For some reason which I have not bothered to find out I cannot use the Compilation symbol Free in the PhotoChallenge.csproj project itself, but I have some other referenced projects where it is no problem. So I just have a class in the referenced project which I can use where ever I have to check if the current version is paid or free:

public static class Edition  
{      
    public static bool IsFree  
    {          
        get  
        {   
#if FREE              
            return true;   
#else              
            return false;  
#endif          
         }      
     }  
}  

Comments

Comments closed.