Closed flcdrg closed 5 years ago
Same problem using 15.9.0 Preview 1
Uploaded logs and recording via Report a Problem to https://developercommunity.visualstudio.com/content/problem/321125/migrate-packagesconfig-to-packagereference-doesnt.html
Could it be that you haven't saved your project and are looking at the csproj file using a different editor? i just tried the migration, and upon unloading the project and viewing the csproj file from VS, i did see the following entries in the project file:
<ItemGroup>
<PackageReference Include="AlphaFS">
<Version>2.1.3</Version>
</PackageReference>
<PackageReference Include="log4net">
<Version>2.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Web.Xdt">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="PublishedApplications">
<Version>2.4.0</Version>
</PackageReference>
<PackageReference Include="Rx-Linq">
<Version>2.1.30214</Version>
</PackageReference>
<PackageReference Include="SimpleInjector">
<Version>2.5.0</Version>
</PackageReference>
</ItemGroup>
No, definitely saved the project. I'll try on a different computer to see if I get the same result or not.
Ok.. so on different computer it worked as expected (same results as you).
I re-ran it on my initial computer and also managed to get it to work. Once thing I noticed though is that while the migration was taking place, Visual Studio popped up a dialog saying the project had been modified on disk and did I want to reload it. This time I said "No" (pretty sure previously I'd been saying "Yes").
Did it say project or file? I imagine this could happen if you have the csproj or packages.config file open in VS editor.
Anyway, if this is not an issue for you anymore, feel free to close the issue!
It says 'The project 'chocolatey' has been modified outside the environment
Neither the csproj nor packages.config are open in VS (or anything else).
Possibly related, but not sure if you noticed during the migration it throws up an init.ps1 script into Notepad - maybe that's messing with the project when the package is uninstalled as part of the migration.
I've experienced the same behavior, I can follow up offline with a repro.
/cc @anangaur @karann-msft
Finally found the reason with the help of @jainaashish.
In the migration process, some packages modified the csproj. When VS detected the changes and asked for reloading, all changes were missing. Just skip the changes before save, and the PackagesReferences will be persisted.
Yeah, I think that corresponds with what I've seen. Sometimes I would get prompted as to whether to reload or ignore changes. Ignoring and then saving seems to work around this.
I'd like to add some information to this. In my case, converting a console application, the .csproj file was definitely not updated immediately after the conversion completed, something I could reproduce. Instead, I had to save the solution. I was never prompted to reload/ignore, because the .csproj file hadn't changed.
What I see happening is the package references are cached in the obj folder. On save, that cached information is written to .csproj. I really think the converter should explicitly save and/or finish writing to .csproj. It's possible--though unlikely--to delete the obj folder before saving, and all package references are lost.
To recap, steps to reproduce what I saw:
Will close this issue since there's nothing the nuget team can do about it. This is an issue with VS asking to reload and making the PR not persist.
A good work around as @rido-min and @flcdrg mentioned is to ignore changes until everything is finished.
Trying to use the Migrate packages.config to PackageReference tool in Visual Studio 15.8 against the
chocolatey
project under the src directory from https://github.com/chocolatey/chocoThe tool removes packages.config, reports a successful migration, but the chocolatey.csproj does not contain any PackageReference elements.
Confusingly, the Solution Explorer does show new package nodes under the References nodes, but I think these are 'phantom' nodes - if I delete the .vs folder and reload the solution, they disappear.