According to docs, new PackageReference is not supported (yet) for ASP.NET projects https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files
But what about class libraries that ASP.NET depend on? Let's suppose I have following .NET Framework solution:
I couldn't migrate to PackageReference Foo.AspNetWebApp as it not support for ASP.NET non-Core projects. But could I migrate everything else? Is it supported scenario? I will win at least merges for everything else :-)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With