Question

I have a Windows phone app and 2 different configuration, what I want is to set in a configuration a different display name for the app, there's any automatized way to do this?

I tried modifing the AssemblyTitle attribute in AssemblyInfo.cs but that doesn't do anything

Was it helpful?

Solution

Resolved by creating a small program fired as a Pre-Build event which read the Manifest and change it accordingly to the Config name passed to him

For reference of anyone should have this problem here is the code. This implementation takes two parameter par1: name of the config par2: path to the WMAppManifest of the application

    static void Main(string[] args)
    {
        XmlDocument document = GetDocument(args[1]);
        SubstituteName(document, args[0]);
        SaveDocument(document, args[1]);
    }

    private static void SaveDocument(XmlDocument document, string path)
    {
        document.Save(path);
    }

    private static void SubstituteName(XmlDocument document, string ConfigName)
    {
        string name="appname "+ConfigName;
        if (ConfigName.Equals("Config1"))
            name = "appname 1";
        if (ConfigName.Equals("Config2"))
            name = "appname 2";

        XmlNode node = document.SelectSingleNode("//App");
        node.Attributes["Title"].Value = name;
    }

    private static XmlDocument GetDocument(string path)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(path);
        return doc;
    }

to consume in the app project: In the pre-build event

"$(SolutionDir)AppNameChanger.exe" $(ConfigurationName) "$(SolutionDir)WP8Project\Properties\WMAppManifest.xml"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top