Closed mfkl closed 3 years ago
Based on the error, it looks like you need a newer version of Mono?
Apologies, you are correct. C# 9 is supported in yesterday's nightly mono build, but not in the current stable / VS version.
Building C# 9 single target works, but with your SDK and multitarget it gives
(CoreCompile target) ->
CSC : error CS1900: Warning level must be in the range 0-4
Your SDK is likely not at fault here, just FYI.
CSC : error CS1900: Warning level must be in the range 0-4
This error means you are trying to build a net5.0 with an older (pre C# 9) compiler. You can manually specify <WarningLevel>4</WarningLevel>
in your project file to make it go away but some C# 9 features may not work.
csc -langversion:?
does return a list that includes C# 9. csc --version
returns 3.7.0-5.20367.1 which should include full C# 9 support. I think this is a bug and I can't think of another place to open an issue as the default SDK with single target builds the same csproj fine.
You can manually specify
<WarningLevel>4</WarningLevel>
in your project file to make it go away
Interestingly, specifying this in the csproj seems to get ignored. Building with msbuild
. @jmarolf
@mfkl I can no longer access your repro project. If properties you set in your project file do not get picked up you have a very broken build environment. I do not know if that is due to msbuildsdkextras, mono, the .NET sdk, or some combination of all three.
If you feel the issue lies with the sdk I would open a new issue here
If you feel this is an issue with mono's build environment I would open a new issues here
@jmarolf https://github.com/mfkl/mac-multitarget-net5-cs9. Thanks, will open an issue at mono.
quick question: do you actually need MSBuildSDKExtras? Does this not work for you?
<TargetFrameworks>net5.0;net5.0-ios</TargetFrameworks>
IOS currently requires the Extras. This is something that .NET 6 should be addressing.
gotcha, thanks!
Hi,
Given
and
Invoking
msbuild
givesIt builds fine on Windows, interestingly. I've made sure it builds fine on macOS with a single target and without MSBuildSdkExtras.
repro: https://github.com/mfkl/test-net5-mac-multitarget