Search code examples
c#uwp

Is there a way to have two projects in Visual Studio where one is basically a subset of the other


I have a Visual Studio c# UWP project. I need to create a light version of the project which is basically the same project but has way fewer assets and one different asset (a SQLite database).

Right now it looks like I have to create a new project folder which is a copy of the main project and then remove the assets and change one asset. I think that will work but it will make me have to copy source files from the main project every time I change a line of code in the original.

After searching the web I have been unable to find a simpler way of doing this. Is there a way?

I am about ready to start this and want to see if there is a less brute force way to accomplish this.


Solution

  • You can have a single project and code repository, but create custom build configurations and make use of MSBuild's conditional properties.

    For example, you can create a Full and Lite configuration and control behaviour of your application with constants, and you can have different build locations.

    <PropertyGroup Condition=" '$(Configuration)' == 'Full' ">
        <DefineConstants>FULL;TRACE</DefineConstants>
        <OutputPath>bin\Full\</OutputPath>
    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)' == 'Lite' ">
        <DefineConstants>LITE;TRACE</DefineConstants>
        <OutputPath>bin\Lite\</OutputPath>
    </PropertyGroup>
    

    You can also control dependencies and DLLs conditionally:

    <Reference Include="Some.FullLibrary" Condition=" '$(Configuration)' == 'Full' " />
    

    MSBuild is quite a flexible system.