diff --git a/UnitySetup/UnitySetup.psm1 b/UnitySetup/UnitySetup.psm1 index e6348bf..7a5cdca 100644 --- a/UnitySetup/UnitySetup.psm1 +++ b/UnitySetup/UnitySetup.psm1 @@ -2713,9 +2713,23 @@ function Update-UnityPackageManagerConfig { [int]$SearchDepth = 3, [Switch]$VerifyOnly, [int]$PATLifetime = 7, - [guid]$AzureSubscription + [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 = "(?(?https:\/\/pkgs.dev.azure.com\/(?[a-zA-Z0-9]*))\/?(?[a-zA-Z0-9]*)?\/_packaging\/(?[a-zA-Z0-9\-_\.%\(\)!]*)?\/npm\/registry\/?)" $upmRegEx = "\[npmAuth\.""(?(?https:\/\/pkgs.dev.azure.com\/(?[a-zA-Z0-9]*))\/?(?[a-zA-Z0-9]*)?\/_packaging\/(?[a-zA-Z0-9\-_\.%\(\)!]*)?\/npm\/registry\/?)""\][\n\r\s]*_auth ?= ?""(?[a-zA-Z0-9=]*)""[\n\r\s]*(?:alwaysAuth[\n\r\s]*=[\n\r\s]*true)[\n\r\s]*" $azAPIVersion = '7.1-preview.1' @@ -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 @@ -2752,4 +2766,4 @@ function Update-UnityPackageManagerConfig { Write-Verbose "Verify Mode complete" exit 0 } -} +} \ No newline at end of file