1 changed file
Build | ||
Publish-AzDOArtifactFeed.ps1 | ||
Publish-AzDOArtifactFeed.ps1
/Build/Publish-AzDOArtifactFeed.ps1-16+11/Build/Publish-AzDOArtifactFeed.ps1
Add comment 1 [CmdletBinding()]
Add comment 2 param (
Add comment 3 Minus [string]$PAT
Add comment 3 Plus [string]$AzDOAccountName = 'adamrushuk',
Add comment 4 Plus [string]$AzDOArtifactsFeedName = 'psmodules',
Add comment 5 Plus [string]$AzDOPat
Add comment 4 6 )
Add comment 5 7
Add comment 6 8 # Variables
Add comment 7 9 $moduleFolderPath = Join-Path -Path $env:SYSTEM_ARTIFACTSDIRECTORY -ChildPath "PowerShellPipeline\PSModule\PSvCloud"
Add comment 8 Minus $repositoryName = 'psmodules'
Add comment 10 Plus
Add comment 9 11 $feedUsername = 'NotChecked'
Add comment 10 Minus $packageSourceUrl = "https://adamrushuk.pkgs.visualstudio.com/_packaging/$repositoryName/nuget/v2" # Enter your VSTS AccountName (note: v2 Feed)
Add comment 12 Plus $packageSourceUrl = "https://$($AzDOAccountName).pkgs.visualstudio.com/_packaging/$AzDOArtifactsFeedName/nuget/v2" # Enter your VSTS AccountName (note: v2 Feed)
Add comment 11 13
Add comment 12 14 # Testing
Add comment 13 15 Write-Host "artifact_feed_pat env var: [$env:artifact_feed_pat]"
Add comment 14 Minus Write-Host "PAT param passed in: [$PAT]"
Add comment 16 Plus Write-Host "PAT param passed in: [$AzDOPat]"
Add comment 15 17
Add comment 16 18 ls env: | ft -AutoSize
Add comment 17 19
Add comment 18 Minus <#
Add comment 19 Minus Write-Host "NuGet binary info:"
Add comment 20 Minus Get-Command NuGet.exe | Format-List *
Add comment 21 20
Add comment 22 Minus Get-ChildItem $moduleFolderPath
Add comment 23 Minus Test-ModuleManifest -Path "$moduleFolderPath\PSvCloud.psd1"
Add comment 24 Minus #>
Add comment 25 Minus
Add comment 26 21 # This is downloaded during Step 3, but could also be "C:\Users\USERNAME\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe"
Add comment 27 22 # if not running script as Administrator.
Add comment 28 23 $nugetPath = (Get-Command NuGet.exe).Source
Add comment 32 27 }
Add comment 33 28
Add comment 34 29 # Create credential
Add comment 35 Minus $password = ConvertTo-SecureString -String $PAT -AsPlainText -Force
Add comment 30 Plus $password = ConvertTo-SecureString -String $AzDOPat -AsPlainText -Force
Add comment 36 31 $credential = New-Object System.Management.Automation.PSCredential ($feedUsername, $password)
Add comment 37 32
Add comment 38 33
Add comment 53 48 # Try to Publish a PowerShell module - this will prompt and download NuGet.exe, and fail publishing the module (we publish at the end)
Add comment 54 49 $publishParams = @{
Add comment 55 50 Path = $moduleFolderPath
Add comment 56 Minus Repository = $repositoryName
Add comment 51 Plus Repository = $AzDOArtifactsFeedName
Add comment 57 52 NugetApiKey = 'VSTS'
Add comment 58 53 Force = $true
Add comment 59 54 Verbose = $true
Add comment 64 59
Add comment 65 60 # Step 4
Add comment 66 61 # Register NuGet Package Source
Add comment 67 Minus & $nugetPath Sources Add -Name $repositoryName -Source $packageSourceUrl -Username $feedUsername -Password $PAT
Add comment 62 Plus & $nugetPath Sources Add -Name $AzDOArtifactsFeedName -Source $packageSourceUrl -Username $feedUsername -Password $AzDOPat
Add comment 68 63
Add comment 69 64 # Check new NuGet Source is registered
Add comment 70 65 & $nugetPath Sources List
Add comment 73 68 # Step 5
Add comment 74 69 # Register feed
Add comment 75 70 $registerParams = @{
Add comment 76 Minus Name = $repositoryName
Add comment 71 Plus Name = $AzDOArtifactsFeedName
Add comment 77 72 SourceLocation = $packageSourceUrl
Add comment 78 73 PublishLocation = $packageSourceUrl
Add comment 79 74 InstallationPolicy = 'Trusted'
Add comment 84 79 Register-PSRepository @registerParams
Add comment 85 80
Add comment 86 81 # Check new PowerShell Repository is registered
Add comment 87 Minus Get-PSRepository -Name $repositoryName
Add comment 82 Plus Get-PSRepository -Name $AzDOArtifactsFeedName
Add comment 88 83
Add comment 89 84
Add comment 90 85 # Step 6