Search code examples
windows-phone-7.1windows-phone-7targets

Creating an application with multiple targets in Windows Phone 7


Is there any way to create a project/application which will have multiple targets.
Its same as how we create multiple targets for an iPhone application in XCode.
Basically I have an app which has to be made for different targets, with almost all the similar functionalities but with little change.


Solution

  • You can use Configuration Manager to add additional configurations to the list of Debug and Release. Then for each configuration go to Project/Properties/Build/Conditional compilation symbols and add a symbol used with your configuration or target, eg. make it SILVERLIGHT;WINDOWS_PHONE;CUSTOMVERSION1

    Then in your code you can say

    #if CUSTOMVERSION1
        Debug.WriteLine("This is a CUSTOMVERSION1");
    #else
        Debug.WriteLine("This is not CUSTOMVERSION1");
    #endif
    

    Otherwise - if you want to make bigger changes - you would create another project and link files from one project to another project - project/Add/Existing Item//Add As Link(an option in the "Add" button menu). You can then add more files or add different versions of these files as needed. You could use Project Linker to do it faster.