Skip to content
Closed
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
20 changes: 17 additions & 3 deletions UnitySetup/UnitySetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2713,9 +2713,23 @@ function Update-UnityPackageManagerConfig {
[int]$SearchDepth = 3,
[Switch]$VerifyOnly,
[int]$PATLifetime = 7,
[guid]$AzureSubscription

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting - I tried this specifically before suggesting you convert to [guid]. Let me try some things.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed - the issue is that you're assuming that $AzureSubscription is valid and then passing it into Update-PackageAuthConfig which ends up throwing the error. I have fixes for that an others about to go up.

[String]$AzureSubscription # Define as String
)

$AzureSubscriptionGuid = $null

if (-not [string]::IsNullOrEmpty($AzureSubscription)) {
try {
$AzureSubscriptionGuid = [guid]::Parse($AzureSubscription)
} catch {
Write-Error "AzureSubscription parameter must be a valid GUID."
return
}
}
else {
$AzureSubscriptionGuid = [guid]::Empty
}

$scopedURLRegEx = "(?<FullURL>(?<OrgURL>https:\/\/pkgs.dev.azure.com\/(?<Org>[a-zA-Z0-9]*))\/?(?<Project>[a-zA-Z0-9]*)?\/_packaging\/(?<Feed>[a-zA-Z0-9\-_\.%\(\)!]*)?\/npm\/registry\/?)"
$upmRegEx = "\[npmAuth\.""(?<FullURL>(?<OrgURL>https:\/\/pkgs.dev.azure.com\/(?<Org>[a-zA-Z0-9]*))\/?(?<Project>[a-zA-Z0-9]*)?\/_packaging\/(?<Feed>[a-zA-Z0-9\-_\.%\(\)!]*)?\/npm\/registry\/?)""\][\n\r\s]*_auth ?= ?""(?<Token>[a-zA-Z0-9=]*)""[\n\r\s]*(?:alwaysAuth[\n\r\s]*=[\n\r\s]*true)[\n\r\s]*"
$azAPIVersion = '7.1-preview.1'
Expand All @@ -2738,7 +2752,7 @@ function Update-UnityPackageManagerConfig {
$tomlFileObjects = Import-TOMLFile -tomlFilePaths $tomlFilePaths -Force

if ($PSCmdlet.ShouldProcess("Synchronizing UPM configuration")) {
$upmConfigs = Update-PackageAuthConfig -ScopedRegistryURLs $scopedRegistryURLs -TomlfileObjects $tomlFileObjects -AutoClean:$AutoClean.IsPresent -VerifyOnly:$VerifyOnly.IsPresent -ManualPAT:$ManualPAT.IsPresent -PATLifetime $PATLifetime -DefaultScope $defaultScope -AzAPIVersion $azAPIVersion -ScopedURLRegEx $scopedURLRegEx -UPMRegEx $upmRegEx -AzureSubscription $AzureSubscription
$upmConfigs = Update-PackageAuthConfig -ScopedRegistryURLs $scopedRegistryURLs -TomlfileObjects $tomlFileObjects -AutoClean:$AutoClean.IsPresent -VerifyOnly:$VerifyOnly.IsPresent -ManualPAT:$ManualPAT.IsPresent -PATLifetime $PATLifetime -DefaultScope $defaultScope -AzAPIVersion $azAPIVersion -ScopedURLRegEx $scopedURLRegEx -UPMRegEx $upmRegEx -AzureSubscription $AzureSubscriptionGuid

if ($PSCmdlet.ShouldProcess("Exporting UPM configuration")) {
Export-UPMConfig -UPMConfig $upmConfigs -tomlFilePaths $tomlFilePaths
Expand All @@ -2752,4 +2766,4 @@ function Update-UnityPackageManagerConfig {
Write-Verbose "Verify Mode complete"
exit 0
}
}
}