-
Notifications
You must be signed in to change notification settings - Fork 390
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
Adding both Project and Package references to .Net Core SDK based project shows permanent dependency warning, when PackageReference Version range specified #2836
Comments
Why do you want to have both a package reference and a project reference to the same things? |
Since SDK based csproj supports setting all .nupkg related stuff inline, we decided to drop .nuspec file dependency during build\pack. This approach (setting Package and Project reference to the same thing) So basically this changes workflow from this when working within one sln (classic csproj + .nuspec):
to this (SDK based csproj, no .nuspec files):
Greater alternative would be allowing setting NuGet version constraints right in ProjectReference node, like this: |
Got it, thanks @YakhontovYaroslav. That's what I suspected, but wanted to confirm. @emgarten @rrelyea - what do you expect to happen in cases like this? |
The restore behavior is correct, you cannot have both a package and project reference. I suggest using a condition and passing an additional property when calling pack to switch over to the view you want pack to see. The root issue here seems to be that pack doesn't support custom version ranges for project references, that is tracked here: NuGet/Home#5556 |
@emgarten Issue You have referenced will indeed provide descent solution, once implemented, in fact i have suggested similar alternative above. But im not sure about first part of Your answer. You mentioned that i cannot have both type of references to the same thing, while sure i can. Restore\Build\Pack\etc works flawlessly both in VS, CLI (msbuild) and CI with such approaches. Im not sure what MsBuild does in this case under the hood, but im suspecting it just ignores PackageReference, relying solely on ProjectReference. The only quirk is dependencies node in VS UI. Its not that much of an issue, but its really confusing when i`m trying to figure out whether there are real issues with project dependencies or not. Conditional references will sure fix the problem, but imho its just too heavy to embrace and follow for regular developer. In fact Setting PackageReference Version constraints already forces us to edit csproj manually (adding\updating references through NuGet UI will remove any Version constrains that was set earlier). Ideally VS should allow user to set Project and Package references version constraints through Properties window and Add Reference\NuGet package dialogs. |
@drewnoakes Take a look and see if this scenario has any weird behavior in the current implementation of the Dependencies tree. |
The dependencies tree is working correctly here. There is no resolved package in this case, so it appears with a triangle. I sympathise with the request to make it easier to substitute a project reference in the IDE with a package reference during pack. It seems like @emgarten's approach is the way to go. |
This might be somehow related to #2835
Steps to reproduce:
Actual behavior:
Build generates .nupkg with correct .nuspec
but dependencies node shows warning on NuGet
Expected behavior:
No warning shown on NuGet dependency.
The text was updated successfully, but these errors were encountered: