All functions are now separated in multiple files. To simplify publishing all of them are simply combined in a single file to speedup loading and finally automatically published with the sample script publish.ps1.
To publish utility you can simply call
.\publish.ps1 -version x.y.z -apiKey yourApiKeyHerePlease follow the instruction you find at official GitHub repository.
# Register local provider
Register-PSRepository `
-Name Demo_build_utils `
-SourceLocation C:\develop\GitHub\powershell-build-utils\src\BuildUtils `
-PublishLocation C:\develop\GitHub\powershell-build-utils\src\BuildUtils `
-InstallationPolicy Trusted
# Publish module in local repository
Publish-Module `
-Path C:\develop\github\powershell-build-utils\src\BuildUtils `
-Repository Demo_build_utils `
-NuGetApiKey your_key_here
# Publish module to official gallery
Publish-Module `
-Path C:\develop\github\powershell-build-utils\src\BuildUtils `
-NuGetApiKey your_key_here `
-Verbose First step is register the feed where the package is published, as an example here is my public MyGet feed location. Be sure to use v2 version of feed, because at the time of this readme PowerShell works with v2 nuget package version
Register-PSRepository -Name MyGet -SourceLocation https://www.myget.org/F/alkampfer/api/v2You should be able to find this module with the following command
PS C:\somedir> Find-Module -Name BuildUtils
Version Name Repository Description
------- ---- ---------- -----------
0.x.x BuildUtils PSGallery Simple utilities to simplify build of .NET projectIf everything is done correctly, we can install the module for the current user with this command (this will not require administrative permissions and install module for current user only)
Install-package BuildUtils -Confirm:$false -Force -Scope CurrentUser -VerboseOnce the package is installed successfully, you can import it and verify all the functions that are available for usage
PS C:\somedir> Import-Module BuildUtils
PS C:\somedir> Get-Command -module BuildUtils
CommandType Name Version Source
----------- ---- ------- ------
Function Edit-XmlNodes 0.1.2 build-utils
Function Get-7ZipLocation 0.1.2 build-utils
Function Update-SourceVersion 0.1.2 build-utilsYou should be able now to simply use and manage those functions.
After you aligned version in .nuspec and .psd1 file, just run nuget to create package file. You can run following command in the src directory.
nuget.exe pack .\BuildUtils.nuspecThis will create a nuget package that can be pushed on a specific feed by this command
nuget.exe push build-utils.0.1.1.nupkg yourapikey -src https://www.myget.org/F/alkampfer/api/v3/index.jsonTo verify that the module is correct you can check for package correctness with the command
Test-ModuleManifest -Path .\BuildUtils.psd1To verify if we have installed a specific function we can use the following command.
Get-Command Get-7ZipLocationIf you have the function installed on a specific module, you can always uninstall module (module name can be found with previous command)
Uninstall-Module -name build-utils -Force