Skip to content

Instantly share code, notes, and snippets.

@Antaris
Last active May 17, 2017 10:31
Show Gist options
  • Save Antaris/b7d86d3485606e9f1b9fc8698092d56d to your computer and use it in GitHub Desktop.
Save Antaris/b7d86d3485606e9f1b9fc8698092d56d to your computer and use it in GitHub Desktop.
Flexible package management with MSBuild
<Project>
<!-- TARGET FRAMEWORKS -->
<ItemGroup Condition="'$(TargetFramework)'=='netstandard1.6'">
<PackageReference Include="NETStandard.Library" Version="1.6.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'">
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
</ItemGroup>
<!-- /TARGET FRAMEWORKS -->
<!-- APPLICATION MODELS -->
<ItemGroup Condition="'$(HostType)'=='Website'">
<PackageReference Include="Microsoft.NET.Sdk.Web" Version="1.0.0-alpha-20161104-2-112" />
</ItemGroup>
<ItemGroup Condition="'$(HostType)'=='UnitTest'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20161024-02" />
<PackageReference Include="xunit" Version="2.2.0-beta3-build3402" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
</ItemGroup>
<!-- /APPLICATION MODELS -->
<!-- DATABASE PACKAGES -->
<PropertyGroup Condition="'$(DatabaseProvider)'!=''">
<UsesEntityFramework>true</UsesEntityFramework>
</PropertyGroup>
<ItemGroup Condition="'$(UsesEntityFramework)'=='true'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(DatabaseProvider)'=='SqlServer'">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(DatabaseProvider)'=='InMemory'">
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.0" />
</ItemGroup>
<!-- /DATABASE PACKAGES -->
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.props" />
<PropertyGroup Label="Output">
<AssemblyName>MyPackage.Abstractions</AssemblyName>
<AssemblyTitle>MyPackage.Abstractions</AssemblyTitle>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.props" />
<PropertyGroup Label="Common">
<UsesEntityFramework>true</UsesEntityFramework>
</PropertyGroup>
<PropertyGroup Label="Output">
<AssemblyName>MyPackage</AssemblyName>
<AssemblyTitle>MyPackage</AssemblyTitle>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<ItemGroup Label="ProjectReferences">
<ProjectReference Include="..\..\src\MyPackage.Abstractions\MyPackage.Abstractions.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.props" />
<PropertyGroup Label="Common">
<HostType>Website</HostType>
<DatabaseProvider>SqlServer</DatabaseProvider>
</PropertyGroup>
<PropertyGroup Label="Package">
<AssemblyTitle>MyPackage.Host</AssemblyTitle>
<AssemblyName>MyPackage.Host</AssemblyName>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup Label="ProjectReferences">
<ProjectReference Include="..\..\src\MyPackage\MyPackage.csproj" />
<ProjectReference Include="..\..\src\MyPackage.Abstractions\MyPackage.Abstractions.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.props" />
<PropertyGroup Label="Common">
<HostType>UnitTest</HostType>
<DatabaseProvider>InMemory</DatabaseProvider>
</PropertyGroup>
<PropertyGroup Label="Package">
<AssemblyTitle>MyPackage.Tests</AssemblyTitle>
<AssemblyName>MyPackage.Tests</AssemblyName>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup Label="ProjectReferences">
<ProjectReference Include="..\..\src\MyPackage\MyPackage.csproj" />
<ProjectReference Include="..\..\src\MyPackage.Abstractions\MyPackage.Abstractions.csproj" />
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment