Created
June 24, 2019 22:01
-
-
Save jasonchester/12597c0af92e65b728644155a19f05a3 to your computer and use it in GitHub Desktop.
Publish to Azure Artifacts Powershell Gallery Workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jobs: | |
- job: PublishScripts_LocalRepo | |
pool: | |
vmImage: 'vs2017-win2016' | |
steps: | |
- pwsh: | | |
Install-Module -Name PackageManagement -Force -AllowClobber | |
Install-Module -Name PowerShellGet -Force -AllowClobber | |
displayName: Update PackageManagement | |
- pwsh: | | |
Write-Host '----- Powershell Version' | |
$PSVersionTable | |
Write-Host '----- Loaded Modules' | |
Get-Module | Format-Table | |
Write-Host '----- Available Modules' | |
Get-Module -ListAvailable | Format-Table | |
Write-Host '----- Environment' | |
Get-ChildItem env: | |
displayName: 'debug info' | |
env: | |
SYSTEM_ACCESSTOKEN: $(System.AccessToken) | |
- pwsh: | | |
Import-Module -Name 'PackageManagement' -RequiredVersion '1.4.2' | |
Import-Module -Name 'PowerShellGet' -RequiredVersion '2.1.5' | |
$PSRepository = 'PSLocal' | |
$LocalRepoPath = (Join-Path -Path $Env:BUILD_STAGINGDIRECTORY -ChildPath 'PSLocalGallery') | |
if (Get-PSRepository -Name $PSRepository -ErrorAction SilentlyContinue) { | |
Unregister-PSRepository -Name $PSRepository | |
} | |
Remove-Item -Path $LocalRepoPath -Recurse -ErrorAction SilentlyContinue | |
New-Item -ItemType Directory -Force -Path $LocalRepoPath | Out-Null | |
Register-PSRepository -Name $PSRepository -SourceLocation $LocalRepoPath -ScriptSourceLocation $LocalRepoPath -InstallationPolicy Trusted | |
displayName: 'Create Local PS Repository' | |
- pwsh: | | |
Import-Module -Name 'PackageManagement' -RequiredVersion '1.4.2' | |
Import-Module -Name 'PowerShellGet' -RequiredVersion '2.1.5' | |
$galleryName = 'PSLocal' | |
Get-ChildItem -Path ./scripts/*.ps1 | | |
ForEach-Object -Process { | |
Test-ScriptFileInfo -Path $_ | |
Publish-Script -Path $_ -Repository $galleryName | |
} | |
Find-Script -Repository $galleryName | |
displayName: 'Publish Scripts' | |
- task: NuGetCommand@2 | |
inputs: | |
command: 'push' | |
vstsFeed: '/ef19beae***7d2e' | |
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' | |
nuGetFeedType: 'internal' | |
publishVstsFeed: '/ef19beae***7d2e' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment