project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Project with PackageId containing parameter does not import nested dependencies when referenced by another project.

Open wouterroos opened this issue 4 years ago • 15 comments

Visual Studio Version: 16.8.6

Summary: When a project references another project that has a PackageId that contains a parameter (e.g. <PackageId>MyPackage.$(SomeParameter)</PackageId>), any dependencies of the referenced project are not imported into the referencing project.

Steps to Reproduce:

  1. Create 2 projects, of which one has a PackageId containing a parameter and at least one Project/PackageReference.
  2. Reference this project in the other project.

Expected Behavior: The project reference tree contains both the referenced project and the references of that project (see green arrow in image below) image

Actual Behavior: The project reference tree doesn't contain any reference of the referenced project (see red arrow in image below) image

User Impact: Due to this issue, we need to include a lot of additional package/project references required by the projects references whereas this usually is taken care of by the project system.

wouterroos avatar Mar 11 '21 10:03 wouterroos

@wouterroos thanks for the report.

Unfortunately I'm unable to repro this locally, despite trying quite a few permutations of your scenario.

To investigate further: In the project that you think is not receiving transitive references, enable "Show All Files" in Solution Explorer, then open the obj/project-assets.json file. Look in that file for references to the dependency you're not seeing in the tree. If it exists there, but not under the Dependencies node, then we have a display issue.

Do any of your project or package references specify PrivateAssets values?

Can you copy your solution, delete all the code and anything else that is redundant to the problem, then share it with me? If you don't want to share it publicly, then please file an issue using the Report a Problem feature in VS and attach a ZIP of your solution to that, then link it here so I can see it.

drewnoakes avatar Mar 11 '21 11:03 drewnoakes

@drewnoakes Thanks for your quick response!

To investigate further: In the project that you think is not receiving transitive references, enable "Show All Files" in Solution Explorer, then open the obj/project-assets.json file. Look in that file for references to the dependency you're not seeing in the tree. If it exists there, but not under the Dependencies node, then we have a display issue.

I checked the obj/project-assets.json file (its actually in a subfolder of obj in our solution (using OutputPath and IntermediateOutputPath) since we're building for multiple platforms, which can have different (versions of) dependencies) and it does seem to contain the correct entry (MyPackage.SomeParameterValue) with all underlying dependencies. As far as I can tell it has an identical structure to a project reference that does show up correctly, so that might point towards the display issue you mentioned. However, both ResSharper and Visual Studio also don't seem to 'see' these dependencies as they don't show up in the intellisense.

Do any of your project or package references specify PrivateAssets values?

We don't use PrivateAssets.

Can you copy your solution, delete all the code and anything else that is redundant to the problem, then share it with me? If you don't want to share it publicly, then please file an issue using the Report a Problem feature in VS and attach a ZIP of your solution to that, then link it here so I can see it.

Unfortunately, it is quite a large and complicated solution which I cannot share in its entirety. If the answers to your questions I provided aren't enough to solve the issue, please let me know, I will then invest some time into creating a repro-case.

wouterroos avatar Mar 11 '21 11:03 wouterroos

@wouterroos thanks for the extra detail.

both ResSharper and Visual Studio also don't seem to 'see' these dependencies as they don't show up in the intellisense.

That points at a larger issue than just the display of the dependencies tree.

Unfortunately, it is quite a large and complicated solution which I cannot share in its entirety.

Totally understand that you cannot share it in its entirety. Thankfully it should be straightforward to trim it down. I'd suggest:

  1. Copying the entire repo to somewhere else
  2. Removing any unrelated projects from disk and the solution
  3. Removing all source code from remaining projects
  4. Removing or obfuscating any identifying information you do not wish to share

It'd be good to verify that the issue persists between each step.

I understand that's a fair bit of work, but without a repro it'll be hard to diagnose what's going on. It doesn't sound like your design-time builds are failing, and I can't think of any diagnostics or logs that'd be useful here. As you say, your project setup is moderately complex, so the problem may only exist at the intersection of several features.

drewnoakes avatar Mar 11 '21 21:03 drewnoakes

@drewnoakes Thanks. I might be able to make some time later today to create a repro. Will post it here when done.

wouterroos avatar Mar 12 '21 06:03 wouterroos

Unfortunately we don't have a repro hence we can't investigate further.

jjmew avatar Mar 30 '21 17:03 jjmew

@jjmew I haven't had time to work on a repro yet but I still want to do this. Could you leave the issue open for a while longer?

Thanks

wouterroos avatar Mar 31 '21 04:03 wouterroos

@wouterroos once you find a repro, post it here and we will reopen the issue.

drewnoakes avatar Mar 31 '21 20:03 drewnoakes

@drewnoakes Great! I will create one tomorrow and report back here.

wouterroos avatar Apr 01 '21 05:04 wouterroos

@drewnoakes Please see the repro case attached to https://developercommunity.visualstudio.com/t/project-with-packageid-containing-parameter-does-n/1390991?from=email

wouterroos avatar Apr 06 '21 08:04 wouterroos

Thanks @wouterroos, I think I know what this issue is, and that it's related to the fact your projects are mutli-targeting. I am away from work for the rest of the week so will pick this up once I'm back.

drewnoakes avatar Apr 06 '21 12:04 drewnoakes

@drewnoakes Great! looking forward to hearing from you.

wouterroos avatar Apr 06 '21 14:04 wouterroos

@drewnoakes Any update on this?

wouterroos avatar May 20 '21 05:05 wouterroos

@wouterroos our focus is elsewhere than the dependencies tree at the moment. I don't have a timeline for this.

drewnoakes avatar Jul 05 '21 01:07 drewnoakes

I figured.

wouterroos avatar Jul 05 '21 03:07 wouterroos

I'm experiencing the same issue: I am setting up PackageId using MSBuild properties, and I can't see the nested dependencies in Visual Studio. My solution builds and debugs fine and if I use the NuGet packages with the custom naming scheme, they have the correct dependencies.

I have confirmed that if I remove my logic changing PackageId, Visual Studio works correctly.

Has anyone found a workaround if this cannot be fixed?

jv42 avatar Mar 07 '25 17:03 jv42