Skip to content

Instantly share code, notes, and snippets.

@Serivy
Last active August 23, 2017 15:19
Show Gist options
  • Save Serivy/5cec369c2c0e4332dd835284f3fc5d7b to your computer and use it in GitHub Desktop.
Save Serivy/5cec369c2c0e4332dd835284f3fc5d7b to your computer and use it in GitHub Desktop.
Use new Directory.Build.targets MSBuild 15 system.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import any parent target files. -->
<Import Condition="Exists('$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., $(MSBuildThisFile)))\$(MSBuildThisFile)')" Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., $(MSBuildThisFile)))\$(MSBuildThisFile)"/>
<!-- Include your logic here for the current level. -->
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup>
<_ImportDirTarget>$([MSBuild]::GetDirectoryNameOfFileAbove('$(MSBuildThisFileDirectory)', 'Directory.Build.targets'))\Directory.Build.targets</_ImportDirTarget>
</PropertyGroup>
<Import Condition="'$(MSBuildToolsVersion)' &lt; '15' and Exists('$(_ImportDirTarget)')" Project="$(_ImportDirTarget)"/>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
...
</Project>
@Serivy
Copy link
Author

Serivy commented Aug 23, 2017

proj.csproj modifications are needed if you are unsure if building on msbuild < 15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment