Skip to content

Instantly share code, notes, and snippets.

@attilah
Created March 18, 2017 18:25
Show Gist options
  • Save attilah/507ea47c3fac3b78d1992c9f29268638 to your computer and use it in GitHub Desktop.
Save attilah/507ea47c3fac3b78d1992c9f29268638 to your computer and use it in GitHub Desktop.
Common props with conditions
<Project>
<PropertyGroup Condition=" '$(ABC)'=='true' ">
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<ABC>true</ABC>
</PropertyGroup>
</Project>
@attilah
Copy link
Author

attilah commented Mar 18, 2017

If SDK would support this, it would be the best thing:

  <PropertyGroup Condition="'$(ImportDirectoryBuildAfterProps)' == 'true' and '$(DirectoryBuildAfterPropsPath)' == ''">
    <_DirectoryBuildAfterPropsFile Condition="'$(_DirectoryBuildAfterPropsFile)' == ''">Directory.Build.After.props</_DirectoryBuildAfterPropsFile>
    <_DirectoryBuildAfterPropsBasePath Condition="'$(_DirectoryBuildAfterPropsBasePath)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '$(_DirectoryBuildAfterPropsFile)'))</_DirectoryBuildAfterPropsBasePath>
    <DirectoryBuildAfterPropsPath Condition="'$(_DirectoryBuildAfterPropsBasePath)' != '' and '$(_DirectoryBuildAfterPropsFile)' != ''">$([System.IO.Path]::Combine('$(_DirectoryBuildAfterPropsBasePath)', '$(_DirectoryBuildAfterPropsFile)'))</DirectoryBuildAfterPropsPath>
  </PropertyGroup>

  <Import Project="$(DirectoryBuildAfterPropsPath)" Condition="'$(ImportDirectoryBuildAfterProps)' == 'true' and exists('$(DirectoryBuildAfterPropsPath)')"/>

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