dotnet / dotnet/project-system
Nuget Central Package Management cannot update versions in imported "Directory.Packages.props" files with non-default name
- Dominant language
- C#
- Stars
- 1k
- Forks
- 415
- PR merge metrics
- No merged PRs in 30d
Description
---
**Issue moved from NuGet/Home#13041**
- Please respond to @WolfgangHG.
---
_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".
```
true
```
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](https://github.com/NuGet/Home/files/13463457/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](https://github.com/NuGet/Home/files/13463458/NugetCPM_Default.zip)
### Verbose Logs
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.