Skip to content

Commit d699b23

Browse files
authored
use the sdk.paths mechanism from .NET 10p3 (#49627)
1 parent 6a9fe05 commit d699b23

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

eng/pipelines/templates/jobs/sdk-build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ jobs:
104104
env:
105105
BuildConfig: $(buildConfiguration)
106106
TestFullMSBuild: ${{ parameters.testFullMSBuild }}
107-
107+
108108
- powershell: build/RunTestTemplateTests.ps1
109109
displayName: 🟣 Run Test Templates Tests
110-
110+
111111
- ${{ else }}:
112112
- script: |
113113
source $(Build.SourcesDirectory)/eng/common/native/init-os-and-arch.sh
@@ -137,6 +137,7 @@ jobs:
137137
- ${{ if eq(parameters.runAoTTests, true) }}:
138138
# For the reason this is here, see: https://github.com/dotnet/sdk/issues/22655
139139
- script: $(Build.SourcesDirectory)/artifacts/bin/redist/$(buildConfiguration)/dotnet/dotnet workload install wasm-tools --skip-manifest-update
140+
workingDirectory: $(Build.SourcesDirectory)/artifacts
140141
displayName: 🟣 Install wasm-tools Workload
141142
# For the /p:Projects syntax for PowerShell, see: https://github.com/dotnet/msbuild/issues/471#issuecomment-1146466335
142143
- ${{ if eq(parameters.pool.os, 'windows') }}:

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
2+
"sdk": {
3+
"paths": [
4+
".dotnet",
5+
"$host$"
6+
],
7+
"errorMessage": "The .NET SDK is not installed or is not configured correctly. Please run ./build to install the correct SDK version locally."
8+
},
29
"tools": {
310
"dotnet": "10.0.100-preview.6.25315.102",
411
"runtimes": {

src/Layout/redist/redist.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,4 @@
117117
</Target>
118118

119119
<Target Name="ReturnProductVersion" Returns="$(FullNugetVersion)" />
120-
121120
</Project>

src/Layout/redist/targets/Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<Import Project="GenerateArchives.targets" />
2222

2323
<Import Project="OverlaySdkOnLKG.targets" />
24+
<Import Project="GenerateTestingGlobalJson.targets" />
2425
</ImportGroup>
2526

2627
<!-- Installers -->
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- We put this in the root of the artifacts dir so that any usage (not just from ./tmp, but also from ./bin) gets redirected. -->
4+
<_TestingGlobalJsonPath>$(ArtifactsDir)global.json</_TestingGlobalJsonPath>
5+
</PropertyGroup>
6+
7+
<!-- Since the dotnet binary respects sdk.paths in global.json now, and we use this in the repo root to make sure that we consistently use the repo-local
8+
SDK for building/etc, we need to put something in place so that tests don't use the repo-local SDK and instead use the redist SDK. -->
9+
<Target Name="CreateRedistGlobalJsonForTesting"
10+
BeforeTargets="AfterBuild"
11+
Outputs="$(_TestingGlobalJsonPath)">
12+
<PropertyGroup>
13+
<_TestingRedistDotnetPath>$(TestHostDotNetRoot.Replace('\', '\\'))</_TestingRedistDotnetPath>
14+
</PropertyGroup>
15+
<ItemGroup>
16+
<_RedistGlobalJsonLines Include="{" />
17+
<_RedistGlobalJsonLines Include=" &quot;sdk&quot;: {" />
18+
<_RedistGlobalJsonLines Include=" &quot;paths&quot;: [" />
19+
<_RedistGlobalJsonLines Include=" &quot;$(_TestingRedistDotnetPath)&quot;" />
20+
<_RedistGlobalJsonLines Include=" ]" />
21+
<_RedistGlobalJsonLines Include=" }" />
22+
<_RedistGlobalJsonLines Include="}" />
23+
</ItemGroup>
24+
<WriteLinesToFile File="$(_TestingGlobalJsonPath)"
25+
Lines="@(_RedistGlobalJsonLines)"
26+
Overwrite="true"
27+
Encoding="utf-8"
28+
WriteOnlyWhenDifferent="true" />
29+
<ItemGroup>
30+
<FileWrites Include="$(_TestingGlobalJsonPath)" />
31+
</ItemGroup>
32+
</Target>
33+
</Project>

0 commit comments

Comments
 (0)