@@ -11,22 +11,41 @@ parameters:
1111 # Unfortunately, _SignType can't be used to exclude the use of the service connection in non-real sign scenarios. The
1212 # variable is not available in template expression. _SignType has a very large proliferation across .NET, so replacing it is tough.
1313 microbuildUseESRP : true
14+ # Microbuild installation directory
15+ microBuildOutputFolder : $(Agent.TempDirectory)/MicroBuild
1416
1517 continueOnError : false
1618
1719steps :
1820 - ${{ if eq(parameters.enableMicrobuild, 'true') }} :
1921 - ${{ if eq(parameters.enableMicrobuildForMacAndLinux, 'true') }} :
20- # Installing .NET 8 is required to use the MicroBuild signing plugin on non-Windows platforms
22+ # Needed to download the MicroBuild plugin nupkgs on Mac and Linux when nuget.exe is unavailable
2123 - task : UseDotNet@2
2224 displayName : Install .NET 8.0 SDK for MicroBuild Plugin
2325 inputs :
2426 packageType : sdk
2527 version : 8.0.x
26- # Installing the SDK in a '.dotnet-microbuild' directory is required for signing.
27- # See target FindDotNetPathForMicroBuild in arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj
28- # Do not remove '.dotnet-microbuild' from the path without changing the corresponding logic.
29- installationPath : $(Agent.TempDirectory)/.dotnet-microbuild
28+ installationPath : ${{ parameters.microBuildOutputFolder }}/.dotnet-microbuild
29+ condition : and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'))
30+
31+ - script : |
32+ set -euo pipefail
33+
34+ # UseDotNet@2 prepends the dotnet executable path to the PATH variable, so we can call dotnet directly
35+ version=$(dotnet --version)
36+ cat << 'EOF' > ${{ parameters.microBuildOutputFolder }}/global.json
37+ {
38+ "sdk": {
39+ "version": "$version",
40+ "paths": [
41+ "${{ parameters.microBuildOutputFolder }}/.dotnet-microbuild"
42+ ],
43+ "errorMessage": "The .NET SDK version $version is required to install the MicroBuild signing plugin."
44+ }
45+ }
46+ EOF
47+ displayName: 'Add global.json to MicroBuild Installation path'
48+ workingDirectory: ${{ parameters.microBuildOutputFolder }}
3049 condition: and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'))
3150
3251 - script : |
6483 ConnectedPMEServiceName : 248d384a-b39b-46e3-8ad5-c2c210d5e7ca
6584 env :
6685 TeamName : $(_TeamName)
67- MicroBuildOutputFolderOverride : $(Agent.TempDirectory)/MicroBuild
86+ MicroBuildOutputFolderOverride : ${{ parameters.microBuildOutputFolder }}
6887 SYSTEM_ACCESSTOKEN : $(System.AccessToken)
6988 continueOnError : ${{ parameters.continueOnError }}
7089 condition : and(succeeded(), eq(variables['Agent.Os'], 'Windows_NT'), in(variables['_SignType'], 'real', 'test'))
7695 signType : $(_SignType)
7796 zipSources : false
7897 feedSource : https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
98+ workingDirectory : ${{ parameters.microBuildOutputFolder }}
7999 ${{ if eq(parameters.microbuildUseESRP, true) }} :
80100 ConnectedServiceName : ' MicroBuild Signing Task (DevDiv)'
81101 ${{ if eq(variables['System.TeamProject'], 'DevDiv') }} :
@@ -84,7 +104,7 @@ steps:
84104 ConnectedPMEServiceName : c24de2a5-cc7a-493d-95e4-8e5ff5cad2bc
85105 env :
86106 TeamName : $(_TeamName)
87- MicroBuildOutputFolderOverride : $(Agent.TempDirectory)/MicroBuild
107+ MicroBuildOutputFolderOverride : ${{ parameters.microBuildOutputFolder }}
88108 SYSTEM_ACCESSTOKEN : $(System.AccessToken)
89109 continueOnError : ${{ parameters.continueOnError }}
90110 condition : and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'), eq(variables['_SignType'], 'real'))
0 commit comments