I am currently reading the Mango (Windows Phone OS 7.1) version of my Phoney Tools project. But I have a particular problem: I need to maintain both a 7.0 and a 7.1 version of the project builds. You might have the same issue with your own project so I thought it’d be a good way to show off some special features that Visual Studio has to help you solve these sorts of situations. Essentially my goal was to maintain one set of code but build both sets from the same source.
First off, I took my original project and created two solution folders and created the 7.1 projects as shown here:
To build the 7.1 versions, I linked the source code between the projects. If you haven’t done this before, this means that the 7.1 projects would use the same physical file as the 7.0 versions but be built against the Windows Phone OS 7.1 project settings. To created a linked file, when you add an existing file, you have to pick “Add as Link” in the Existing File dialog:
Using the small dropdown on the “Add” button, you can add the files to your project as a link to the original file. You can see these links in the Solution Explorer so you know which files are linked:
You can see the icon shows a small overlay of an arrow to indicate the linked files. This way I can have a single set of code that can build both versions. Key here is that the underlying references and project types all point at the two versions of the phone libraries. But what about code differences? That’s where project defines come in. In my 7.1 project settings dialog under the build tab, I added a new define called “MANGO”:
With this new project define (again, only in the 7.1 projects), I can edit the code where necessary using this define:
[Obsolete("Class is no longer required in Windows Phone 7.1.")]
public class GameTimer
With these two tricks, I now have both 7.0 and 7.1 building in the same solution. I hope this helps you trying to do the same thing!