Skip to content

The MSBuild "pack" target is missing a property for explicit assembly references #6858

Closed

Description

@MaxG117

I can't figure out how the NuSpec <references> element maps to a csproj or MSBuild property. I believe it is because this mapping was omitted. The following articles:
https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target
https://docs.microsoft.com/en-us/dotnet/core/tools/csproj#nuget-metadata-properties
fail to mention this.

Please let me know how to specify an explicit assembly reference for the pack target in a csproj file, explain why this capability does not exist, or use this issue to implement the mapping. Thank you.

Activity

  1. jainaashish commented on Apr 25, 2018

    @jainaashish

    @rohit21agrawal can you quick peek into this and respond accordingly?

  2. added this to the Backlog milestone on Apr 25, 2018
  3. rohit21agrawal commented on Apr 25, 2018

    @rohit21agrawal
    Contributor

    currently this capability does not exist. We will add this to our feature backlog. Thanks for reporting!

  4. added
    Priority:1High priority issues that must be resolved in the current sprint.
    on Apr 25, 2018
  5. MaxG117 commented on Apr 25, 2018

    @MaxG117
    Author

    I have an additional question/request.

    My nuget package consists of two assemblies: A.DLL and B.DLL, The consumer of my package (a.k.a. the target project) only needs to reference A.DLL, but A.DLL requires B.DLL at runtime. This is why I added an explicit assembly reference to A.DLL using the <references> NuSpec element. This worked as expected when targeting .NET Framework -- building the target project placed both A.DLL and B.DLL into the build output directory and the target project executes successfully.

    However, I'm now targeting .NET Standard and I found out that dotnet publish does not copy B.DLL into the publish directory. The only way to get B.DLL into the publish directory was to remove the explicit assembly reference to A.DLL from the NuSpec file. I believe this is a dotnet publish bug, If B.DLL is copied to the build output directory, it should also be copied to the publish directory. Please let me know if I should open a separate issue.

  6. rohit21agrawal commented on Apr 26, 2018

    @rohit21agrawal
    Contributor

    @MaxG117 can you show us the nuspec you use to build your package, and the nuspec that's present inside the generated package, along with the contents of the obj folder (*.g.props, *.g.targets, project.assets.json) , after you run a restore?

  7. added
    Priority:2Issues for the current backlog.
    and removed
    Priority:1High priority issues that must be resolved in the current sprint.
    on Jun 29, 2018
  8. added
    WaitingForCustomerApplied when a NuGet triage person needs more info from the OP
    on Jun 29, 2018
  9. TechnikEmpire commented on Jul 22, 2018

    @TechnikEmpire

    I've seen this as well. Microsoft.Data.Sqlite suffers from the same/similar problem if I'm understanding the notes here. If I reference that package in a .NET Standard library, then have a consumer reference my package (which references Microsoft.Data.Sqlite), the targets that unpack the Sqlite native assemblies into the bin folder on build will not get executed. I have to explicitly reference Microsoft.Data.Sqlite to get the package to work properly in this use cause (which I was argue is not only normal, but fundamental) and it's extremely annoying to pass this on to consumers. You're basically forced to hand out broken packages.

  10. 2 remaining items

  11. ghost added
    Status:InactiveIcebox issues not updated for a specific long time
    on Sep 1, 2022
  12. added
    Priority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.
    and removed
    Priority:2Issues for the current backlog.
    on Apr 3, 2023
  13. dotnet-policy-service commented on Mar 5, 2026

    @dotnet-policy-service
    Contributor

    Due to lack of recent activity, this issue has been marked as a candidate for icebox cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will add a Triage:NeedsTriageDiscussion label and lead to a triaging process.
    This process is part of the experimental Stale icebox issues cleanup we are currently trialing. Please share any feedback you might have in the linked issue.

  14. dotnet-policy-service commented on Mar 19, 2026

    @dotnet-policy-service
    Contributor

    This issue will now be closed since it had been marked Icebox cleanup candidate, but received no further activity in the past 14 days.

  15. removed this from the Backlog milestone on Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions