I have a PS1 script that I use in all my projects to sign the assemblies. Until now I copied this file over to all my projects. Now I wanted to create a nuget package with the PS1 file.
I created a nuspec file and put the file in "content". Unfortunately nothing happened. Then I tried to put it in lib. Still noting happened. When I restore the package in my project no files where created in this project.
When I analyst the nupkg file with my 7-Zip the file looks OK. The ps1 file was in content, lib respectively.
I didn't found anything to this topic online. Can someone explain to me, how to create such a NuGet-Package?
When a project using packages.config
installs a NuGet package, the package's tools\install.ps1
script will run. However, this no longer happens when the project using the package uses PackageReference
(such as SDK style projects, used by .NET Core).
Similarly, the files in the content
folder of the nupkg
are copied into the project on install, but only when the project uses packages.config
. PackageReference
projects use the contentFiles
folder in the nupkg
, however the behaviour is different. Those files are copied only on build, not install, for .NET Framework projects and on publish for .NET Core projects. Probably not what you want for signing assemblies.
The feature you probably want to use is including MSBuild props and targets in your package. Note that the props
and targets
file names must match the package id exactly for NuGet to use them. You probably want to use afterTargets="build"
at a guess.