Home: No way to include text files in package using dotnet pack command

Created on 12 Nov 2016  路  4Comments  路  Source: NuGet/Home

Moved from https://github.com/dotnet/cli/issues/4073 on behalf of @maxim-boligatov. Comments are quite relevant so inlined.


Steps to reproduce

put the following text in project.json:

"buildOptions": {
"copyToOutput": [ "MyOwnTextFile.config" ]
},

run dotnet pack

Expected behavior

nupkg contains "MyOwnTextFile.config" file

Actual behavior

nupkg does not contain "MyOwnTextFile.config" file

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64


something like this

"packOptions": {
"files": {
"mappings" : {
"lib/net461/": {
"include": "MyOwnTextFile.config"
}
}
}
}


Nice! Now it has correct place in package.

But how to tell that this file should be placed in project and copied on build to output?

In other words setup "contentFiles":

https://docs.nuget.org/create/nuspec-reference#contentfiles-with-visual-studio-2015-update-1-and-later

Pack Question

All 4 comments

@piotrpMSFT @maxim-boligatov closing this, since this is a pretty easily achievable scenario with the msbuild based dotnet pack. feel free to msg me/comment here if there are any issues. The spec is available at :

https://github.com/NuGet/Home/wiki/Adding-nuget-pack-as-a-msbuild-target#including-content-in-package

@rohit21agrawal
Thanks... I will need to investigate it and be ready for msbuild.
Only one question. How soon can we get it for using in production?

@maxim-boligatov
@rrelyea will be better able to comment on the timeline. If I am not wrong, the RTM for tooling is somewhere around February.

Please feel free to ask any questions if you have any issues with using the msbuild based dotnet pack.

Hey, can someone please guide me on how I can achieve this? I've got a .net core package with some contentFiles and I need to have them copied to the output of the root project. Can't find a way to have the copyToOutput attribute attached in the nuspec file as described here:

https://docs.microsoft.com/en-gb/nuget/schema/nuspec#contentfiles-with-visual-studio-2015-update-1-and-later

Using VS2017 for both the package and the root project.

Was this page helpful?
0 / 5 - 0 ratings