Can dotnet pack create a nuget package without adding content files from other nuget packages?











up vote
0
down vote

favorite












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.










share|improve this question


















  • 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
    Nov 8 at 11:26












  • I just tested it and I couldn't make it work.
    – Verzada
    Nov 8 at 12:53















up vote
0
down vote

favorite












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.










share|improve this question


















  • 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
    Nov 8 at 11:26












  • I just tested it and I couldn't make it work.
    – Verzada
    Nov 8 at 12:53













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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.










share|improve this question













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.







c# .net nuget pack






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 10:27









Verzada

7119




7119








  • 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
    Nov 8 at 11:26












  • I just tested it and I couldn't make it work.
    – Verzada
    Nov 8 at 12:53














  • 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
    Nov 8 at 11:26












  • I just tested it and I couldn't make it work.
    – Verzada
    Nov 8 at 12:53








1




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
Nov 8 at 11:26






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
Nov 8 at 11:26














I just tested it and I couldn't make it work.
– Verzada
Nov 8 at 12:53




I just tested it and I couldn't make it work.
– Verzada
Nov 8 at 12:53












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










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 binDebugtest.1.0.0.nuspec file does not contain the specification.zip file elements that exists when I don't use ExcludeAssets.






share|improve this answer





















  • Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
    – Peter Wurzinger
    Nov 8 at 18:53










  • well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
    – Ziv
    Nov 8 at 19:50










  • I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
    – Verzada
    Nov 9 at 8:30










  • The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
    – Verzada
    Nov 9 at 8:44










  • Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
    – Ziv
    Nov 9 at 13:24











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205824%2fcan-dotnet-pack-create-a-nuget-package-without-adding-content-files-from-other-n%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










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 binDebugtest.1.0.0.nuspec file does not contain the specification.zip file elements that exists when I don't use ExcludeAssets.






share|improve this answer





















  • Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
    – Peter Wurzinger
    Nov 8 at 18:53










  • well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
    – Ziv
    Nov 8 at 19:50










  • I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
    – Verzada
    Nov 9 at 8:30










  • The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
    – Verzada
    Nov 9 at 8:44










  • Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
    – Ziv
    Nov 9 at 13:24















up vote
1
down vote



accepted










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 binDebugtest.1.0.0.nuspec file does not contain the specification.zip file elements that exists when I don't use ExcludeAssets.






share|improve this answer





















  • Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
    – Peter Wurzinger
    Nov 8 at 18:53










  • well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
    – Ziv
    Nov 8 at 19:50










  • I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
    – Verzada
    Nov 9 at 8:30










  • The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
    – Verzada
    Nov 9 at 8:44










  • Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
    – Ziv
    Nov 9 at 13:24













up vote
1
down vote



accepted







up vote
1
down vote



accepted






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 binDebugtest.1.0.0.nuspec file does not contain the specification.zip file elements that exists when I don't use ExcludeAssets.






share|improve this answer












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 binDebugtest.1.0.0.nuspec file does not contain the specification.zip file elements that exists when I don't use ExcludeAssets.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 15:46









Ziv

669416




669416












  • Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
    – Peter Wurzinger
    Nov 8 at 18:53










  • well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
    – Ziv
    Nov 8 at 19:50










  • I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
    – Verzada
    Nov 9 at 8:30










  • The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
    – Verzada
    Nov 9 at 8:44










  • Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
    – Ziv
    Nov 9 at 13:24


















  • Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
    – Peter Wurzinger
    Nov 8 at 18:53










  • well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
    – Ziv
    Nov 8 at 19:50










  • I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
    – Verzada
    Nov 9 at 8:30










  • The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
    – Verzada
    Nov 9 at 8:44










  • Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
    – Ziv
    Nov 9 at 13:24
















Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
– Peter Wurzinger
Nov 8 at 18:53




Ah alright, so it seems that arbitrary files can indeed be excluded using ExcludeAssets - good to know!
– Peter Wurzinger
Nov 8 at 18:53












well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
– Ziv
Nov 8 at 19:50




well, it excludes all contentFiles from the package. If you had a package with multiple contentFiles and you want to keep some and exclude others, it would be more difficult.
– Ziv
Nov 8 at 19:50












I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
– Verzada
Nov 9 at 8:30




I didin't set ExcludeAssets="contentFiles", but to "all", so that's where my mistake was.
– Verzada
Nov 9 at 8:30












The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
– Verzada
Nov 9 at 8:44




The package size went from 9.5MB to 28KB, so the setting really matters in the cases where you get content files included from a referenced package
– Verzada
Nov 9 at 8:44












Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
– Ziv
Nov 9 at 13:24




Maybe NuGet ignores ExcludeAssets="all", because semantically that's the same as not referencing the package at all, so it's unlikely to ever be what the user wants (you can comment out the line if you want to remove it temporarily without removing it from the file).
– Ziv
Nov 9 at 13:24


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205824%2fcan-dotnet-pack-create-a-nuget-package-without-adding-content-files-from-other-n%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)