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

When packing transitive dependencies for PrivateAssets=all, pack lib, not ref #36

Closed
kzu opened this issue Dec 3, 2020 · 0 comments
Closed
Labels
enhancement New feature or request

Comments

@kzu
Copy link
Member

kzu commented Dec 3, 2020

If a package reference with PrivateAssets=all has transitive dependencies and the project targets netstandard2.0, the transitive dependency is packed from the ref (reference assembly) folder instead of the lib folder, making the reference unusable at run-time.

Repro:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <PackageId>TransitiveRef</PackageId>
    <Description>TransitiveRef</Description>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NuGetizer" Version="0.5.0" />
    <PackageReference Include="Scriban" Version="3.0.4" PrivateAssets="all" />
  </ItemGroup>

</Project>

Package contents seems to be correct:

❯ nugetize
Package: TransitiveRef.1.0.0.nupkg
         C:\Temp\bin\TransitiveRef.nuspec
    Authors    : TransitiveRef
    Description: TransitiveRef
    Version    : 1.0.0
  Contents:
    /lib/
      netstandard2.0/
        Microsoft.CSharp.dll
        Scriban.dll
        System.Runtime.CompilerServices.Unsafe.dll
        System.Threading.Tasks.Extensions.dll
        TransitiveRef.dll
        TransitiveRef.pdb

However, opening the System.Runtime.CompilerServices.Unsafe.dll assembly reveals it to be a reference assembly with no implementations.

@kzu kzu closed this as completed in 32f8bee Dec 4, 2020
@kzu kzu added the enhancement New feature or request label Dec 4, 2020
kzu added a commit that referenced this issue Dec 4, 2020
When packing a package reference with PrivateAssets=all, you typically
do so in order to run the resulting code from the target pack folder
directly without having any extra dependencies that have to be resolved
from elsewhere. For this typical use case, you'll want to pack actual
"runnable" assemblies, not reference assemblies.

Packages that pack reference assemblies (typically done for netstandard)
resulted code that couldn't run because the packed assemblies contained
no code.

So we first look at related files that have a "/ref/" in the path, see
if we can find the same file but under "/lib/" and if so, pack that
instead.

Fixes #36
kzu added a commit to devlooped/ThisAssembly that referenced this issue Dec 10, 2020
kzu added a commit to devlooped/ThisAssembly that referenced this issue Dec 10, 2020
@devlooped devlooped locked and limited conversation to collaborators Nov 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant