Is it safe/feasible to migrate to "new project system" (PackageReference) for .NET framework solutions containing ASP.NET projects? Is it safe/feasible to migrate to "new project system" (PackageReference) for .NET framework solutions containing ASP.NET projects? asp.net asp.net

Is it safe/feasible to migrate to "new project system" (PackageReference) for .NET framework solutions containing ASP.NET projects?


It's feasible and will save you tons of time when doing NuGet package restore (shorter CI builds), you can read more details about the gains here.

Also you can use the following useful extension for doing the conversion easily.


I used the following PowerShell script for my conversion process of asp.net projects with success on over 20 projects at this point. You must first change PackageReference to the default behavior of Visual Studio in Tools > NuGet Package Manager > Package Manager Settings > Default package management format. Then you can run the powershell script in the Package Manager Console window, replacing the name of the project you wish to migrate.

$packages = Get-Package -ProjectName MyProjectName$packages | %{ Uninstall-Package -Id $_.Id -ProjectName $_.ProjectName -RemoveDependencies -Force}$packages | %{ Install-Package -Id $_.Id -Version $_.Versions[0] -ProjectName $_.ProjectName }

Expect a few innocuous errors during the uninstall step, as this script will try to force uninstall everything in the order it was listed, instead of the order of the dependencies. In the end it does remove them all and get rid of your packages.config for you. Then the last line of the script adds them all back this time as PackageReference's. Occasionally you need to do a bit of project file maintenance if the uninstall missed some targets or packages folder references that should have been removed.