Skip to content

Commit

Permalink
Register NuGet source when generating CGManifest (PowerShell#16570)
Browse files Browse the repository at this point in the history
* Register nuget source

* update cgmanifest
  • Loading branch information
TravisEz13 authored and TrapGodBrim committed Jan 19, 2022
1 parent 80fb62d commit f15c7d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/cgmanifest.json
Expand Up @@ -695,7 +695,7 @@
"Type": "nuget",
"Nuget": {
"Name": "StyleCop.Analyzers",
"Version": "1.2.0-beta.354"
"Version": "1.1.118"
}
},
"DevelopmentDependency": true
Expand Down
9 changes: 8 additions & 1 deletion tools/findMissingNotices.ps1
Expand Up @@ -13,6 +13,11 @@ Import-Module dotnet.project.assets
Import-Module "$PSScriptRoot\..\.github\workflows\GHWorkflowHelper" -Force
. "$PSScriptRoot\..\tools\buildCommon\startNativeExecution.ps1"

$packageSourceName = 'findMissingNoticesNugetOrg'
if (!(Get-PackageSource -Name $packageSourceName -ErrorAction SilentlyContinue)) {
$null = Register-PackageSource -Name $packageSourceName -Location https://www.nuget.org/api/v2 -ProviderName NuGet
}

$existingRegistrationTable = @{}
$cgManifestPath = (Resolve-Path -Path $PSScriptRoot\..\tools\cgmanifest.json).ProviderPath
$existingRegistrationsJson = Get-Content $cgManifestPath | ConvertFrom-Json -AsHashtable
Expand Down Expand Up @@ -109,7 +114,9 @@ function New-NugetComponent {
$nugetPublicVersionCache = [System.Collections.Generic.Dictionary[string, string]]::new()
function Get-NuGetPublicVersion {
param(
[parameter(Mandatory)]
[string]$Name,
[parameter(Mandatory)]
[string]$Version
)

Expand All @@ -124,7 +131,7 @@ function Get-NuGetPublicVersion {
}

$publicVersion = $null
$publicVersion = Find-Package -Name $Name -AllowPrereleaseVersions -source nuget.org -AllVersions -ErrorAction SilentlyContinue | ForEach-Object {
$publicVersion = Find-Package -Name $Name -AllowPrereleaseVersions -source $packageSourceName -AllVersions -ErrorAction SilentlyContinue | ForEach-Object {
try {
$packageVersion = [System.Management.Automation.SemanticVersion]$_.Version
} catch {
Expand Down

0 comments on commit f15c7d7

Please sign in to comment.