Skip to content

Commit

Permalink
Add note on how to extend package contents dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu authored Jun 17, 2021
1 parent ea7427a commit e39bd72
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@ Finally, you can focedly turn a project reference build output into a private as
This section contains miscelaneous useful features that are typically used in advanced scenarios and
are not necessarily mainstream.

### Dynamically Extending Package Contents

If you need to calculate additional items to inject into the package dynamically, you can run a target
before `GetPackageContents`, which is the target NuGetizer uses before packing to determine what needs
to be included. At this point you can add arbitrary `<PackageFile ... PackagePath=... />` items laying
out precisely what it is you want to inject into the .nupkg. For example:

```xml
<Target Name="AddPackageContents" BeforeTargets="GetPackageContents">
<PackageFile Include="$(MSBuildProjectDirectory)\..\docs\**\*.md" PackagePath="docs\%(RelativeDir)%(Filename)%(Extension)" />
</Target>
```

This example will add all markdown files in a `docs` folder one level above the current project, and
place them all under the `docs` folder in the `.nupkg`, preserving their original folder structure.

### Packing arbitrary files from referenced packages

If you want to pack files from referenced packages, you can simply add `PackageReference` attribute
Expand Down Expand Up @@ -342,4 +358,4 @@ packing on CI, since at that point all that's run are the P2P protocol involving
<img src="https://raw.githubusercontent.com/devlooped/oss/main/assets/images/sponsors.svg" alt="sponsors" height="36" width="36" style="vertical-align: text-top; border: 0px; padding: 0px; margin: 0px">&nbsp;&nbsp;by&nbsp;<a href="https://github.com/clarius">@clarius</a>&nbsp;<img src="https://raw.githubusercontent.com/clarius/branding/main/logo/logo.svg" alt="sponsors" height="36" width="36" style="vertical-align: text-top; border: 0px; padding: 0px; margin: 0px">
</h3>

*[get mentioned here too](https://github.com/sponsors/devlooped)!*
*[get mentioned here too](https://github.com/sponsors/devlooped)!*

0 comments on commit e39bd72

Please sign in to comment.