问题
I'm using xUnit for implementing tests. I used to install the xUnit Visual Studio runner, xunit.runner.visualstudio
nuget package to run tests using the VS GUI.
Below is are xUnit-related branches of the dependency tree in VS. You can clearly see the xUnit VS runner has no dependencies:
Visual Studio is suddenly asking me to install the Microsoft.NET.Test.Sdk
nuget in order to run tests in the GUI. Anyone knows why?
Note:
- I have been using VS 2019 for over a year frequently updating asap. The problem occurred only yesterday. I'm on v16.7.2 now.
回答1:
During xunit.runner.visualstudio version <=2.4.1
, it already contains a dependency Microsoft.NET.Test.Sdk
, and the later version 2.4.2
and 2.4.3
has removed such dependency Microsoft.NET.Test.Sdk
.
also, not sure whether the issue is caused by the update of VS which requires such package recently. And from the default xunit
template project, it contains the package Microsoft.NET.Test.Sdk
by default. So I think VS requires this package.
Maybe in some specific cases, no error will be reported without this package, but there will be no accidental errors in the follow-up, so install this package.
Besides, not sure whether you have install the xunit.runner.visualstudio
version <= 2.4.1
which already has such package, and then update this package later during the VS Update.
Suggestion
1), try to reinstall xunit.runner.visualstudio
nuget package, first uninstall it and then install the version 2.4.1
.
Then, close VS Instance, delete .vs
hidden folder under the solution folder, bin
and obj
folder.
2) try to change the target framework version of your project(it will install any default nuget packages based on the target framework version).
Right-click on your project Properties-->Application--> change target framework to anyone else first and then change it back to the original one.
In addition, if these do not work, you should share a sample of your project with us and provide more detailed info so that it will help us troubleshoot the issue more quickly.
Update 1
For your updated issue, or you could install the nuget package Microsoft.NET.Test.Sdk directly on your project.
Or change your project target framework to net core
.
Use this in csproj file:
<TargetFramework>netcoreapp3.1</TargetFramework>
Then, rebuild your project and you can see the dependency under it.
来源:https://stackoverflow.com/questions/63781190/visual-studio-2019-suddenly-requires-nuget-microsoft-net-test-sdk-to-run-xunit-u