VS2019 - MSBuild SdkResolver 在使用 C# 时无法运行 [英] VS2019 - MSBuild SdkResolver fails to run when using C#

查看:94
本文介绍了VS2019 - MSBuild SdkResolver 在使用 C# 时无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开始使用 c#(我一直在使用 VS for C++ 没有问题),每当我尝试打开 C# 项目时,我都会收到此错误:

无法打开项目文件.SDK 解析器Microsoft.DotNet.MSBuildSdkResolver"无法运行.路径中的非法字符.

.csprj 只有 7 行!

 <属性组><TargetFramework>netstandard2.0</TargetFramework></PropertyGroup></项目>

我尝试将 " 换成 ' 但得到了同样的错误.

使用 /ResetSkipPkgs 运行 VS2019 可防止此问题发生并且项目加载正常.但是我找不到问题的根源.

有没有其他人知道是什么导致了这种情况?我希望能够在不每次都通过命令行运行 VS 的情况下处理 C# 项目!

解决方案

有没有其他人知道是什么导致了这种情况?我希望能够无需每次都通过命令行运行 VS 即可处理 C# 项目!

不确定您之前对 VS 做了什么.可能这个问题是由一些第三方集成工具、vs 扩展或一些 VS 设置引起的.

建议

请尝试以下步骤:

1)确保你的 VS2019 已经安装了这两个工作负载

2) 检查系统环境变量 PATH 并确保它具有值 C:\Program Files\dotnet\没有其他空格键.

另外,检查您是否有环境变量MSBuildSDKsPath,如果有,您应该检查其值是否存在并输入路径进行检查.如果不是,则应修改为使用已存在的地址.

如果 MSBuildSDKsPath 不存在,您应该添加它并将其值设置为

C:\Program Files\dotnet\sdk\3.1.xxx\Sdks

确保该路径存在于您的 PC 下.

非常重要:不要在变量值中使用引号并以"结束.所以请检查每个环境,确保没有乱码.

3) 打开 VS IDE,点击菜单 Extensions-->Manage Extensions 进入已安装的扩展,然后禁用任何第三方扩展以检查问题是否由它们引起.

4)通过工具重置所有VS设置-->导入和导出设置-->重置所有设置 或直接运行 devenv/Resetsettings.

5)

/ResetSkipPkgs 添加到

点击应用确定以启用它.

注意:当您使用它时,您应该通过单击该图标打开 VS,而不是在不支持该功能的 VS 安装程序下启动它).

如果你在开始菜单中启动VS2019,你应该在C:\ProgramData\Microsoft\Windows\Start Menu\Programs中通过我的函数修改Shortcut.

I'm trying to get started with c# (I've been using VS for C++ without issue) and whenever I try to open a C# Project I get this error:

The project file cannot be opened. The SDK resolver "Microsoft.DotNet.MSBuildSdkResolver" failed to run. Illegal characters in path.

The .csprj only has 7 lines!

    <Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

</Project>

I tried swapping the " for ' but got the same error.

Running VS2019 with /ResetSkipPkgs prevents this issue from happening and the project loads fine. However I can't find the source of the issue.

Does anyone else know what could be causing this? I'd like to be able to work on C# projects without running VS via commandline every time!

解决方案

Does anyone else know what could be causing this? I'd like to be able to work on C# projects without running VS via commandline every time!

Not sure what you did to your VS before. Maybe this issue is caused by some third party integration tools, vs extensions, or some VS Settings.

Suggestion

Please try the following steps:

1) make sure that your VS2019 has installed these two workloads

2) check System Environment Variable PATH and make sure that it has value C:\Program Files\dotnet\ and no other space keys.

Also, check if you have environment variable MSBuildSDKsPath, if so, you should check if its value exists and enter the path to check it. If not, you should modify to use the address that already exists.

If MSBuildSDKsPath does not exist, you should add it and set its value to

C:\Program Files\dotnet\sdk\3.1.xxx\Sdks

Make sure the path exists under your PC.

VERY IMPORTANT: Don't use quotes in the variable value and finish it with a "". So please check every environment and make sure that there are no garbled characters.

3) open VS IDE, click menu Extensions-->Manage Extensions and enter into installed extensions and then disable any third party extensions to check whether the issue is caused by them.

4) Reset all VS settings by Tools-->Import and Export Settings-->Reset All Settings or just run devenv /Resetsettings.

5) repair VS or update it to the latest version if there is any updates.

6) delete the .vs hidden folder under the solution folder, bin and obj folder and then test again.

================================================

Besides, you can directly add the switch into /ResetSkipPkgs into VS icon so that every time when you open VS, it will run the /ResetSkipPkgs at the same time.

Right-click on the VS2019 Shortcut icon-->Properties-->Shortcut

Add /ResetSkipPkgs into the

Click Apply and Ok to enable it.

Note: when you use it, you should open VS by clicking that icon rather than start it under VS Installer which does not support that feature).

If you start VS2019 in Start Menu, you should modify the Shortcut by my function in C:\ProgramData\Microsoft\Windows\Start Menu\Programs.

这篇关于VS2019 - MSBuild SdkResolver 在使用 C# 时无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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