Maintaining a Project with Two Windows Phone Versions


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:

image

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:

Add as Link

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:

image

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”:

Visual Studio Project Settings

With this new project define (again, only in the 7.1 projects), I can edit the code where necessary using this define:

#if MANGO
  [Obsolete("Class is no longer required in Windows Phone 7.1.")]
#endif
  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!


Bootstrap 4 is Here!

After a long development cycle, Bootstrap has been completely re-written to improve performance and be more consistent. Learn Bootstrap 4 now with my Wilder Minds course:

Enroll Today


Shawn
Shawn Wildermuth
Author, Teacher, and Coach




My Courses

Wilder Minds Training
Vue.js by Example (Now Available)
Bootstrap 4 by Example
Intro to Font Awesome 5 (Free Course)
Pluralsight
Less: Getting Started (Coupon Available)
Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.1)
Using Visual Studio Code for ASP.NET Core Projects
Implementing ASP.NET Web API
Web API Design

Application Name WilderBlog Environment Name Production
Application Ver v4.0.30319 Runtime Framework x86
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.26919.02
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86