Nuget Central Package Management cannot update versions in imported "Directory.Packages.props" files with non-default name #9351
Labels
Bug
This is a functional issue in already written code.
Triage-Investigate
Reviewed and investigation needed by dev team
Milestone
Issue moved from NuGet/Home#13041
From @WolfgangHG on Saturday, November 25, 2023 9:20:13 AM
NuGet Product Used
Visual Studio Package Management UI
Product Version
"nuget.exe" reports 6.8.0.122
Worked before?
No response
Impact
It bothers me. A fix would be nice
Repro Steps & Context
While experimenting with CPM, I first tried something similar to this rather weird structure of nuget CPM declarations:
In the solution root, there sits a "Directory.Packages.props" file that imports a file "Included_Directory.Packages.props".
This file "Included_Directory.Packages.props" defines a version for "Newtonsoft.Json":
The projects declare a package reference:
When using Nuget Package Manager to update "Newtonsoft.Json", it does not update the version in "Included_Directory.Packages.props" but overwrites the version in each project file:
See attached sample (with original state - you have to update "Newtonsoft.Json" to reproduce the problem): NugetCPM_NonDefault.zip
My reason for doing something like this: I have a rather large tools solution with a lot of utility dlls, and I have an application that references those utility dlls (by including copies of the tools dll in a local folder and referencing those dlls instead of using Nuget package references - due to historical reasons :-( ). So I want to copy the "Directory.Packages.props" from the utility solution to the application solution with a different name, and import it in the application solution "Directory.Packages.props". When updating a nuget package, VS would modify each project file instead of trying to write to the imported "Directory.Packages.props".
It works when the imported file has the name "Directory.Packages.props" and is just placed in a subdir. So, this would be the workaround for me.
Here is a sample with this workaround:
NugetCPM_Default.zip
Verbose Logs
No response
The text was updated successfully, but these errors were encountered: