Search code examples
c#windows-phone-7windows-8c-preprocessor

Detect whether project is being compiled for windows 8 or wp


I have a windows phone app and I am trying to port it to windows 8. The problem is that several classes should be common among these projects. But some features from windows phone don't work on windows 8 and vice versa. So I should probably use preprocessor derectives for detecting OS. Are there any already defined preprocessor constants that could help me with that? Or could you suggest some better way for doing that?

P.S. These classes use async ctp library. And also some of them have networking capabilities. And as loading files in wp and win8 are implemented in different ways (I need asynchronous file downloading with custom headers and POST requests), I also have to take that into account.


Solution

  • Your best option is to put all common code in a Portable Library. This will allow you to target multiple platforms.

    I think there is not preprocessor directive for windows 8 but you can easily create a new one in a build configuration (properties/condition compilation symbols).