Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions tools/findMissingNotices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -203,28 +203,34 @@ function Get-CGRegistrations {
"alpine-.*" {
$folder = $unixProjectName
$target = "$dotnetTargetName|$Runtime"
$neutralTarget = "$dotnetTargetName"
}
"linux-.*" {
$folder = $unixProjectName
$target = "$dotnetTargetName|$Runtime"
$neutralTarget = "$dotnetTargetName"
}
"osx-.*" {
$folder = $unixProjectName
$target = "$dotnetTargetName|$Runtime"
$neutralTarget = "$dotnetTargetName"
}
"win-x*" {
$sdkToUse = $winDesktopSdk
$folder = $windowsProjectName
$target = "$dotnetTargetNameWin7|$Runtime"
$neutralTarget = "$dotnetTargetNameWin7"
}
"win-.*" {
$folder = $windowsProjectName
$target = "$dotnetTargetNameWin7|$Runtime"
$neutralTarget = "$dotnetTargetNameWin7"
}
"modules" {
$folder = "modules"
$actualRuntime = 'linux-x64'
$target = "$dotnetTargetName|$actualRuntime"
$neutralTarget = "$dotnetTargetName"
}
Default {
throw "Invalid runtime name: $Runtime"
Expand All @@ -241,6 +247,7 @@ function Get-CGRegistrations {
$null = New-PADrive -Path $PSScriptRoot\..\src\$folder\obj\project.assets.json -Name $folder
try {
$targets = Get-ChildItem -Path "${folder}:/targets/$target" -ErrorAction Stop | Where-Object { $_.Type -eq 'package' } | select-object -ExpandProperty name
$targets += Get-ChildItem -Path "${folder}:/targets/$neutralTarget" -ErrorAction Stop | Where-Object { $_.Type -eq 'project' } | select-object -ExpandProperty name
} catch {
Get-ChildItem -Path "${folder}:/targets" | Out-String | Write-Verbose -Verbose
throw
Expand All @@ -250,27 +257,51 @@ function Get-CGRegistrations {
Get-PSDrive -Name $folder -ErrorAction Ignore | Remove-PSDrive
}

# Name to skip for TPN generation
$skipNames = @(
"Microsoft.PowerShell.Native"
"Microsoft.Management.Infrastructure.Runtime.Unix"
"Microsoft.Management.Infrastructure"
"Microsoft.PowerShell.Commands.Diagnostics"
"Microsoft.PowerShell.Commands.Management"
"Microsoft.PowerShell.Commands.Utility"
"Microsoft.PowerShell.ConsoleHost"
"Microsoft.PowerShell.SDK"
"Microsoft.PowerShell.Security"
"Microsoft.Management.Infrastructure.CimCmdlets"
"Microsoft.WSMan.Management"
"Microsoft.WSMan.Runtime"
"System.Management.Automation"
)

Write-Verbose "Found $($targets.Count) targets to process..." -Verbose
$targets | ForEach-Object {
$target = $_
$parts = ($target -split '\|')
$name = $parts[0]
$targetVersion = $parts[1]
$publicVersion = Get-NuGetPublicVersion -Name $name -Version $targetVersion

# Add the registration to the cgmanifest if the TPN does not contain the name of the target OR
# the exisitng CG contains the registration, because if the existing CG contains the registration,
# that might be the only reason it is in the TPN.
if (!$RegistrationTable.ContainsKey($target)) {
$DevelopmentDependency = $false
if (!$existingRegistrationTable.ContainsKey($name) -or $existingRegistrationTable.$name.Component.Version() -ne $publicVersion) {
$registrationChanged = $true
}
if ($existingRegistrationTable.ContainsKey($name) -and $existingRegistrationTable.$name.DevelopmentDependency) {
$DevelopmentDependency = $true
}

$registration = New-NugetComponent -Name $name -Version $publicVersion -DevelopmentDependency:$DevelopmentDependency
$RegistrationTable.Add($target, $registration)
if ($name -in $skipNames) {
Write-Verbose "Skipping $name..."

} else {
$targetVersion = $parts[1]
$publicVersion = Get-NuGetPublicVersion -Name $name -Version $targetVersion

# Add the registration to the cgmanifest if the TPN does not contain the name of the target OR
# the exisitng CG contains the registration, because if the existing CG contains the registration,
# that might be the only reason it is in the TPN.
if (!$RegistrationTable.ContainsKey($target)) {
$DevelopmentDependency = $false
if (!$existingRegistrationTable.ContainsKey($name) -or $existingRegistrationTable.$name.Component.Version() -ne $publicVersion) {
$registrationChanged = $true
}
if ($existingRegistrationTable.ContainsKey($name) -and $existingRegistrationTable.$name.DevelopmentDependency) {
$DevelopmentDependency = $true
}

$registration = New-NugetComponent -Name $name -Version $publicVersion -DevelopmentDependency:$DevelopmentDependency
$RegistrationTable.Add($target, $registration)
}
}
}

Expand Down