Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@attilah 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