Skip to content

Commit b8dc04b

Browse files
lewingradical
andauthored
Use properties for target versions for core and framework (#67717)
* Populate target framework versions for tasks, and generated nugets based .. on other properties, instead of hardcoding the values. * Version substitution for MonoTargets nuget * Version substitution for MonoAOTCompiler nuget * sendhelixhelp.proj: Ensure that DotNetCliVersion gets overridden, as .. intended. This seems to have been broken by the condition being removed in dotnet/arcade@cfdac35 from the `DotNetCliVersion` property, causing the value to always overridden again to `6.0.100`. And this breaks wasm aot/eat tests on helix: ``` /datadisks/disk1/work/A4EE08D9/p/build/wasm/WasmApp.Native.targets(569,5): error MSB4062: The "MonoAOTCompiler" task could not be loaded from the assembly /datadisks/disk1/work/A4EE08D9/p/build/MonoAOTCompiler/MonoAOTCompiler.dll. Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [/datadisks/disk1/work/A4EE08D9/w/B3AE0955/e/publish/ProxyProjectForAOTOnHelix.proj] /datadisks/disk1/work/A4EE08D9/p/build/wasm/WasmApp.Native.targets(569,5): error MSB4062: Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. ``` * Fix build for net7.0 Fails with: ``` src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcSocket.cs(27,35): error CS0108: 'IpcSocket.AcceptAsync(CancellationToken)' hides inherited member 'Socket.AcceptAsync(CancellationToken)'. Use the new keyword if hiding was intended. [/__w/1/s/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj] ``` * Fix some more target frameworks * bump the workload sdk version * Revert "sendhelixhelp.proj: Ensure that DotNetCliVersion gets overridden, as" This reverts commit 426b4b1. Last update to Arcade's XHarnessRunner.targets unconditionally set DotNetCliVersion, to workaround which this commit was added. But the update in this PR changed DotNetCliPackageType to `aspnetcore-runtime`, which makes the version from global.json - `6.0.100` incorrect for aspnetcore. And the next upcoming update will set versions explicitly and change the DotNetCliPackageType back to `sdk`. Instead, revert this. And don't use version from global.json for now, instead relying on the version that xharnesrunner.targets sets. Co-authored-by: Ankit Jain <[email protected]>
1 parent aff3c18 commit b8dc04b

File tree

13 files changed

+82
-30
lines changed

13 files changed

+82
-30
lines changed

Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
<NetFrameworkToolCurrent>net472</NetFrameworkToolCurrent>
6969
<!-- Don't build for NETFramework during source-build. -->
7070
<NetFrameworkToolCurrent Condition="'$(DotNetBuildFromSource)' == 'true'" />
71+
72+
<TargetFrameworkForNETFrameworkTasks>$(NetFrameworkToolCurrent)</TargetFrameworkForNETFrameworkTasks>
73+
<!-- Don't build for NETFramework during source-build. -->
74+
<TargetFrameworkForNETFrameworkTasks Condition="'$(DotNetBuildFromSource)' == 'true'" />
75+
76+
<TargetFrameworkForNETCoreTasks>$(NetCoreAppToolCurrent)</TargetFrameworkForNETCoreTasks>
7177
</PropertyGroup>
7278

7379
<PropertyGroup>

src/libraries/sendtohelix-wasm.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
<When Condition="'$(NeedsEMSDK)' == 'true'">
9898
<PropertyGroup>
9999
<NeedsDotNetSdk>true</NeedsDotNetSdk>
100-
<UseDotNetCliVersionFromGlobalJson>true</UseDotNetCliVersionFromGlobalJson>
100+
<!--<UseDotNetCliVersionFromGlobalJson>true</UseDotNetCliVersionFromGlobalJson>-->
101101
<IncludeXHarnessCli>true</IncludeXHarnessCli>
102102
<EnableXHarnessTelemetry>false</EnableXHarnessTelemetry>
103103
</PropertyGroup>

src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/Microsoft.NET.Runtime.MonoAOTCompiler.Task.pkgproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,28 @@
88
<ItemGroup>
99
<ProjectReference Include="$(RepoTasksDir)AotCompilerTask\MonoAOTCompiler.csproj" />
1010

11-
<PackageFile Include="Sdk\Sdk.props" TargetPath="Sdk" />
1211
<PackageFile Include="build\$(MSBuildProjectName).props" TargetPath="build" />
1312
</ItemGroup>
1413

14+
<Target Name="_PrepareForPack" BeforeTargets="GetPackageFiles">
15+
<PropertyGroup>
16+
<SdkPropsPath>$(IntermediateOutputPath)Sdk.props</SdkPropsPath>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<_ReplacementValue Include="TargetFrameworkForNETCoreTasks" Value="$(TargetFrameworkForNETCoreTasks)" />
21+
<_ReplacementValue Include="TargetFrameworkForNETFrameworkTasks" Value="$(TargetFrameworkForNETFrameworkTasks)" />
22+
</ItemGroup>
23+
24+
<GenerateFileFromTemplate
25+
TemplateFile="Sdk/Sdk.props.in"
26+
Properties="@(_ReplacementValue)"
27+
OutputPath="$(SdkPropsPath)" />
28+
29+
<ItemGroup>
30+
<PackageFile Include="$(SdkPropsPath)" TargetPath="Sdk" />
31+
</ItemGroup>
32+
</Target>
33+
1534
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
1635
</Project>

src/mono/nuget/Microsoft.NET.Runtime.MonoAOTCompiler.Task/Sdk/Sdk.props

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<PropertyGroup>
3+
<MonoAOTCompilerTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\${TargetFrameworkForNETCoreTasks}\MonoAOTCompiler.dll</MonoAOTCompilerTasksAssemblyPath>
4+
<MonoAOTCompilerTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\${TargetFrameworkForNETFrameworkTasks}\MonoAOTCompiler.dll</MonoAOTCompilerTasksAssemblyPath>
5+
</PropertyGroup>
6+
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
7+
</Project>

src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,28 @@
1313
<PackageFile Include="Sdk\Sdk.props" TargetPath="Sdk" />
1414
<PackageFile Include="Sdk\Sdk.targets" TargetPath="Sdk" />
1515
<PackageFile Include="build\$(MSBuildProjectName).props" TargetPath="build" />
16-
<PackageFile Include="Sdk\MonoTargetsTasks.props" TargetPath="Sdk" />
1716
<PackageFile Include="Sdk\RuntimeComponentManifest.targets" TargetPath="Sdk" />
1817
</ItemGroup>
1918

19+
<Target Name="_PrepareForPack" BeforeTargets="GetPackageFiles">
20+
<PropertyGroup>
21+
<MonoTargetsTasksPropsPath>$(IntermediateOutputPath)MonoTargetsTasks.props</MonoTargetsTasksPropsPath>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<_ReplacementValue Include="TargetFrameworkForNETCoreTasks" Value="$(TargetFrameworkForNETCoreTasks)" />
26+
<_ReplacementValue Include="TargetFrameworkForNETFrameworkTasks" Value="$(TargetFrameworkForNETFrameworkTasks)" />
27+
</ItemGroup>
28+
29+
<GenerateFileFromTemplate
30+
TemplateFile="Sdk/MonoTargetsTasks.props.in"
31+
Properties="@(_ReplacementValue)"
32+
OutputPath="$(MonoTargetsTasksPropsPath)" />
33+
34+
<ItemGroup>
35+
<PackageFile Include="$(MonoTargetsTasksPropsPath)" TargetPath="Sdk" />
36+
</ItemGroup>
37+
</Target>
38+
2039
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
2140
</Project>

src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/MonoTargetsTasks.props renamed to src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/MonoTargetsTasks.props.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<MonoTargetsTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\net6.0\MonoTargetsTasks.dll</MonoTargetsTasksAssemblyPath>
4-
<MonoTargetsTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\net472\MonoTargetsTasks.dll</MonoTargetsTasksAssemblyPath>
3+
<MonoTargetsTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\${TargetFrameworkForNETCoreTasks}\MonoTargetsTasks.dll</MonoTargetsTasksAssemblyPath>
4+
<MonoTargetsTasksAssemblyPath Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\${TargetFrameworkForNETFrameworkTasks}\MonoTargetsTasks.dll</MonoTargetsTasksAssemblyPath>
55
</PropertyGroup>
66
<!-- ILStrip -->
77
<UsingTask TaskName="ILStrip" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />

src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,32 @@
99
<ProjectReference Include="$(RepoTasksDir)WasmAppBuilder\WasmAppBuilder.csproj" />
1010
<ProjectReference Include="$(RepoTasksDir)WasmBuildTasks\WasmBuildTasks.csproj" />
1111

12-
<PackageFile Include="Sdk\Sdk.targets" TargetPath="Sdk" />
1312
<PackageFile Include="Sdk\AutoImport.props" TargetPath="Sdk" />
1413
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.props" TargetPath="Sdk" />
1514
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.targets" TargetPath="Sdk" />
1615
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.Native.*" TargetPath="Sdk" />
1716
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\EmSdkRepo.Defaults.props" TargetPath="Sdk" />
1817
</ItemGroup>
1918

19+
<Target Name="_PrepareForPack" BeforeTargets="GetPackageFiles">
20+
<PropertyGroup>
21+
<SdkTargetsPath>$(IntermediateOutputPath)Sdk.targets</SdkTargetsPath>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<_ReplacementValue Include="TargetFrameworkForNETCoreTasks" Value="$(TargetFrameworkForNETCoreTasks)" />
26+
<_ReplacementValue Include="TargetFrameworkForNETFrameworkTasks" Value="$(TargetFrameworkForNETFrameworkTasks)" />
27+
</ItemGroup>
28+
29+
<GenerateFileFromTemplate
30+
TemplateFile="Sdk/Sdk.targets.in"
31+
Properties="@(_ReplacementValue)"
32+
OutputPath="$(SdkTargetsPath)" />
33+
34+
<ItemGroup>
35+
<PackageFile Include="$(SdkTargetsPath)" TargetPath="Sdk" />
36+
</ItemGroup>
37+
</Target>
38+
2039
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
2140
</Project>

src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets renamed to src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.targets.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<!-- Property overrides -->
33
<PropertyGroup>
4-
<_TasksDir Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\net6.0\</_TasksDir>
5-
<_TasksDir Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\net472\</_TasksDir>
4+
<_TasksDir Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tasks\${TargetFrameworkForNETCoreTasks}\</_TasksDir>
5+
<_TasksDir Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tasks\${TargetFrameworkForNETFrameworkTasks}\</_TasksDir>
66

77
<WasmAppBuilderTasksAssemblyPath>$(_TasksDir)WasmAppBuilder.dll</WasmAppBuilderTasksAssemblyPath>
88
<WasmBuildTasksAssemblyPath>$(_TasksDir)WasmBuildTasks.dll</WasmBuildTasksAssemblyPath>

src/mono/wasm/build/WasmApp.InTree.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PropertyGroup>
66
<Platform>AnyCPU</Platform>
77
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
8-
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
8+
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
99
<EMSDK_PATH Condition="'$(EMSDK_PATH)' == '' and '$(MonoProjectRoot)' != ''">$([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasm', 'emsdk'))</EMSDK_PATH>
1010
<RunAOTCompilation Condition="'$(RunAOTCompilation)' == ''">false</RunAOTCompilation>
1111
<PublishTrimmed>true</PublishTrimmed>

src/mono/wasm/templates/Microsoft.NET.Runtime.WebAssembly.Templates.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Description>Templates to create WebAssembly projects.</Description>
99
<PackageTags>dotnet-new;templates</PackageTags>
1010

11-
<TargetFramework>net6.0</TargetFramework>
11+
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
1212

1313
<IncludeContentInPack>true</IncludeContentInPack>
1414
<IncludeBuildOutput>false</IncludeBuildOutput>

src/tasks/Directory.Build.props

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcSocket.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public IpcSocket(AddressFamily addressFamily, SocketType socketType, ProtocolTyp
2323
}
2424

2525
// .NET 6 implements this method directly on Socket, but for earlier runtimes we need a polyfill
26-
#if !NET6_0
26+
#if !NET6_0_OR_GREATER
2727
public async Task<Socket> AcceptAsync(CancellationToken token)
2828
{
2929
using (token.Register(() => Close(0)))
@@ -63,7 +63,7 @@ public virtual void Connect(EndPoint remoteEP, TimeSpan timeout)
6363
}
6464

6565
// .NET 6 implements this method directly on Socket, but for earlier runtimes we need a polyfill
66-
#if !NET6_0
66+
#if !NET6_0_OR_GREATER
6767
public async Task ConnectAsync(EndPoint remoteEP, CancellationToken token)
6868
{
6969
using (token.Register(() => Close(0)))

0 commit comments

Comments
 (0)