Skip to content

.NET SDK projects don't pack satellite assemblies from SatelliteDllsProjectOutputGroup #4698

Closed

Description

@AArnott

d15rel 26224.1
dotnet --version 1.0.0

The SatelliteDllsProjectOutputGroup target produces and returns @(SatelliteDllsProjectOutputGroupOutput) items, which should be included in the nupkg file. For instance, when I build a netstandard library, our LSBuild (.lcl file based) build authoring produces the *.resources.dll satellite assemblies and adds them to this item list. But when packing, these satellite assemblies are not picked up. This is good enough for the rest of msbuild, which properly copies these satellite assemblies across P2P references.

I also notice that even the built-in support for Strings.resx and Strings.es.resx, where I am getting resource assemblies produced by the standard VS toolchain, nuget pack still omits those satellite assemblies.

Activity

  1. AArnott commented on Feb 27, 2017

    @AArnott
    ContributorAuthor

    If there is a workaround I can apply, I'd be happy to for now. How do the packaging targets determine what to pack from the individual TargetFramework builds? I hope I can copy the satellite assembly items to whatever item list is required so that they get included there.

  2. rohit21agrawal commented on Feb 27, 2017

    @rohit21agrawal
    Contributor

    @AArnott (BuiltProjectOutputGroup)->FinalOutputPath is what is used to determine what DLLs to be picked up for each TFM.

    https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Build.Tasks.Pack.Library/Pack.targets#L119

    https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Build.Tasks.Pack.Library/Pack.targets#L165-L175

    Suggested workaround would be to write a target which would copy the items of @(SatelliteDllsProjectOutputGroupOutput) to BuiltProjectGroupOutput and make sure the FinalOutputPath metadata is set on them.

  3. AArnott commented on Feb 27, 2017

    @AArnott
    ContributorAuthor

    Thanks for the workaround. I can apply that.
    FWIW though, that's conflating two output groups where they are designed to be distinct. NuGet should call into both to get all the files out. I'm not even sure the workaround will work -- because conflating the two could cause malfunctions in msbuild or project systems, including P2P references. Referencing projects expect only one DLL in the BuiltProjectGroupOutput so if I throw in all the satellite assemblies that could break P2Ps.

    It looks like your .targets invoke two targets at the moment (Built and Documentation). So we're talking about adding a third to it. Too bad that targets list isn't a property or item list that I can simply add to.

  4. AArnott commented on Feb 27, 2017

    @AArnott
    ContributorAuthor

    OK, so that third target doesn't set FinalOutputPath on the items. I created my own that does, so now what we have is my satellite assemblies are copied to the root of the nupkg's lib folder (so only one survives since they all have the same name). Instead, they should all be in subfolders of the various lib\TFM folders based on their culture name.

    There appears to be no way to solve this in a workaround, since the Pack task strips away all metadata from these items and only keeps the FinalOutputPath, so evidently the logic to place the DLLs in the right places doesn't allow additional input to help it along.

    Any other ideas?

  5. AArnott commented on Feb 27, 2017

    @AArnott
    ContributorAuthor

    I've contrived a workaround. I added this to my project file:

      <Target Name="PackSatelliteAssemblies" BeforeTargets="_WalkEachTargetPerFramework">
        <MSBuild Condition="'$(IncludeBuildOutput)' == 'true'"
                 Projects="$(MSBuildProjectFullPath)"
                 Targets="SatelliteDllsProjectOutputGroupWithTargetFramework"
                 BuildInParallel="$(BuildInParallel)"
                 Properties="TargetFramework=%(_TargetFrameworks.Identity)">
          <Output TaskParameter="TargetOutputs" ItemName="_SatelliteAssembliesToPack" />
        </MSBuild>
        <ItemGroup>
          <Content Include="@(_SatelliteAssembliesToPack)" Condition=" '%(Culture)' != '' ">
            <Pack>true</Pack>
            <PackagePath>lib\%(TargetFramework)\%(TargetPath)</PackagePath>
          </Content>
        </ItemGroup>
      </Target>
    
      <Target Name="SatelliteDllsProjectOutputGroupWithTargetFramework"
              DependsOnTargets="SatelliteDllsProjectOutputGroup"
              Returns="@(_SatelliteDllsProjectOutputGroupOutputWithFinalOutputPath)">
        <ItemGroup>
          <_SatelliteDllsProjectOutputGroupOutputWithFinalOutputPath Include="@(SatelliteDllsProjectOutputGroupOutput)">
            <TargetFramework>$(TargetFramework)</TargetFramework>
          </_SatelliteDllsProjectOutputGroupOutputWithFinalOutputPath>
        </ItemGroup>
      </Target>

    EDIT: I edited later to fix some over-build bugs I had in the original version.

  6. rohit21agrawal commented on Feb 27, 2017

    @rohit21agrawal
    Contributor

    @AArnott instead of adding it to Content and providing a PackagePath, did you try adding them to _TargetPathsToAssemblies with the FinalOutputPath metadata set ?
    https://github.com/NuGet/NuGet.Client/blob/02df800a3b5422f8e8e828d66417de8927757b85/src/NuGet.Core/NuGet.Build.Tasks.Pack.Library/Pack.targets#L119

    On the disk, are satellite assemblies placed in TFM specific folders?

  7. rohit21agrawal commented on Feb 27, 2017

    @rohit21agrawal
    Contributor

    Too bad that targets list isn't a property or item list that I can simply add to.

    This is an area i have already planned to add an extension point to, and will do that whenever we fix this bug.

  8. AArnott commented on Feb 27, 2017

    @AArnott
    ContributorAuthor

    @rohit21agrawal: Yes, I tried adding it to _TargetPathsToAssemblies but that didn't work as I describe in my earlier comment.

    Satellite assemblies must be found in culture\some.resources.dll paths under where the original assembly is found. CLR rules. So yes, they must be found under the TFM.

  9. rohit21agrawal commented on Feb 27, 2017

    @rohit21agrawal
    Contributor

    @AArnott currently Pack figures out the TFM to put a DLL using the path of the DLL on disk. If the path doesn't contain a TFM, then it puts it in the root.

    This will also change in future and I will supplement it by providing TargetFramework metadata to the _TargetPathsToAssemblies item.

  10. AArnott commented on Feb 27, 2017

    @AArnott
    ContributorAuthor

    I see. How do you find which segment of a path is the TFM? It's there, but evidently the task wasn't finding it:

    image

  11. rohit21agrawal commented on Feb 27, 2017

    @rohit21agrawal
    Contributor

    it has to be directly under the TFM folder.

  12. AArnott commented on Feb 28, 2017

    @AArnott
    ContributorAuthor

    OK, well it won't be, by design of CLR requirements. So it looks like your enhancement to the Task is required.
    In the meantime, my workaround seems to work so I might use that if this bug ends up being the last adoption blocker.

  13. AArnott commented on Feb 28, 2017

    @AArnott
    ContributorAuthor

    There's another (potential) problem here in your nuget .targets. You are invoking MSBuild in your own project, but because you pass in more than just TargetFramework as a global property (you add BuildProjectReferences=false), this causes over-build. Right now, you appear to be getting away with it, evidently because the targets you're invoking don't have expensive side effects. But the SatelliteDllsProjectOutputGroup target will end up building most of the project, again, because MSBuild sees your unique set of global properties so it thinks it's building a new project.

  14. AArnott commented on Feb 28, 2017

    @AArnott
    ContributorAuthor
  15. added a commit that references this issue on Mar 4, 2017
  16. borgdylan commented on Mar 11, 2017

    @borgdylan

    I have noticed the same thing, all satellite made by resgen and al are omitted even if I can see them in bin/Debug/TFM

  17. borgdylan commented on Mar 11, 2017

    @borgdylan

    I also confirm that @AArnott 's workaround works. All it takes is <PackageReference Include="NuGet4698Workaround" Version="1.0.1" PrivateAssets="All" />.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions