@@ -32,8 +32,6 @@ public sealed class DownloadUniversalPackages : Task
32
32
{
33
33
private const string PackageItemName = "UniversalPackage" ;
34
34
35
- private const string CredentialProviderRelativePath = @"plugins\netcore\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe" ;
36
-
37
35
private const string PatVarNameBase = "ArtifactToolPat_" ;
38
36
39
37
/// <summary>
@@ -567,18 +565,33 @@ private string GetArtifactToolReleaseInfoUrl(string osName, string arch)
567
565
568
566
private string ? GetArtifactsCredentialProviderPath ( )
569
567
{
570
- string credentialProviderDir ;
568
+ string exeName = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows )
569
+ ? "CredentialProvider.Microsoft.exe"
570
+ : "CredentialProvider.Microsoft" ;
571
571
if ( ! string . IsNullOrWhiteSpace ( ArtifactsCredentialProviderPath ) )
572
572
{
573
- // Allow the user to specify either the exe or the root dir
573
+ // Allow the user to specify either the exe, a dir with the exe, or the root dir
574
574
if ( File . Exists ( ArtifactsCredentialProviderPath ) )
575
575
{
576
576
return ArtifactsCredentialProviderPath ;
577
577
}
578
578
579
579
if ( Directory . Exists ( ArtifactsCredentialProviderPath ) )
580
580
{
581
- return GetArtifactsCredentialProviderExePath ( ArtifactsCredentialProviderPath ! ) ;
581
+ string possibleExePath = Path . Combine ( ArtifactsCredentialProviderPath , exeName ) ;
582
+ if ( File . Exists ( possibleExePath ) )
583
+ {
584
+ return possibleExePath ;
585
+ }
586
+
587
+ possibleExePath = GetArtifactsCredentialProviderExePath ( ArtifactsCredentialProviderPath ! ) ;
588
+ if ( File . Exists ( possibleExePath ) )
589
+ {
590
+ return possibleExePath ;
591
+ }
592
+
593
+ Log . LogError ( $ "Credential provider was not found under '{ ArtifactsCredentialProviderPath } '.") ;
594
+ return null ;
582
595
}
583
596
584
597
Log . LogError ( $ "Credential provider path '{ ArtifactsCredentialProviderPath } ' does not exist.") ;
@@ -592,7 +605,7 @@ private string GetArtifactToolReleaseInfoUrl(string osName, string arch)
592
605
return null ;
593
606
}
594
607
595
- credentialProviderDir = Path . Combine ( ArtifactToolBasePath , "credential-provider" , releaseInfo . Value . Version , "plugins" , "netcore" , "CredentialProvider.Microsoft" ) ;
608
+ string credentialProviderDir = Path . Combine ( ArtifactToolBasePath , "credential-provider" , releaseInfo . Value . Version ) ;
596
609
597
610
// Download only if needed
598
611
if ( ! Directory . Exists ( credentialProviderDir ) )
@@ -604,20 +617,17 @@ private string GetArtifactToolReleaseInfoUrl(string osName, string arch)
604
617
}
605
618
}
606
619
607
- return GetArtifactsCredentialProviderExePath ( credentialProviderDir ) ;
608
- }
609
-
610
- string ? GetArtifactsCredentialProviderExePath ( string dir )
611
- {
612
- string credentialProviderExePath = Path . Combine ( dir , CredentialProviderRelativePath ) ;
613
- if ( File . Exists ( credentialProviderExePath ) )
620
+ string exePath = GetArtifactsCredentialProviderExePath ( credentialProviderDir ) ;
621
+ if ( File . Exists ( exePath ) )
614
622
{
615
- return credentialProviderExePath ;
623
+ return exePath ;
616
624
}
617
625
618
- Log . LogError ( $ "Credential provider path '{ CredentialProviderRelativePath } ' was not found under ' { dir } ' .") ;
626
+ Log . LogError ( $ "Credential provider path '{ exePath } ' was not found.") ;
619
627
return null ;
620
628
}
629
+
630
+ string GetArtifactsCredentialProviderExePath ( string dir ) => Path . Combine ( dir , "plugins" , "netcore" , "CredentialProvider.Microsoft" , exeName ) ;
621
631
}
622
632
623
633
private ( string Version , string DownloadUri ) ? GetArtifactsCredentialProviderReleaseInfo ( )
0 commit comments