We have a shared .props
file throughout a large .NET solution (OSS project) that ships primarily C# libraries with some F# APIs built on top of them. I want to globally set the C# version through the LangVersion
property to use C# 10.0 or 11.0, but when I do this it breaks compilation of my F# projects that also depend on the same .props
file.
Using separate .props
files for each isn't a great option as that .props
file is also what's responsible for populating version / package metadata and we want to keep that in one place in order to eliminate duplicative-type errors.
Therefore, what I'm trying to do is use a conditional property inside our .props
file that looks like this:
<!-- Set the language version for C# if we're not inside an F# project -->
<PropertyGroup Condition=" '$(Language)' == 'CSharp' ">
<LangVersion>10.0</LangVersion>
</PropertyGroup>
However, I'm not sure what the right variable / output is to check this. I've gone through the lists mentioned in List of MSBuild built-in variables and have not been able to find it there.