c# - 在 Visual Studio 2019 中升级 xproj
问题描述
我需要在 Visual Studio 2019 中升级 xproj 类型的项目。当我尝试打开解决方案时,它说它需要升级,但随后我收到以下消息:
不再支持 Xproj 项目文件。有关迁移到 csproj 的详细信息,请参阅https://docs.microsoft.com/en-us/dotnet/core/migration/。
链接的文档提到在 Visual Studio 中执行此操作(不起作用)或使用 dotnet migrate。当我尝试这样做时,我得到以下信息:
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-migrate does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
进一步看,dotnet migrate 似乎在 dotnetcore 3.0 中已被弃用
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-migrate
此命令已弃用。从 .NET Core 3.0 SDK 开始,dotnet migrate 命令不再可用。它只能将 Preview 2 .NET Core 项目迁移到不支持的 1.x .NET Core 项目。
我已经在 Visual Studio 2017 和 2015 命令行上尝试过,得到了完全相同的错误。似乎安装了 dotnetcore3 会删除执行此操作的能力。
是否有任何方法可以在不访问推荐的 Microsoft 工具的情况下迁移项目?
解决方案
您可以通过以下命令列出已安装的 dotnet core sdk 版本:
dotnet --list-sdks
然后,您可以通过以下命令切换回旧版本的 dotnet core sdk(例如2.0.2
):
dotnet new globaljson --sdk-version 2.0.2
这应该在您的 xproj 所在的文件夹中执行。
最后,您可以通过以下方式迁移您的项目:
dotnet migrate
推荐阅读
- python - /no such table 处的 OperationalError:公共服务器上的 django_session 错误,站点在本地服务器上工作正常
- c - 当 x 和 y 是字符时,为什么 pow(x,y) 返回 inf?
- python-3.x - 使画布背景透明 - python
- jenkins - Jenkins 管道 docker-compose 挂载卷
- parsing - 使用 FParsec,如何在解析器之间使用 manyCharsTill 而不会在结束字符串上失败?
- python - 使用 Elastic search dsl python analyze api
- python - 将一组参数传递给sqlite中的UPDATE语句
- c - 如何在 (int argc, char **argv) 中打印 argv
- reactjs - 使用 React.createElement 在上下文或道具中找不到“商店”
- c++ - 定义返回模板对象实例或引用的函数的最佳方式