Use one feed in each nuget.config in official builds (#14363)
Co-authored-by: Robert Holt <rjmholt@gmail.com> # Conflicts: # build.psm1
This commit is contained in:
parent
a012227f2a
commit
eb2295b58d
34
build.psm1
34
build.psm1
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
# On Unix paths is separated by colon
|
||||
|
@ -325,7 +325,8 @@ function Start-PSBuild {
|
|||
try {
|
||||
# Excluded sqlite3 folder is due to this Roslyn issue: https://github.com/dotnet/roslyn/issues/23060
|
||||
# Excluded src/Modules/nuget.config as this is required for release build.
|
||||
git clean -fdX --exclude .vs/PowerShell/v16/Server/sqlite3 --exclude src/Modules/nuget.config
|
||||
# Excluded nuget.config as this is required for release build.
|
||||
git clean -fdX --exclude .vs/PowerShell/v16/Server/sqlite3 --exclude src/Modules/nuget.config --exclude nuget.config
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
@ -598,7 +599,11 @@ function Restore-PSPackage
|
|||
[Parameter()]
|
||||
$Options = (Get-PSOptions -DefaultToNew),
|
||||
|
||||
[switch] $Force
|
||||
[switch] $Force,
|
||||
|
||||
[switch] $InteractiveAuth,
|
||||
|
||||
[switch] $PSModule
|
||||
)
|
||||
|
||||
if (-not $ProjectDirs)
|
||||
|
@ -622,21 +627,28 @@ function Restore-PSPackage
|
|||
'Microsoft.NET.Sdk'
|
||||
}
|
||||
|
||||
if ($Options.Runtime -notlike 'fxdependent*') {
|
||||
if ($PSModule.IsPresent) {
|
||||
$RestoreArguments = @("--verbosity")
|
||||
}
|
||||
elseif ($Options.Runtime -notlike 'fxdependent*') {
|
||||
$RestoreArguments = @("--runtime", $Options.Runtime, "/property:SDKToUse=$sdkToUse", "--verbosity")
|
||||
} else {
|
||||
$RestoreArguments = @("/property:SDKToUse=$sdkToUse", "--verbosity")
|
||||
}
|
||||
|
||||
if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) {
|
||||
if ($VerbosePreference -eq 'Continue') {
|
||||
$RestoreArguments += "detailed"
|
||||
} else {
|
||||
$RestoreArguments += "quiet"
|
||||
}
|
||||
|
||||
if ($InteractiveAuth) {
|
||||
$RestoreArguments += "--interactive"
|
||||
}
|
||||
|
||||
$ProjectDirs | ForEach-Object {
|
||||
$project = $_
|
||||
Write-Log "Run dotnet restore $project $RestoreArguments"
|
||||
Write-Log -message "Run dotnet restore $project $RestoreArguments"
|
||||
$retryCount = 0
|
||||
$maxTries = 5
|
||||
while($retryCount -lt $maxTries)
|
||||
|
@ -647,7 +659,7 @@ function Restore-PSPackage
|
|||
}
|
||||
catch
|
||||
{
|
||||
Write-Log "Failed to restore $project, retrying..."
|
||||
Write-Log -message "Failed to restore $project, retrying..."
|
||||
$retryCount++
|
||||
if($retryCount -ge $maxTries)
|
||||
{
|
||||
|
@ -656,7 +668,7 @@ function Restore-PSPackage
|
|||
continue
|
||||
}
|
||||
|
||||
Write-Log "Done restoring $project"
|
||||
Write-Log -message "Done restoring $project"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -2390,7 +2402,7 @@ function Copy-PSGalleryModules
|
|||
|
||||
Find-DotNet
|
||||
|
||||
Restore-PSPackage -ProjectDirs (Split-Path $CsProjPath) -Force:$Force.IsPresent
|
||||
Restore-PSPackage -ProjectDirs (Split-Path $CsProjPath) -Force:$Force.IsPresent -PSModule
|
||||
|
||||
$cache = dotnet nuget locals global-packages -l
|
||||
if ($cache -match "info : global-packages: (.*)") {
|
||||
|
@ -3172,8 +3184,10 @@ function New-NugetConfigFile
|
|||
<packageSources>
|
||||
<clear />
|
||||
<add key="[FEEDNAME]" value="[FEED]" />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
</disabledPackageSources>
|
||||
<packageSourceCredentials>
|
||||
<[FEEDNAME]>
|
||||
<add key="Username" value="[USERNAME]" />
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="powershell_nuget" value="https://powershell.pkgs.visualstudio.com/PowerShell/_packaging/powershell/nuget/v3/index.json" />
|
||||
<add key="PSGallery" value="https://www.powershellgallery.com/api/v2/" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
</disabledPackageSources>
|
||||
</configuration>
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||
|
||||
<Import Project="..\..\PowerShell.Common.props" />
|
||||
<PropertyGroup>
|
||||
<Product>PowerShell</Product>
|
||||
<Company>Microsoft Corporation</Company>
|
||||
<Copyright>(c) Microsoft Corporation.</Copyright>
|
||||
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="PowerShellGet" Version="2.2.4.1" />
|
||||
|
|
11
src/Modules/nuget.config
Normal file
11
src/Modules/nuget.config
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="PSGallery" value="https://www.powershellgallery.com/api/v2/" />
|
||||
<add key="powershell_nuget" value="https://powershell.pkgs.visualstudio.com/PowerShell/_packaging/powershell/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
</disabledPackageSources>
|
||||
</configuration>
|
10
test/tools/Modules/nuget.config
Normal file
10
test/tools/Modules/nuget.config
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="PSGallery" value="https://www.powershellgallery.com/api/v2/" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
<clear />
|
||||
</disabledPackageSources>
|
||||
</configuration>
|
|
@ -15,7 +15,7 @@ steps:
|
|||
|
||||
- powershell: |
|
||||
Import-Module -Force "$(Build.SourcesDirectory)/tools/releaseBuild/azureDevOps/AzArtifactFeed/SyncGalleryToAzArtifacts.psm1"
|
||||
SyncGalleryToAzArtifacts -AzDevOpsFeedUserName $(AzDevOpsFeedUserName) -AzDevOpsPAT $(AzDevOpsFeedPAT) -Destination $(Build.ArtifactStagingDirectory)
|
||||
SyncGalleryToAzArtifacts -AzDevOpsFeedUserName $(AzDevOpsFeedUserName) -AzDevOpsPAT $(AzDevOpsFeedPAT2) -Destination $(Build.ArtifactStagingDirectory)
|
||||
displayName: Download packages from PSGallery that need to be updated
|
||||
condition: succeededOrFailed()
|
||||
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
steps:
|
||||
- powershell: |
|
||||
Import-Module $env:REPOROOT/build.psm1 -Force
|
||||
New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT) -FeedName AzDevOpsFeed -Destination $env:REPOROOT/src/Modules
|
||||
parameters:
|
||||
- name: "repoRoot"
|
||||
default: $(REPOROOT)
|
||||
|
||||
if(-not (Test-Path "$env:REPOROOT/src/Modules/nuget.config"))
|
||||
steps:
|
||||
- pwsh: |
|
||||
Import-Module ${{ parameters.repoRoot }}/build.psm1 -Force
|
||||
New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT2) -FeedName AzDevOpsFeed -Destination '${{ parameters.repoRoot }}/src/Modules'
|
||||
|
||||
if(-not (Test-Path "${{ parameters.repoRoot }}/src/Modules/nuget.config"))
|
||||
{
|
||||
throw "nuget.config is not created"
|
||||
}
|
||||
displayName: 'Add nuget.config for Azure DevOps feed for PSGallery modules'
|
||||
condition: and(succeededOrFailed(), ne(variables['AzDevOpsFeed'], ''))
|
||||
- pwsh: |
|
||||
Import-Module ${{ parameters.repoRoot }}/build.psm1 -Force
|
||||
New-NugetConfigFile -NugetFeedUrl $(AzDevOpsPackageFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT2) -FeedName AzDevOpsFeed -Destination '${{ parameters.repoRoot }}'
|
||||
|
||||
if(-not (Test-Path "${{ parameters.repoRoot }}/nuget.config"))
|
||||
{
|
||||
throw "nuget.config is not created"
|
||||
}
|
||||
displayName: 'Add nuget.config for Azure DevOps feed for packages'
|
||||
condition: and(succeededOrFailed(), ne(variables['AzDevOpsPackageFeed'], ''))
|
||||
|
|
|
@ -42,7 +42,8 @@ jobs:
|
|||
displayName: 'Skip Alpine or fxdependent for PS v6.0.*'
|
||||
|
||||
- template: insert-nuget-config-azfeed.yml
|
||||
|
||||
parameters:
|
||||
repoRoot: $(REPOROOT)
|
||||
|
||||
- powershell: |
|
||||
import-module "$env:REPOROOT/build.psm1"
|
||||
|
@ -51,7 +52,9 @@ jobs:
|
|||
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
|
||||
|
||||
- powershell: |
|
||||
$env:AzDevOpsFeedPAT2 = '$(AzDevOpsFeedPAT2)'
|
||||
& "$env:REPOROOT/tools/releaseBuild/vstsbuild.ps1" -ReleaseTag $(ReleaseTagVar) -Name '$(build)'
|
||||
$env:AzDevOpsFeedPAT2 = $null
|
||||
|
||||
displayName: 'Build and package'
|
||||
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
|
||||
|
|
|
@ -32,20 +32,14 @@ jobs:
|
|||
tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -location $(PowerShellRoot) -BootStrap
|
||||
displayName: 'Bootstrap VM'
|
||||
|
||||
- pwsh: |
|
||||
Import-Module $(Build.SourcesDirectory)/build.psm1 -Force
|
||||
New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT) -FeedName AzDevOpsFeed -Destination "$(PowerShellRoot)/src/Modules"
|
||||
|
||||
if(-not (Test-Path "$(PowerShellRoot)/src/Modules/nuget.config"))
|
||||
{
|
||||
throw "nuget.config is not created"
|
||||
}
|
||||
displayName: 'Add nuget.config for AzDevOps feed for PSGallery modules '
|
||||
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
|
||||
parameters:
|
||||
repoRoot: $(PowerShellRoot)
|
||||
|
||||
- pwsh: |
|
||||
$env:AZDEVOPSFEEDPAT = '$(AzDevOpsFeedPAT)'
|
||||
$env:AzDevOpsFeedPAT2 = '$(AzDevOpsFeedPAT2)'
|
||||
$(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -Symbols -location $(PowerShellRoot) -Build -ArtifactName macosBinResults
|
||||
$env:AZDEVOPSFEEDPAT = $null
|
||||
$env:AzDevOpsFeedPAT2 = $null
|
||||
displayName: 'Build'
|
||||
|
||||
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
|
||||
|
|
|
@ -31,10 +31,12 @@ jobs:
|
|||
parameters:
|
||||
ReleaseTagVar: $(ReleaseTagVar)
|
||||
|
||||
- template: insert-nuget-config-azfeed.yml
|
||||
|
||||
- template: cloneToOfficialPath.yml
|
||||
|
||||
- template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml
|
||||
parameters:
|
||||
repoRoot: $(PowerShellRoot)
|
||||
|
||||
- powershell: |
|
||||
|
||||
$runtime = switch ($env:Architecture)
|
||||
|
|
|
@ -61,7 +61,7 @@ jobs:
|
|||
|
||||
- template: cloneToOfficialPath.yml
|
||||
|
||||
- powershell: |
|
||||
- pwsh: |
|
||||
# cleanup previous install
|
||||
if((Test-Path "${env:ProgramFiles(x86)}\WiX Toolset xcopy")) {
|
||||
Remove-Item "${env:ProgramFiles(x86)}\WiX Toolset xcopy" -Recurse -Force
|
||||
|
@ -69,7 +69,7 @@ jobs:
|
|||
|
||||
$toolsDir = New-Item -ItemType Directory -Path '$(Build.ArtifactStagingDirectory)\tools'
|
||||
$wixUri = 'https://github.com/wixtoolset/wix3/releases/download/wix311rtm/wix311-binaries.zip'
|
||||
Invoke-RestMethod -Uri $wixUri -OutFile '$(Build.ArtifactStagingDirectory)\tools\wix.zip'
|
||||
Invoke-RestMethod -Uri $wixUri -OutFile '$(Build.ArtifactStagingDirectory)\tools\wix.zip' -MaximumRetryCount 5 -RetryIntervalSec 10
|
||||
|
||||
Import-Module '$(PowerShellRoot)/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/wix.psm1'
|
||||
Install-WixZip -zipPath '$(Build.ArtifactStagingDirectory)\tools\wix.zip'
|
||||
|
|
Loading…
Reference in a new issue