Skip to content

Commit ccec848

Browse files
authored
Create Sdk.props in AOT compilers with a template (#53685)
* Create Sdk.props in AOT compilers with a template Fixes #53653 Example: ``` sudo cat Sdk/Sdk.props <Project> <ItemGroup> <MonoAotCrossCompilerPath Include="$(MSBuildThisFileDirectory)..\tools\mono-aot-cross" RuntimeIdentifier="iossimulator-arm64" /> </ItemGroup> </Project> ```
1 parent 1ec8a0a commit ccec848

13 files changed

+59
-27
lines changed

eng/testing/tests.mobile.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<RemoveDir Directories="$(BundleDir)" />
9595

9696
<MonoAOTCompiler Condition="'$(RunAOTCompilation)' == 'true'"
97-
CompilerBinaryPath="$(MonoAotCrossCompilerPath)"
97+
CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())'))"
9898
OutputDir="$(_MobileIntermediateOutputPath)"
9999
Mode="Full"
100100
OutputType="AsmOnly"
@@ -178,7 +178,7 @@
178178
<RemoveDir Directories="$(BundleDir)" />
179179

180180
<MonoAOTCompiler Condition="'$(RunAOTCompilation)' == 'true'"
181-
CompilerBinaryPath="$(MonoAotCrossCompilerPath)"
181+
CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())'))"
182182
OutputDir="$(_MobileIntermediateOutputPath)"
183183
Mode="$(AOTMode)"
184184
OutputType="AsmOnly"

eng/testing/tests.targets

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222

2323
<!-- For both tests.mobile.targets and tests.wasm.targets -->
2424
<PropertyGroup>
25-
<MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</MonoAotCrossCompilerPath>
26-
<MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(MonoAotCrossCompilerPath).exe</MonoAotCrossCompilerPath>
25+
<_MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</_MonoAotCrossCompilerPath>
26+
<_MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(_MonoAotCrossCompilerPath).exe</_MonoAotCrossCompilerPath>
2727
</PropertyGroup>
28+
<ItemGroup>
29+
<MonoAotCrossCompiler Include="$(_MonoAotCrossCompilerPath)" RuntimeIdentifier="$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())" />
30+
</ItemGroup>
2831

2932
<PropertyGroup>
3033
<ArchiveTestsAfterTargets>PrepareForRun</ArchiveTestsAfterTargets>

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,8 @@
257257
<PropertyGroup Condition="'$(TargetArchitecture)' == 'arm64' AND '$(BuildArchitecture)' != 'arm64'">
258258
<_hostArch>amd64</_hostArch>
259259
</PropertyGroup>
260+
261+
<PropertyGroup>
262+
<WorkloadTasksAssemblyPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WorkloadBuildTasks', 'Debug', '$(NetCoreAppToolCurrent)'))WorkloadBuildTasks.dll</WorkloadTasksAssemblyPath>
263+
</PropertyGroup>
260264
</Project>

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Archives" Version="$(MicrosoftDotNetBuildTasksArchivesVersion)" />
1414
</ItemGroup>
1515

16+
<UsingTask TaskName="GenerateFileFromTemplate" AssemblyFile="$(WorkloadTasksAssemblyPath)" />
17+
1618
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
1719
</Project>

src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.MonoCrossAOT.Sdk.props

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<ItemGroup>
3+
<MonoAotCrossCompiler Include="$(MSBuildThisFileDirectory)..\tools\mono-aot-cross${ExeSuffix}" RuntimeIdentifier="${TargetRid}" />
4+
</ItemGroup>
5+
</Project>
6+

src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.MonoCrossAOT.sfxproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@
1919

2020
<ItemGroup>
2121
<NativeRuntimeAsset Include="$(MonoAotCrossDir)$(TargetCrossRid)\**" TargetPath="tools/" />
22-
<NativeRuntimeAsset Include="$(MSBuildThisFileDirectory)Microsoft.NETCore.App.MonoCrossAOT.Sdk.props" TargetPath="Sdk/Sdk.props" />
22+
<NativeRuntimeAsset Include="$(MonoAotCrossDir)$(TargetCrossRid).Sdk.props" TargetPath="Sdk/Sdk.props" />
2323
</ItemGroup>
2424

25+
<Target Name="WriteAotSdkProps" BeforeTargets="ValidateProperties">
26+
<ItemGroup>
27+
<_SdkPropsProperties Condition="!$([MSBuild]::IsOsPlatform('Windows'))" Include="ExeSuffix" Value="" />
28+
<_SdkPropsProperties Condition="$([MSBuild]::IsOsPlatform('Windows'))" Include="ExeSuffix" Value=".exe" />
29+
<_SdkPropsProperties Include="TargetRid" Value="$(TargetCrossRid)" />
30+
</ItemGroup>
31+
<GenerateFileFromTemplate
32+
TemplateFile="Microsoft.NETCore.App.MonoCrossAOT.Sdk.props.in"
33+
Properties="@(_SdkPropsProperties)"
34+
OutputPath="$(MonoAotCrossDir)$(TargetCrossRid).Sdk.props" />
35+
</Target>
36+
2537
<Target Name="ValidateProperties" BeforeTargets="GenerateNuspec">
2638
<Error Condition="'$(TargetCrossRid)' == ''" Text="TargetCrossRid not set" />
2739
<Error Condition="!Exists('$(MonoAotCrossDir)$(TargetCrossRid)\$(AotCompilerFileName)')" Text="Cross compiler not found in $(MonoAotCrossDir)$(TargetCrossRid)" />

src/libraries/sendtohelixhelp.proj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,12 @@
296296
</PropertyGroup>
297297

298298
<PropertyGroup Condition="'$(RuntimeFlavor)' == 'Mono'">
299-
<MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</MonoAotCrossCompilerPath>
300-
<MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(MonoAotCrossCompilerPath).exe</MonoAotCrossCompilerPath>
299+
<_MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</_MonoAotCrossCompilerPath>
300+
<_MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(_MonoAotCrossCompilerPath).exe</_MonoAotCrossCompilerPath>
301301
</PropertyGroup>
302+
<ItemGroup Condition="'$(RuntimeFlavor)' == 'Mono'">
303+
<MonoAotCrossCompiler Include="$(_MonoAotCrossCompilerPath)" RuntimeIdentifier="$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())" />
304+
</ItemGroup>
302305

303306
<Message Condition="'$(TargetOS)' == 'Browser'" Importance="High" Text="Using emsdk: $(EmSdkDir)" />
304307

src/mono/Directory.Build.props

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@
6161

6262
<PropertyGroup>
6363
<MonoAotCrossDir>$([MSBuild]::NormalizePath($(RuntimeBinDir), 'cross', '$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())'))</MonoAotCrossDir>
64-
<MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</MonoAotCrossCompilerPath>
65-
<MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(MonoAotCrossCompilerPath).exe</MonoAotCrossCompilerPath>
64+
<_MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</_MonoAotCrossCompilerPath>
65+
<_MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(_MonoAotCrossCompilerPath).exe</_MonoAotCrossCompilerPath>
6666
</PropertyGroup>
67+
<ItemGroup>
68+
<MonoAotCrossCompiler Include="$(_MonoAotCrossCompilerPath)" RuntimeIdentifier="$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())" />
69+
</ItemGroup>
6770

6871
<!-- Paths for Mobile App Projects -->
6972
<PropertyGroup>

src/mono/sample/Android/AndroidSampleApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Message Importance="High" Text="SourceDir: $(OutputPath)" />
6060

6161
<MonoAOTCompiler Condition="'$(ForceAOT)' == 'true'"
62-
CompilerBinaryPath="$(MonoAotCrossCompilerPath)"
62+
CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())'))"
6363
OutputDir="$(_MobileIntermediateOutputPath)"
6464
Mode="Full"
6565
OutputType="AsmOnly"

0 commit comments

Comments
 (0)