Search code examples
batch-filewindows-phone-8visual-studio-2013cmdwindows-phone

Automate compilation process for Windows Phone application and multiple variations


I am developing multiple Windows Phone applications that vary only by the content of several files. Applications share the same logic therefore I created a project and multiple folders, one for each app variation with variant's assets and files and moved them to separate location. To compile project I copy over files and follow a standard compilation process with Visual Studio.

Now there are only 5 application variations and for now it is suiting solution, but the number is expected to grow to 50 and more. I would like to automate the process and my current idea is to write a batch script to copy files from variation folder, overwrite project files, compile app with a script and to copy xap package to another location.

My two questions are:

  1. Is my idea good resolution of the problem or is there a more graceful way to do this I am not aware of? (manage and develop multiple app variations)
  2. How would I compile windows phone app from cmd?

Solution

  • I think your problem is valid. I ran into a similar requirement in the past (only that it was for Windows 8 Store Apps), and what I did was the following:

    Create a "core" project and moved all the shared logic to that project. I then created a sample app project, referenced the core project and made sure the sample app worked the way I wanted it to.

    Finally, I converted the sample app into a Visual Studio template. What this basically does is take the project code and create a Visual Studio template you can reuse. Read more about it here.

    Some work needed to be done within the template source code in order to get some of the dynamic parts like app name into specific locations within the code. For example, you can change a class namespace to be the project's namespace by applying the following code in tour class:

    namespace $safeprojectname$
    

    You can read more about template parameters here.

    Hope it helps.