I've inherited a VS-2015 C# application and would like to migrate it to VS 2017 or 2019. It has a packages.config file with 4 packages:
<package id="AjaxControlToolkit" version="15.1.4.0" targetFramework="net4" />
<package id="EntityFramework" version="6.0.0" targetFramework="net4" />
<package id="Microsoft.AspNet.Providers" version="2.0.0" targetFramework="net4" />
<package id="Microsoft.AspNet.Providers.Core" version="2.0.0" targetFramework="net4" />
The first few lines of the project's sln file are:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}")
I'd like to migrate the packages.config file to a csproj file.
In Visual Studio 2017, I tried migrating it by right-clicking on packages.config and clicking 'Migrate packages.config to PackageReference', but it gives me an error:
Operation Failed - Project is not Eligible for Migration.
I also tried this tool: https://github.com/hvanbakel/CsprojToVs2017 and this also fails.
Is there really no way to migrate this to .csproj?
Restore packages (In Visual Studio, the references appear in Solution Explorer under the Dependencies \ NuGet or the References node.) If the package references in your project file are correct, use your preferred tool to restore packages. If the package references in your project file (. csproj) or your packages.
There is a workaround to this issue that I have used for older ASP.NET projects (and may potentially work with other project types which exhibit this issue too).
Essentially, the migration tool can still work, but first you must fool Visual Studio (temporarily) into thinking your project is a class library rather than a web project while you do the migration.
Detailed steps:
Close your project/solution if it's open in Visual Studio, and take a backup of it.
Open the .csproj file in a text editor
Cut the ProjectGuid
and ProjectTypeGuids
entries, and paste them somewhere else temporarily.
Insert <ProjectGuid>{7C796B6B-86B5-4C57-ADAA-12CF1FECDA71}</ProjectGuid>
where your ProjectGuid
entry was previously, and save the file
Open the project in Visual Studio (2017 or later)
Right-click the packages.config file and choose the option to migrate to package reference.
Once the migration is successful, close the project/solution again.
Go back into the .csproj file and replace the ProjectGuid
entry with the ProjectGuid
and ProjectTypeGuids
entries which you saved in step 3.
Re-open the project in Visual Studio. You should now be able to use it as normal.
This has worked for me on two projects so far. I can't promise there wouldn't be any side-effects in edge cases or more complex projects, but it's certainly something you can try.
Credit to this GitHub comment for the idea.
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