Hey folks!
I have a question about how I should organize my Visual Studio project and/or solution to allow targeting both Win32 and UWP with as little resistance as possible. Currently my project consists of a game exe project and a few dll projects, all sitting under the same solution, and all targeting plain old Win32 with Visual Studio 2013. I have been thinking about porting the project to UWP for some time now, mainly to be able to run on the Xbox, but there are some things I haven't wrapped my head around, mainly how to organize the projects in Visual Studio.
As far as I know, to build for UWP I would need to update to VS2015 and I would need to make the project an "app container" project. Codewise there shouldn't be that much to do, except change the main loop to work through the CoreApplication system as well as remove some uses of LoadLibrary() etc. However, it seems that if I change the project to an "app container" project I loose the ability to build for Win32. I was hoping I could simply add a new UWP configuration to the solution which would make all projects build "app container" targets, but that does not seem to be possible. Creating a new empty UWP project in VS and opening the vcxproj file up in a text editor reveals things like this in the "Globals" property group:
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.10586.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
Namely, they are not part of a configuration, but instead make the whole project an "app container" project.
What I would like to do is have one project (eg. the exe of the game) where I could flip between Win32 and UWP easily through configurations, using #defines to enable/disable parts of the code that does not apply to the current configuration. Is there a way to do this?
One way I have been thinking about is having the Win32 project be the "main" project and have a UWP project which simply includes links to each and every source file in the Win32 project. This sounds cumbersome and error prone and I would like to avoid it if possible. Another way would be to autogenerate both projects with something like CMake, SharpMake or premake, but I would not want to get into that either right now. Any other options?
Cheers!