How to organize Windows Phone code base to target both 7.x and 8 platforms
Asked Answered
N

1

6

I took over a Windows Phone project which was previously targeting WP 7.1 platform, and with the recent announcement of the new platform it should target WP 8 as well.

My VS 2010 solution consists on several projects (Data access, Model, Tests and WP7 client app) and i am wandering on how to include support for WP8.

I have to note that the code-base is not compatible with WP8, due to usage of Toolkit controls and other 3rd party libraries targeted for WP7.1 specifically.

Also there is another problem with the Visual Studio versions - WP7.1 can work with VS 2010, but WP8 requires VS 2012. Should i move the whole code-base to VS 2012?

Any good advice on how to organize code-base in a most meaningful way in order to avoid duplication and possible painful maintenance?

I am thinking between one solution - multiple projects vs. multiple solutions - reusable projects approach. Code duplication (like two separate folders/solutions) should be the least possible approach (fallback).

Nonconductor answered 10/12, 2012 at 11:1 Comment(0)
P
3

The best thing to do is for you to upgrade all the projects to VS2012 in order to be able to support both WP versions (you'll still be able to open the WP7 project in VS2010 despite it being a VS2012 solution, 'cause it's backward compatible).

Regarding the best way to organize the code base, in my opinion you should create a Portable Library that supports both WP7 and WP8 and get all the common code base there (probably mainly the business logic, specially good if you're using a pattern such as MVVM). Not forgetting about the controls issue, you should probably have some different controls for WP8 'cause the screen sizes are not the same and you could get some more info available and use different controls. If you still want to use the same XAML code, have just one file in one of the projects and add that same file "As Link" in the other project you want to re-use it.

Finally, you can, and also probably should, use some conditional code compilation by making use of the #if directive.

Hope that this information helps, and if any code sample is needed, just say so and I'll try to gather something up.

Philippe answered 10/12, 2012 at 11:12 Comment(2)
Thanks for the prompt answer Marco. I like your approach, and will try it out. Will come back with my findings...Nonconductor
It took me some time to properly set up Windows 8 + Visual Studio 2012 environment, but this is definitely the way i like to follow. I have now one solution with two client projects, each targeting different version of the Windows Phone platform, and few reusable libraries that are shared between them. Thanks again.Nonconductor

© 2022 - 2024 — McMap. All rights reserved.