Reputation: 19171
I have read this question but now that we also have 4.5 the solution won't work.
How can I check if the runtime is above 4.0?
Since it's a string I am guessing I cannot do:
<DefineConstants Condition=" '$(TargetFrameworkVersion)' >= 'v4.0' ">NET_4_0</DefineConstants>
So should I define both:
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.0' ">NET_4_0</DefineConstants>
<DefineConstants Condition=" '$(TargetFrameworkVersion)' == 'v4.5' ">NET_4_5</DefineConstants>
Is there a more generic solution?
Upvotes: 1
Views: 189
Reputation: 8798
Carrying on from @MichaelPrice's answer & @HansPassant's comment...
<Choose>
<When Condition=" '$(TargetFrameworkVersion.Substring(1,3))'>'3.5' ">
<ItemGroup>
<DefineConstants>$(DefineConstants);NEWERTHANNET35</DefineConstants>
</ItemGroup>
</When>
</Choose>
Upvotes: 0
Reputation: 8968
You can utilize any methods from the System.String class in the .NET Library, including comparisons.
See http://msdn.microsoft.com/en-us/library/dd633440.aspx
Edit
And if you can't get property functions to work well enough for you, you could try the MSBuild Extension Pack. http://www.msbuildextensionpack.com/help/3.5.3.0/html/9c5401ed-6f55-089e-3918-2476c186ca66.htm
Upvotes: 2