Compatibility errors between netcoreapp3.0 app and netstandard2.1 library when using MSBuild
See original GitHub issueWe have a dotnet codebase that contains a 4-5 dotnet core applications as well as around 20 dotnet standard libraries. These are all separate projects in the same solution. The dotnet core apps reference several of the dotnet standard libraries. We recently migrated everything to netcoreapp3.0 and netstandard2.1. The other devs working on the project (one in windows, one on macos) are not having any issues. I am trying to use MSBuild to build the application because that is what Rider uses when debugging.
I have installed the sdks and dotnet build
works. I cannot run msbuild
, because it produces errors. I also cannot run dotnet msbuild
, it also has the same errors. These are an example of the errors:
"error NU1201: Project MyDotnetStandard21Lib is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Project MyDotnetStandard21Lib supports: netstandard2.1 (.NETStandard,Version=v2.1)"
When I run msbuild
, I believe it is doing
exec /Library/Frameworks/Mono.framework/Versions/6.4.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/MSBuild.dll
I’m not sure what dotnet msbuild
runs.
I also tried to use the MSBuild from the dotnet core sdk like this:
exec /Library/Frameworks/Mono.framework/Versions/6.4.0/bin/mono $MONO_OPTIONS /usr/local/share/dotnet/sdk/3.0.100/MSBuild.dll
but I got a bunch of exceptions like these:
$msbuild
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Unhandled Exception:
System.BadImageFormatException: Could not resolve field token 0x0400036b, due to: Could not load type of field 'Microsoft.Build.Execution.BuildManager:_workQueue' (33) due to: Could not load file or assembly 'System.Threading.Tasks.Dataflow, Version=4.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:/usr/local/share/dotnet/sdk/3.0.100/Microsoft.Build.dll type:BuildManager member:(null)
File name: 'Microsoft.Build'
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject (System.String projectFile, System.String[] targets, System.String toolsVersion, System.Collections.Generic.Dictionary`2[TKey,TValue] globalProperties, System.Collections.Generic.Dictionary`2[TKey,TValue] restoreProperties, Microsoft.Build.Framework.ILogger[] loggers, Microsoft.Build.Framework.LoggerVerbosity verbosity, Microsoft.Build.CommandLine.DistributedLoggerRecord[] distributedLoggerRecords, System.Int32 cpuCount, System.Boolean enableNodeReuse, System.IO.TextWriter preprocessWriter, System.Boolean detailedSummary, System.Collections.Generic.ISet`1[T] warningsAsErrors, System.Collections.Generic.ISet`1[T] warningsAsMessages, System.Boolean enableRestore, Microsoft.Build.Logging.ProfilerLogger profilerLogger, System.Boolean enableProfiler, System.Boolean interactive, System.Boolean isolateProjects, System.Boolean graphBuild, System.String[] inputResultsCaches, System.String outputResultsCache) [0x005a0] in <faa2ef9cf63940199fa55bdf037faaa3>:0
at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String[] commandLine) [0x00415] in <faa2ef9cf63940199fa55bdf037faaa3>:0
at Microsoft.Build.CommandLine.MSBuildApp.Main (System.String[] args) [0x00029] in <faa2ef9cf63940199fa55bdf037faaa3>:0
I’m trying to figure out what I’m doing wrong or how I should be running MSBuild for dotnetcore3.0 projects on MacOS. I suspect I have some wires crossed somewhere. Any help would be greatly appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Well this is a little embarrassing but it appears I just needed to update Rider. I tried to update it on a few days ago and it only updated from 2018.3.4 to 2018.3.5. I just checked for updates again to make sure I updated and now it says there is a 2019.2 update available. After updating, everything is working properly. Thank you for your assistance!
Ok, I ran
dotnet msbuild /restore
and it completed successfully! I was then able to runmsbuild
and it also completed successfully as diddotnet msbuild
.I then tried to do a build in Rider and it failed with the same errors as before. I then tried
dotnet msbuild
again and it also failed and then I needed to rundotnet msbuild /restore
again to get it back.So it seems something with Rider is breaking the build in a way that it can’t complete again without /restore. I did find a setting in Rider to “Restore Nuget packages before Build” and I tried selecting that but it didn’t resolve the issue. I guess I will need to follow up with JetBrains to see if they have any solutions in mind. Thanks for pointing out that /restore flag, that was progress!
FWIW, here are my build settings in Rider in case anyone notices something weird