This topic contains 2 replies, has 2 voices, and was last updated by
September 19, 2017 at 12:11 pm #80077ParticipantPoints: 54Rank: Member
I'm setting up an private NuGet server for testing purposes, but want to use it later for a place to get scripts from.
I don't completely understand how to pack a Powershell file to the NuGet. According to the documentation I need to use either the .nupkg file, which does not contain any references to the script I want to package (Unless I put dependency in there?)
I can't use the .ps1 extension to pack the file to my understanding. I need to use like the .csproj extension (Which is not created during the Visual Studio Powershell Script creation).
I get a psproj file if I create it with Visual Studio, but that doesn't seem to work.
Could anyone direct me towards a resource where it explains how to pack a Powershell script? I've tried to find help articles but to no avail.
September 28, 2017 at 7:05 am #80804ParticipantPoints: 0Rank: Member
You can use the Publish-* cmdlets, which call into nuget.exe and build the nuspec file (which nuget uses to create the nupkg file) and publish to the gallery. Before you can publish to your private NuGet Server, you need to register it as a repo with Register-PsRepository. Something like this for example:
Register-PSRepository -Name "TestPsGallery" `
-ScriptSourceLocation "http://testpsgallery.net/nuget" `
-ScriptPublishLocation "http://testpsgallery.net/api/v2/package" `
If you want to publish modules, you need to add the SourceLocation and PublishLocation parameters to the Register-PsRepository command. Once your repository is registered, you can use it like any other NuGet repo to publish and install scripts and modules to.
Publish-Script -Path PathToScript -Repository TestPsGallery -NuGetApiKey ApiKey
September 29, 2017 at 7:45 pm #80986ParticipantPoints: 54Rank: Member
I ended up doing above, however before I read your post. It wasn't very clear that you could do that.
The topic ‘Packing a Powershell script/module to Nuget’ is closed to new replies.