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

[Bug]: CPVM: Directory.Packages.props Imports aren't being respected #11560

Closed
ransagy opened this issue Feb 3, 2022 · 4 comments
Closed

[Bug]: CPVM: Directory.Packages.props Imports aren't being respected #11560

ransagy opened this issue Feb 3, 2022 · 4 comments
Labels
Area:RestoreCPM Central package management Functionality:Restore Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Bug

Comments

@ransagy
Copy link

ransagy commented Feb 3, 2022

NuGet Product Used

dotnet.exe, MSBuild.exe

Product Version

dotnet 6.0.1, nuget 6.0.0.280, msbuild 16.11.1+3e40a09f8

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

I have an existing code base that used a combination of Directory.Build.targets files to achieve a pre-cursor to what CPVM does.
The main repo folder has one such file with a bunch of <PackageReference Update="A" Version="1.0.0" /> directives and each solution/project that needs to specialize/override anything has their own copy with an import directive to the baseline file, i.e. <Import Project="../Directory.Build.targets" />.

When migrating that codebase to use CPVM, I followed the same pattern with the Directory.Packages.props files, assuming the Import will apply in the same order and behavior.

This seems to not be the case, As the baseline version of a package "wins" over the nearest version defined in an inner props file.

I've made a simple repro to showcase the issue with Newtonsoft.Json v12 and v13, Where i try to use a type that only exists in the latter in one project.

Expected: The build completes successfully, Meaning the project with the specific Directory.Packages.props with v13 was applied properly.

Actual: The build failes on the missing type, Meaning the baseline v12 was applied.

Steps to repro:

  1. Checkout the repo @ https://github.com/ransagy/TestCPVMHierarchy
  2. Try to build the repo with dotnet build
  3. Note the failure, Remove the Import directive from Console\Directory.Packages.props
  4. Build again, This time it passes successfully.

I know there is an open issue on version overriding specifically for CPVM, But i didn't feel this comes from the same source.

There is an msbuild.log file in the repro that is the output of dotnet build in my case as an example.

Verbose Logs

No response

@ransagy
Copy link
Author

ransagy commented Feb 3, 2022

Pinging @JonDouglas for general awareness as who seems to be leading the CPVM effort lately.

@ransagy
Copy link
Author

ransagy commented Feb 3, 2022

I forgot to add (or rather, had to rewrite the issue because GitHub erased what I typed because it was too long) - i tried Update instead of Include where applicable and that didn't seem to matter either.

@nkolev92
Copy link
Member

nkolev92 commented Feb 4, 2022

@ransagy

You basically have multiple includes, and NuGet will only read the first one, which happens to be the top one.
You're basically hitting #9864.

I'd change the version to PackageVersion Update in the Directory.Packages.Props

Closing this as dup of that.

@nkolev92 nkolev92 closed this as completed Feb 4, 2022
@nkolev92 nkolev92 added Resolution:Duplicate This issue appears to be a Duplicate of another issue Area:RestoreCPM Central package management Functionality:Restore labels Feb 4, 2022
@ransagy
Copy link
Author

ransagy commented Feb 4, 2022

You're right; I missed that one, thanks.
One thing to note - it works as long as the nearest props file changes its directives to Update, It fails to build entirely if the baseline props file does. In case someone comes across that.

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:Restore Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Bug
Projects
None yet
Development

No branches or pull requests

3 participants