0

I have a Class Library (.NET Core 2.0) being tested by an MSTest Test Project (.NET Core 2.0). The FluentAssertions site says .NET Core 2.0 is supported (and I stepped down from 2.1). It works locally, but on the build machine I get the following error:

The nuget command failed with exit code(1) and error(Errors in D:\a\1\s\ProjectName.Tests.csproj Package System.Configuration.ConfigurationManager 4.4.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package System.Configuration.ConfigurationManager 4.4.0 supports: - net461 (.NETFramework,Version=v4.6.1) - netstandard2.0 (.NETStandard,Version=v2.0) One or more packages are incompatible with .NETCoreApp,Version=v2.0.)

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
KarlZ
  • 170
  • 9
  • I'm pretty sure .NET Core 2.0 implemented .NETStandard 2.0 so should work... – Michal Ciechan Sep 25 '18 at 14:04
  • Also that error is pointing at `System.Configuration.ConfigurationManager` – Michal Ciechan Sep 25 '18 at 14:05
  • Personally would try the following (as it looks like there is some incorrect dependency finding): https://stackoverflow.com/a/39833423/271106 – Michal Ciechan Sep 25 '18 at 14:08
  • Under Dependencies > NuGet > FluentAssertions (5.4.2) there are two items - FluentAssertions.dll and System.Configuration.ConfigurationManager (4.4.0). And in the NuGet UI under Dependencies for FluentAssertions it shows .NETCoreApp, Version=v2.0 it has one - System.Configuration.ConfigurationManager (>=4.4.0) – KarlZ Sep 25 '18 at 14:08
  • 1
    Also have you tried Cleaning out your source on your build server? – Michal Ciechan Sep 25 '18 at 14:08
  • I'm using Azure DevOps... It starts clean every time. – KarlZ Sep 25 '18 at 14:10
  • There is a section on setting up .NET Core on Azure DevOps on MS Docs: https://learn.microsoft.com/en-us/dotnet/core/tools/using-ci-with-cli#ci-setup-examples – Michal Ciechan Sep 25 '18 at 14:12
  • I removed `FluentAssertions` and just used old school `Assert.AreEqual(expected, actual);` and everything worked fine. So I wonder if the dependencies are wrong for `FluentAssertions` on `.NETCoreApp`? – KarlZ Sep 25 '18 at 14:26
  • above comments explain: System.Configuration.ConfigurationManager – SilentTremor Sep 25 '18 at 19:57

1 Answers1

1

The issue was that the Azure DevOps Build pipeline was using NuGet 4.1.0. I added a task to the pipeline right before the NuGet restore called NuGet Tool Installer and set it to install version 4.4.0. Then everything worked fine. Thanks Dennis Doomen!

KarlZ
  • 170
  • 9
  • You're welcome. It's a common issue of a lot of problems with PackageReference projects. – Dennis Doomen Sep 26 '18 at 14:21
  • @KarlZ You could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), This can be beneficial to other community members reading this thread. – Andy Li-MSFT Sep 28 '18 at 02:22