Skip to content

Instantly share code, notes, and snippets.

@semoLi
semoLi / MultiVersionConstant.xml
Created January 27, 2021 09:49 — forked from nordinrahman/MultiVersionConstant.xml
PropertyGroup element to define .NET constants
<PropertyGroup>
<NetFrameworkVersionNum>$(TargetFrameworkVersion.Replace("v", "").Replace(".", ""))</NetFrameworkVersionNum>
<!--Add an extra 0 if the version number is 40 or 45 so it can be compared to 401-->
<NetFrameworkVersionNum Condition="$(NetFrameworkVersionNum.Length) &lt; 3">$(TargetFrameworkVersion.Replace("v", "").Replace(".", ""))0</NetFrameworkVersionNum>
<!--Don't define your own NET constants - this file will do it for you-->
<Error Condition=" $(DefineConstants.Contains('NET'))">Don't define your own NET constants</Error>
<!--Create a version to use with constants NET40, NET401 etc.-->
<NetFrameworkVersion Condition=" !$(DefineConstants.Contains(';NET')) ">$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</NetFrameworkVersion>
<DefineConstants Condition=" !$(DefineConstants.Contains(';NET')) ">$(DefineConstants);$(NetFrameworkVersion)</DefineConstants>
<!--Define the OR_GREATER constants-->