Modifying WMAppManifest.xml based on Build Configuration

I would like to release to distinct flavours of my app and would like to indicate this in the application name displayed on the phone. As far as I know for Silverlight Phone Apps the name is solely determined by WMAppManifest.xml. Therefore I would like to modify the application title at build time based on my Build Configuration. Any suggestions?


You can do this with a bit of T4 templating and code generation (see if you don't know about this.)

The following steps will allow you to use a different application title if you are using the debug or release configuration.

Take a copy of WMAppManifest.xml and rename it to

Change the content of to be

<#@ template language="C#" #><#@ output extension=".xml" #><?xml version="1.0"?>
<Deployment xmlns="" AppPlatformVersion="7.0">
  <App xmlns="" ProductID="{4c5315b6-4030-46c5-b5ea-17284d6af0c6}" Title="<#= this.ConfiguredAppTitle #>" RuntimeType="Silverlight" Version="" Genre="apps.normal"  Author="WindowsPhoneApplication8 author" Description="Sample description" Publisher="WindowsPhoneApplication8">
    <IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
      <Capability Name="ID_CAP_IDENTITY_DEVICE"/>
      <Capability Name="ID_CAP_NETWORKING"/>
      <DefaultTask  Name ="_default" NavigationPage="MainPage.xaml"/>
      <PrimaryToken TokenID="WindowsPhoneApplication8Token" TaskName="_default">
          <BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
          <Title><#= this.ConfiguredAppTitle #></Title>
    string ConfiguredAppTitle = "MyPhoneApp";

(Adjust capabilities, etc. as appropriate.)

In the same folder as create a file called with the following contents:

  ConfiguredAppTitle = "MyDebugApp";
#><#@ include file="" #>

Now create a file called with the following contents:

  ConfiguredAppTitle = "MyReleaseApp";
#><#@ include file="" #>

Create a file called copyifnewer.bat in the root of the project. Give it the following contents:

echo Comparing: %1 with %2

if not exist %1 goto File1NotFound
if not exist %2 goto File2NotFound

fc %1 %2 

echo Files are not the same.  Copying %1 over %2
copy %1 %2 /y & goto END

echo Files are the same.  Did nothing
goto END

echo %1 not found.
goto END

copy %1 %2 /y
goto END


In the project properties add this PRE-build command:

"$(ProjectDir)\copyifnewer.bat" "$(ProjectDir)properties\$(ConfigurationName).WMAppManifest.xml" "$(ProjectDir)properties\WMAppManifest.xml"

Now you can adjust the values in the debug & release files to alter the titles as you wish.

If you have other configurations just create appropriately named files (with the same contents as the debug.*.tt) and they'll be picked up automatically.

Note that when testing, if you install the app with one name (in the emulator or phone) you'll have to uninstall it to see a name change reflected in the application list.

Note to self: must blog about this. (It's really powerful but hard to work out how to do the first time.)

Need Your Help

Why doesn't Java include the time/space complexity of each function in the javadoc?

java string complexity-theory javadoc replaceall

Hi I want to know what is the time complexity of the "replaceAll" function of the String class but I can't find any information on it.(

JavaScript & c# - How to check value of hidden element

javascript code-behind

There is (suppose to be) a label or textbox in hidden mode that from the code behind will be set (text value) to "user" or "manager".

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.