@@ -16,16 +16,14 @@ internal static string GetLatestVersionFromPSGallery(string moduleName, ReleaseT
16
16
{
17
17
string version = null ;
18
18
string findModuleScript ;
19
+ string authScript = "" ;
19
20
20
21
if ( ! string . IsNullOrEmpty ( System . Environment . GetEnvironmentVariable ( "DEFAULT_PS_REPOSITORY_URL" ) ) )
21
22
{
22
23
string repository = System . Environment . GetEnvironmentVariable ( "DEFAULT_PS_REPOSITORY_NAME" ) ;
23
- findModuleScript = @"
24
- $AccessTokenSecureString = $env:SYSTEM_ACCESS_TOKEN | ConvertTo-SecureString -AsPlainText -Force;
25
- $credentialsObject = [pscredential]::new('ONEBRANCH_TOKEN', $AccessTokenSecureString);
26
- " ;
27
- findModuleScript += releaseType == ReleaseType . STS
28
- ? $ "Find-PSResource -Name { moduleName } -Repository { repository } -Version * -Credential $credentialsObject"
24
+ authScript += "$AccessTokenSecureString = $env:SYSTEM_ACCESS_TOKEN | ConvertTo-SecureString -AsPlainText -Force;$credentialsObject = [pscredential]::new('ONEBRANCH_TOKEN', $AccessTokenSecureString);" ;
25
+ findModuleScript = releaseType == ReleaseType . STS
26
+ ? $ "Find-PSResource -Name { moduleName } -Repository { repository } -Version * -Credential $credentialsObject"
29
27
: $ "Find-PSResource -Name Az -Repository { repository } -Version * -Credential $credentialsObject";
30
28
}
31
29
else
@@ -34,9 +32,9 @@ internal static string GetLatestVersionFromPSGallery(string moduleName, ReleaseT
34
32
findModuleScript = releaseType == ReleaseType . STS ? $ "Find-PSResource -Name { moduleName } -Repository { repository } -Version *" : $ "Find-PSResource -Name Az -Repository { repository } -Version *";
35
33
}
36
34
string filterRequiredReleaseTypeScript = releaseType == ReleaseType . STS ? "" : "| Where-Object {([System.Version]($_.Version)).Major % 2 -eq 0}" ;
37
- string sortModuleScript = "| Sort-Object {[System.Version]( $_.Version) } -Descending" ;
35
+ string sortModuleScript = "| Sort-Object {[System.Version]$_.Version} -Descending" ;
38
36
string getLastModuleVersionScript = releaseType == ReleaseType . STS ?
39
- $ "({ findModuleScript } { filterRequiredReleaseTypeScript } { sortModuleScript } )[0].Version" :
37
+ $ "{ authScript } ({ findModuleScript } { filterRequiredReleaseTypeScript } { sortModuleScript } )[0].Version" :
40
38
$ "(({ findModuleScript } { filterRequiredReleaseTypeScript } { sortModuleScript } )[0].Dependencies | Where-Object {{$_.Name -eq '{ moduleName } '}})[1]";
41
39
using ( PowerShell powershell = PowerShell . Create ( ) )
42
40
{
0 commit comments