1
votes

I'm trying to setup a library nuget package for .net core with the dotnet pack command, however, instead of just having a dll included in the nuget package, a content file from another references nuget is added (which makes the nuget file size 9.6MB instead of 59KB).

Is there a way to avoid getting files and content from other nuget packages in a nuget library project?

to reproduce: Create a .net core library Add Hl7.Fhir.Specification.STU3 nuget reference run dotnet pack

The nuspec file in the newly created nuget package, will reveal that the specification.zip file is regarded as content that must be added.

I've tried testing with a custom nuspec file which is basicly a copy from the dotnet output, but without the content reference. The problem I see, is that the nuspec file contains a lot of references which must be maintained somehow.

1
Could excluding assets of the referenced package do the Job? I'm not sure if it applies to .zip-files also, have only seen excluding .cs-files. docs.microsoft.com/en-us/nuget/consume-packages/…Peter Wurzinger
I just tested it and I couldn't make it work.Harald S. Hanssen

1 Answers

1
votes

Peter Wurzinger's suggestion worked for me. It's a shame he posted as a comment, rather than an answer, since he deserves the rep points. Anyway, this is my csproj

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Hl7.Fhir.Specification.STU3" Version="0.96.0" ExcludeAssets="contentFiles" />
  </ItemGroup>

</Project>

when I pack, the bin\Debug\test.1.0.0.nuspec file does not contain the specification.zip file elements that exists when I don't use ExcludeAssets.