Comments (6)
@nkolev92 I was able to repro this. I created a repo at https://github.com/brettfo/13453 with all of the relevant information in the README, but the short version is that a Directory.Build.props
further up the tree sets the ManagePackageVersionsCentrally
property to false
and in the /src
directory, Directory.Packages.props
used to be able to override this property in the 205 SDK, but it doesn't in the 300 SDK. It's a regression between the versions, but it's certainly possible that it only "worked" in 205 on accident.
from home.
Issue moved from dotnet/msbuild#10157
- Please respond to @AR-May.
From @AR-May on Tuesday, May 21, 2024 2:05:08 PM
Team triage: it seems like it is a NuGet issue, moving it to NuGet repository.
from home.
There's some breaking changes for CPM opt-in in 8.0.3xx, namely: https://learn.microsoft.com/en-us/nuget/release-notes/nuget-6.10#breaking-changes.
In particular, you shouldn't need ManagePackageVersionsCentrally anymore.
Now, I'm not sure I see how that breaking change could lead to the behavior you're seeing.
I'm not able to repro it with: https://github.com/nkolev92/13453
E:\NuGet\temp\13453 [main ≡]> dotnet restore
Determining projects to restore...
Restored E:\NuGet\temp\13453\13453.csproj (in 212 ms).
E:\NuGet\temp\13453 [main ≡]> dotnet --version
8.0.300
E:\NuGet\temp\13453 [main ≡]>
Can you help me understand how my repro is different from yours?
from home.
I think only Directory.Packages.props is supposed to be imported.
Very likely that it was accidentally working.
cc @jeffkl
from home.
In my case, I disabled ManagePackageVersionsCentrally
in the root Directory.Build.Props file for the entire solution. This detail wasn't included in my original issue that was transferred here:
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>
</Project>
and enabled it only for individual test projects:
<Project Sdk="MSTest.Sdk/3.3.1">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" />
</ItemGroup>
</Project>
If it is no longer possible to configure ManagePackageVersionsCentrally
in the Directory.Build.Props file in the root folder, I can move the Directory.Packages.Props file to the UnitTests subfolder.
from home.
It seems that this has to do with MSBuild import order. Any Directory.Build.props
next to the project or any parent folder is imported first. A little after that, the Directory.Packages.props
is imported but only if ManagePackageVersionsCentrally
is set to true
. Since you're disabling central package management (CPM) in Directory.Build.props
, its too late to enable it in a project since the Directory.Packages.props
was already not imported.
Its rather usual to use central package management but only for a select set of projects. Like you suggested, you could move Directory.Packages.props
to a sub-directory with only those projects in it. Alternatively, you can create a Directory.Build.props
next to each project that wants to use CPM with ManagePackageVersionsCentrally=true
:
Project-level Directory.Build.props
:
<Project>
<PropertyGroup>
<!-- Enable CPM for the project in this directory -->
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<!-- Import parent Directory.Build.props which respects the ManagePackageVersionsCentrally property already being set -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Root Directory.Build.props
:
<Project>
<PropertyGroup>
<!-- Disable CPM by default unless something already enabled it -->
<ManagePackageVersionsCentrally Condition="'$(ManagePackageVersionsCentrally)' != 'true'">false</ManagePackageVersionsCentrally>
</PropertyGroup>
</Project>
I'm closing this issue as "by design" for now since with Directory.Build.props
its not possible to disable CPM globally but then enable it per-project.
from home.
Related Issues (20)
- Add docs for NU1508
- Possible NuGet vulnerability false positive when transitive package conflicts with BCL? HOT 1
- Update dotnet nuget why docs with assets file info
- Define `AuditSources` from an MSBuild property
- Map branch name from sourcelink to RepositoryBranch for NuGet pack
- dotnet nuget verify doesn't seem to match the checks run on nuget.org HOT 4
- Package Manager UI fails to load with a NRE due to restore errors HOT 2
- NuGet.Client uses the deprecated ILMerge package HOT 3
- MSB4018 When using central package managing and package is not specified in Directory.Packages.props HOT 6
- `dotnet list package` does not work if project is using central package management system, after upgrading to `.NET 8.0` HOT 4
- Add opt-in warning/error to require a package readme file
- Bubble-up Known Vulnerability Indicators in Solution Explorer for Transitive Packages
- [Bug Bash] Punctuation located incorrectly in the bottom-text of the “License Acceptance” dialog HOT 7
- Make 'why' command available in NuGet.Commands HOT 1
- [Localization] Revert latest changes from 6.11.x branch HOT 1
- Error NU1301 instead of "TLS validation failed" displays when running ‘dotnet restore’ before TLS certificate validation is disabled HOT 9
- dotnet add package stops checking sources on the first failure http code HOT 2
- Can not install signed package with certificate chain building issue HOT 2
- Fetching Vulnerability Resources doesn't respect cancellation HOT 1
- Improve the PM UI (especially update) experience for CPM transitively pinned packages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from home.