Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading xproj in Visual Studio 2019

I need to upgrade a project in Visual Studio 2019, which is of xproj type. When I attempt to open the solution it says it needs upgrading, but then I get the following message:

Xproj project files are no longer supported. For details on migrating to csproj see https://learn.microsoft.com/en-us/dotnet/core/migration/.

The linked document mentions either doing it in in Visual Studio (doesn't work) or using dotnet migrate. When I attempt this I get the following:

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.

Looking further it appears that dotnet migrate has been deprecated in dotnetcore 3.0

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-migrate

This command is deprecated. The dotnet migrate command is no longer available starting with .NET Core 3.0 SDK. It can only migrate a Preview 2 .NET Core project to a 1.x .NET Core project, which is out of support.

I've tried it on Visual Studio 2017 and 2015 command lines and get the exact same error. It seems that having dotnetcore3 installed removes the ability to do this.

Is there any way of migrating the project without acces to the recommended Microsoft tools?

like image 370
Andrew Avatar asked Jan 23 '20 09:01

Andrew


1 Answers

You can list your installed dotnet core sdk versions by this command:

dotnet --list-sdks

Then you can switch back to an older version of the dotnet core sdk (e.g. 2.0.2) by this command:

dotnet new globaljson --sdk-version 2.0.2

This should be performed in the folder where your xproj is located.

Finally you can migrate your project by:

dotnet migrate
like image 143
bati06 Avatar answered Oct 22 '22 04:10

bati06