Skip to content

Contents and .targets in package dependencies are not included in the build process #6388

Closed

Description

@dotMorten

In a .NET Standard project I'm referencing a NuGet Package, that in turn references other nuget packages to perform bait'n'switch. For instance sub-packages for UWP, Android and iOS. These sub packages deploy various resources like native libraries, shaders etc.

Next you create your app heads for iOS, Android and UWP, and you reference your .NET Standard project. In turn the NuGet package also gets available for compilation. You can even access the APIs in the package from the project heads. However, the .targets and contents down in the package dependencies are not included, and thus at runtime, your app will crash, because the native libs and resources doesn't get deployed.

The workaround currently is to set "privateAssets=none" on the nuget reference, but this is very counter intuitive and is going to hurt my customers. They would expect things to "just work" when it compiles fine. At no point has my nuget package said to ignore .targets and contents (the dependency list in the nuget package does specify include="all" already, but it seems to not actually be doing that).

The interesting bit is, this issue doesn't affect UWP, but it affects WPF, iOS and Android.

Even worse, when using packages.config instead of Package Reference in your project head, you don't get any access to the APIs from the nuget package in the project heads. You have to manually add the package again in the project head.

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): VS UI

NuGet version (x.x.x.xxx): 4.5.0.4685
VS version (if appropriate): 15.5.2
OS version (i.e. win10 v1607 (14393.321)): win10 v1709 (16299.98)
Worked before? If so, with which NuGet version: AFAIK never worked

Sample Project

I can provide packages that reproduces the issue, but due to them having NDA content, it would have to be done through a back-channel.

/CC @rohit21agrawal helped me track down the issue. He understands it better and said he would add some more details here

Activity

  1. nkolev92 commented on Jan 8, 2018

    @nkolev92
    Member

    Related #6091, there we want to change the default for build assets to allow them to flow transitively.

  2. nkolev92 commented on Jul 29, 2022

    @nkolev92
    Member
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