Skip to content

Commit

Permalink
Add a way to use only NuGet feed sources (PowerShell#24528)
Browse files Browse the repository at this point in the history
* Update build.psm1

* update default feeds

* fix issue with cgmanifest having duplicate existing entries

* update pattern
  • Loading branch information
TravisEz13 authored Oct 31, 2024
1 parent 3f51dfa commit adac4c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
15 changes: 9 additions & 6 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ function Switch-PSNugetConfig {
param(
[Parameter(Mandatory = $true, ParameterSetName = 'user')]
[Parameter(Mandatory = $true, ParameterSetName = 'nouser')]
[ValidateSet('Public', 'Private')]
[ValidateSet('Public', 'Private', 'NuGetOnly')]
[string] $Source,

[Parameter(Mandatory = $true, ParameterSetName = 'user')]
Expand All @@ -760,16 +760,19 @@ function Switch-PSNugetConfig {
}
}

$dotnetSdk = [NugetPackageSource] @{Url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v2'; Name = 'dotnet' }
$gallery = [NugetPackageSource] @{Url = 'https://www.powershellgallery.com/api/v2/'; Name = 'psgallery' }
$nugetorg = [NugetPackageSource] @{Url = 'https://api.nuget.org/v3/index.json'; Name = 'nuget.org' }
if ( $Source -eq 'Public') {
$dotnetSdk = [NugetPackageSource] @{Url = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v2'; Name = 'dotnet' }
$gallery = [NugetPackageSource] @{Url = 'https://www.powershellgallery.com/api/v2/'; Name = 'psgallery' }
$nugetorg = [NugetPackageSource] @{Url = 'https://api.nuget.org/v3/index.json'; Name = 'nuget.org' }

New-NugetConfigFile -NugetPackageSource $nugetorg, $dotnetSdk -Destination "$PSScriptRoot/" @extraParams
New-NugetConfigFile -NugetPackageSource $gallery -Destination "$PSScriptRoot/src/Modules/" @extraParams
New-NugetConfigFile -NugetPackageSource $gallery -Destination "$PSScriptRoot/test/tools/Modules/" @extraParams
} elseif ( $Source -eq 'NuGetOnly') {
New-NugetConfigFile -NugetPackageSource $nugetorg -Destination "$PSScriptRoot/" @extraParams
New-NugetConfigFile -NugetPackageSource $gallery -Destination "$PSScriptRoot/src/Modules/" @extraParams
New-NugetConfigFile -NugetPackageSource $gallery -Destination "$PSScriptRoot/test/tools/Modules/" @extraParams
} elseif ( $Source -eq 'Private') {
$powerShellPackages = [NugetPackageSource] @{Url = 'https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell-7-5-preview-test-2/nuget/v3/index.json'; Name = 'powershell' }
$powerShellPackages = [NugetPackageSource] @{Url = 'https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell/nuget/v3/index.json'; Name = 'powershell' }

New-NugetConfigFile -NugetPackageSource $powerShellPackages -Destination "$PSScriptRoot/" @extraParams
New-NugetConfigFile -NugetPackageSource $powerShellPackages -Destination "$PSScriptRoot/src/Modules/" @extraParams
Expand Down
2 changes: 1 addition & 1 deletion nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell-7-5-preview-test-2/nuget/v3/index.json" />
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell-7-5-preview-test-2/nuget/v3/index.json" />
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
2 changes: 1 addition & 1 deletion test/tools/Modules/nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell-7-5-preview-test-2/nuget/v3/index.json" />
<add key="powershell" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShell/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
6 changes: 4 additions & 2 deletions tools/findMissingNotices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ $existingRegistrationsJson.Registrations | ForEach-Object {
$registration = [Registration]$_
if ($registration.Component) {
$name = $registration.Component.Name()
$existingRegistrationTable.Add($name, $registration)
if (!$existingRegistrationTable.ContainsKey($name)) {
$existingRegistrationTable.Add($name, $registration)
}
}
}

Expand Down Expand Up @@ -103,7 +105,7 @@ function ConvertTo-SemVer {
So, I'm making the logic work for that scenario by
thorwing away any part that doesn't match non-pre-release semver portion
#>
$null = $Version -match '^(\d+\.\d+\.\d+)).*'
$null = $Version -match '^(\d+\.\d+\.\d+).*'
$desiredVersion = $matches[1]
}

Expand Down

0 comments on commit adac4c7

Please sign in to comment.