Reputation: 29
I seem to get this error when building my nunit project with .netcoreapp 3.1 and I can't figure out what mismatch version I have. I noticed a similar post on here but with a difference, where it said i should have a Nunit and UnitTestAdapter version 3.9.0 but VS won't allow me to rollback and I don't see why I would need to anyway. Error when buidling my solution is:
Any help in trying to resolve this error would be appreciated?
Package 'NUnitTestAdapter.WithFramework 2.0.0' was restored using '.NETFramework,Version=v4.6.1,
.NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1,
.NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'.
This package may not be fully compatible with your project.
How can NUnitTestAdapter.WithFramework 2.0.0 not be compatible with project when I have the latest packages?
My test.csproj is:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<None Remove="App1.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Chromium.ChromeDriver" Version="2.37.0" />
<PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="DapperExtensions" Version="1.7.0" />
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="ExtentReports" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="NUnitTestAdapter.WithFramework" Version="2.0.0" />
<PackageReference Include="RestSharp" Version="106.11.7" />
<PackageReference Include="Selenium.Chrome.WebDriver" Version="85.0.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="SpecFlow" Version="3.8.7" />
<PackageReference Include="SpecFlow.Assist.Dynamic" Version="1.4.2" />
<PackageReference Include="SpecFlow.NUnit" Version="3.8.7" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.8.7" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="WebDriverChromeDriver" Version="2.10.0" />
</ItemGroup>
Upvotes: 0
Views: 1718
Reputation: 351
@Neil's pointed article explains it well. Make sure your project targets .Net Core 3.x framework or up. If it's .NET Standard based project then the unit tests won't run. Here what it says:
Upvotes: 0
Reputation: 131581
Don't use that package at all. As its description says, it's only for NUnit2 projects running in Visual Studio 2012. NUnit 2 is at least 5 years old.
The NUnit documentation site explains how to use NUnit in .NET Core in .NET Core and .NET Standard. Add the latest versions of NUnit
, NUnit3TestAdapter
and Microsoft.NET.Test.Sdk
.
In your csproj
file you should add :
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>
After that you can run tests in Visual Studio or the command line with:
dotnet test
Update
Looks like your csproj
already has the correct packages. In this case you only need to remove the obsolete package
Upvotes: 0
Reputation: 11889
NUnitTestAdapter.WithFramework 2.0.0 is a .net framework package (that is only supported by NUnit 2.6), and you are creating a .net core application.
Seeing as the last update for NUnitTestAdapter.WithFramework was related to VS2015, I would suggest you find a different package.
I wonder if you just chose the wrong NUnit test adapter.
Upvotes: 2