@@ -13,9 +13,8 @@ parameters:
1313 # Unfortunately, _SignType can't be used to exclude the use of the service connection in non-real sign scenarios. The
1414 # variable is not available in template expression. _SignType has a very large proliferation across .NET, so replacing it is tough.
1515 microbuildUseESRP : true
16- # Location of the MicroBuild output folder
17- # NOTE: There's something that relies on this being in the "default" source directory for tasks such as Signing to work properly.
18- microBuildOutputFolder : ' $(Build.SourcesDirectory)'
16+ # Microbuild installation directory
17+ microBuildOutputFolder : $(Agent.TempDirectory)/MicroBuild
1918 # Microbuild version
2019 microbuildPluginVersion : ' latest'
2120
@@ -30,8 +29,27 @@ steps:
3029 inputs :
3130 packageType : sdk
3231 version : 8.0.x
33- installationPath : ${{ parameters.microBuildOutputFolder }}/.dotnet
34- workingDirectory : ${{ parameters.microBuildOutputFolder }}
32+ installationPath : ${{ parameters.microBuildOutputFolder }}/.dotnet-microbuild
33+ condition : and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'))
34+
35+ - script : |
36+ set -euo pipefail
37+
38+ # UseDotNet@2 prepends the dotnet executable path to the PATH variable, so we can call dotnet directly
39+ version=$(dotnet --version)
40+ cat << 'EOF' > ${{ parameters.microBuildOutputFolder }}/global.json
41+ {
42+ "sdk": {
43+ "version": "$version",
44+ "paths": [
45+ "${{ parameters.microBuildOutputFolder }}/.dotnet-microbuild"
46+ ],
47+ "errorMessage": "The .NET SDK version $version is required to install the MicroBuild signing plugin."
48+ }
49+ }
50+ EOF
51+ displayName: 'Add global.json to MicroBuild Installation path'
52+ workingDirectory: ${{ parameters.microBuildOutputFolder }}
3553 condition: and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'))
3654
3755 - script : |
@@ -85,6 +103,7 @@ steps:
85103 zipSources : false
86104 feedSource : https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
87105 version : ${{ parameters.microbuildPluginVersion }}
106+ workingDirectory : ${{ parameters.microBuildOutputFolder }}
88107 ${{ if eq(parameters.microbuildUseESRP, true) }} :
89108 ConnectedServiceName : ' MicroBuild Signing Task (DevDiv)'
90109 ${{ if eq(variables['System.TeamProject'], 'DevDiv') }} :
0 commit comments