Visual Studio 2019 突然需要 nuget Microsoft.NET.Test.Sdk 来运行 xUnit 单元测试 [英] Visual Studio 2019 suddenly requires nuget Microsoft.NET.Test.Sdk to run xUnit unit-tests

查看:84
本文介绍了Visual Studio 2019 突然需要 nuget Microsoft.NET.Test.Sdk 来运行 xUnit 单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 xUnit 来实现测试.我曾经安装 xUnit Visual Studio runner,xunit.runner.visualstudio nuget 包来使用 VS GUI 运行测试.

以下是 VS 中依赖树的 xUnit 相关分支.你可以清楚地看到 xUnit VS runner 没有依赖:

Visual Studio 突然要求我安装 Microsoft.NET.Test.Sdk nuget 以便在 GUI 中运行测试.有谁知道为什么?

注意:

  • 我已经使用 VS 2019 一年多了,经常尽快更新.问题只发生在昨天.我现在使用的是 v16.7.2.

解决方案

During

此外,如果这些方法不起作用,您应该与我们分享您的项目示例并提供更详细的信息,以便帮助我们更快地解决问题.

更新 1

对于您更新的问题,或者您可以安装 nuget 包 Microsoft.NET.Test.Sdk 直接在您的项目中.

或者将您的项目目标框架更改为net core.

在 csproj 文件中使用:

netcoreapp3.1

然后,重建你的项目,你可以看到它下面的依赖.

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.

解决方案

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.

这篇关于Visual Studio 2019 突然需要 nuget Microsoft.NET.Test.Sdk 来运行 xUnit 单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆