Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

    • Star(0)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist

    Select an option

    Save rvrsh3ll/78739132045f7a58a6428830f44cdec4 to your computer and use it in GitHub Desktop.
    Create a NuGet Package to Install a Powershell Module
    Download the CLI Version of NuGet
    https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
    --Create Work Paths
    md c:\nuget
    md c:\nuget\source
    md c:\nuget\publish
    -- One-Time - Create local NuGet Repo/feed using a local drive path
    cd c:\nuget
    Register-PSRepository -Name Local_Nuget_Feed -SourceLocation C:\Nuget\publish -PublishLocation c:\Nuget\publish -InstallationPolicy Trusted
    (To Remove: Unregister-PSRepository -Name Local_Nuget_Feed)
    --- Verift/Show all PS Repository
    Get-PSRepository
    -- Create Prep folder for your New NuGet Package
    cd c:\nuget\source
    md MyModuleName
    Copy MyModuleName.PSD1 and MyModuleName.PSM1 files from your dev location to here (c:\nuget\source\MyModuleName)
    -- Edit your Powershell Module Manifest .psd1 File
    Set the RootModule to the name of your Module.psm1 file
    Set the ModuleVersion
    --- Create and Install your Powershell Module as a NuGet Package ans save into the Nuget Package Repo/Feed
    cd c:\nuget\source
    Publish-Module -Path .\MyModuleName -Repository Local_Nuget_Feed -NuGetApiKey 'ABC123'
    (The .nupkg file is created here: c:\nuget\publish)
    -- List Packages in Repository
    nuget list -source c:\nuget\publish
    -- Delete Package
    nuget delete MyModuleName 1.0.3 -source c:\nuget\publish
    --- Install your Powershell module from the .nupkg file you just created
    --- In an Elevated Powershell console:
    Install-Package MyModuleName
    -- Check Nuget Package Version After Installation
    get-package | where-object {$_.name -match 'MyModuleName'}
    --- Test Loading/Calling a Function from your PS Module
    MyFunction
    --- List all functions in your PSM1 module
    Get-Command -Module MyModuleName
    --- Verify the correct version of your module and manifest files were installed in the Global Modules Folder here:
    C:\Program Files\WindowsPowerShell\Modules\MyModuleName
    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp