Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio ignoring CPM opt-out when ManagePackageVersionsCentrally is false but Directory.Packages.props exists #12359

Closed
wazzamatazz opened this issue Jan 11, 2023 · 4 comments
Assignees
Labels
Area:RestoreCPM Central package management Functionality:VisualStudioUI Priority:2 Issues for the current backlog. Resolution:External This issue appears to be External to nuget Triage:Investigate Type:Bug
Milestone

Comments

@wazzamatazz
Copy link

NuGet Product Used

Visual Studio Package Management UI

Product Version

VS 2022 Enterprise 17.4.3

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

Consider a repository with the following structure:

- Directory.Packages.props
- src/
  - Directory.Packages.props
  - solution.sln
  - project/
    - project.csproj
  • The top-level Directory.Packages.props opts into central package management (<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>).
  • The nested Directory.Packages.props file in the src folder opts out of central package management (<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>).
  • When solution.sln is opened in Visual Studio and you add a package reference to the project via the VS Package Manager UI, the project reference in the project file is added without a version and a package version is added to the nested Directory.Packages.props instead, even though the closest Directory.Packages.props file to the solution has opted out of central package management.

Steps to reproduce:

  1. Download and unzip the attached file: cpm_issue.zip
  2. Open the solution file in Visual Studio.
  3. Add a NuGet package reference to the project via the Package Manager UI.

Workaround is to manually enter or update package references in the project file instead of using the UI.

Verbose Logs

No response

@jeffkl
Copy link
Contributor

jeffkl commented Jan 13, 2023

@tmeschter I've confirmed this behavior. Does Project System look at the ManagePackageVersionsCentrally property? Or does it just look at the CentralPackageVersionsFileImported property? In this case:

  • Directory.Packages.props is imported
  • CentralPackageVersionsFileImported == true
  • ManagePackageVersionsCentrally == false

So Visual Studio should not update Directory.Packages.props and use the default behavior.

@jeffkl
Copy link
Contributor

jeffkl commented Jan 30, 2023

@tmeschter gentle ping ^

@nkolev92 nkolev92 added Resolution:External This issue appears to be External to nuget Priority:2 Issues for the current backlog. labels Feb 9, 2023
@jeffkl jeffkl changed the title Visual Studio ignoring CPM opt-out in nested Directory.Packages.props Visual Studio ignoring CPM opt-out when ManagePackageVersionsCentrally is false but Directory.Packages.props exists Feb 23, 2023
@jeffkl jeffkl added this to the 6.6 milestone Feb 23, 2023
@jeffkl
Copy link
Contributor

jeffkl commented Feb 23, 2023

A fix for this has been submitted for the Visual Studio Project System and will be available in Visual Studio 17.6 Preview 2.

https://dev.azure.com/devdiv/DevDiv/_git/CPS/pullrequest/453924

@jeffkl
Copy link
Contributor

jeffkl commented Feb 27, 2023

This has been fixed and the change will be available in Visual Studio 17.6 Preview 2

@jeffkl jeffkl closed this as completed Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreCPM Central package management Functionality:VisualStudioUI Priority:2 Issues for the current backlog. Resolution:External This issue appears to be External to nuget Triage:Investigate Type:Bug
Projects
None yet
Development

No branches or pull requests

4 participants