project-system: .csproj file not updated in Visual Studio until user does a Save All or closes solution

From @dougbu on February 25, 2017 0:38

Please read the following information before posting the issue.

Before posting the issue…

  • If you’re having trouble with the NuGet client tools (the Visual Studio extension, NuGet.exe command line tool, etc.), you are in the right place.

Details about Problem

NuGet product used: VS UI Nuget Package Manager 4.0.0

dotnet.exe --version: 1.0.0-rc4-004883

VS version (if appropriate): 15.0.0+26222.1d15rel

OS version: Win10 v1607 (14393.696)

Worked before? Not positive but thing old package.config file was updated immediately.

Detailed repro steps so we can see the same problem

  1. Create a .NET Core Console solution
  2. Add a package e.g. Microsoft.EntityFrameworkCore.SqlServer v1.0.0
  3. Save everything
  4. Switch to a console window and confirm the .csproj file contains
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.0.0" />
    
  5. Open “Manage NuGet Packages…” again
  6. Update the package to a newer version e.g. v1.1.0 in above case
  7. Wait for restore to complete
  8. Switch to console window and… Expected
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
    
    Actual
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.0.0" />
    
  9. Save everything in Visual Studio
  10. Now Actual will match Expected.

Other suggested things

Verbose Logs

Please include verbose logs (NuGet.exe <COMMAND> -verbosity detailed | dotnet.exe <COMMAND> --verbose | etc…)

Sample Project

Very helpful if you can zip a project and paste into this issue!

Copied from original issue: NuGet/Home#4689

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 16 (11 by maintainers)

Most upvoted comments

Is there a reason that you expect the project to be saved in this case?

I expect to be able to move back and forth between the command line and Visual Studio without these strange synchronization failures.

As it is, Visual Studio misleads users. The least I’d expect is an indication saving the project is necessary.

@emgarten said in the original issue

NuGet doesn’t force a save here for perf reasons. With packages.config it was a much smaller file…

project.json files were actually larger than .csproj files, at least in the converted ASP.NET repos. Nonetheless, the experience has regressed with the move to smaller files.

@collinprice As per above the behavior you are seeing with Manage NuGet packages is by design per the document save model that inside Visual Studio. The internal bug that I opened was about adding an unsaved indicator to better indicate that the project file is unsaved.

I’m taking from the bug you filed that you would prefer that Visual Studio always saved the project? If so I’ll turn it into actionable suggestion that folks can vote on - because the new one has the danger of being closed as by design.

@davkean Ahh that makes more sense. My team is in the process of upgrading our projects from package.config to PackageReference and this behaviour has only added to the confusion. Thanks for clarifying. If you could, please turn my post into an actionable suggestion.

Any movement on this action? Not seeing any flag, and it creates hell when you are switching between branches in source control when you forget to do a save all.