question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility errors between netcoreapp3.0 app and netstandard2.1 library when using MSBuild

See original GitHub issue

We 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:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
robbordencommented, Oct 9, 2019

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!

0reactions
robbordencommented, Oct 8, 2019

Ok, I ran dotnet msbuild /restore and it completed successfully! I was then able to run msbuild and it also completed successfully as did dotnet 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 run dotnet 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 image

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetCore app 3.0 and NetStandard 2.1 compatibility issue
I am referencing a class library project built for netstandard2.1 target by a netcoreapp3.0 project in my Jetbrains Rider IDE and getting a ......
Read more >
Troubleshoot .NET Framework targeting errors
This article provides resolutions for MSBuild errors that might occur ... Project ClassLibrary-NET6 is not compatible with netcoreapp3.1 (.
Read more >
Please stop lying about .NET Standard 2.0 support!
In this post I have a bit of a rant about Microsoft's NuGet packages lying about supporting .NET Standard 2.0 when they kinda...
Read more >
What is the use case for netstandard2.1 : r/dotnet
I just wanted to start with, I totally understand the use case for netstandard2.0. For netstandard2.1, they introduced some new APIs, ...
Read more >
Multi-targetting .Net Framework and .Net Core in a single project
A 15-second guide and 15-minute walk through. You have a .Net Core project, whether a netstandard library, or a netcore app, and you'd...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found