Skip to content

Commit 7976f78

Browse files
authored
Avoid hardcoded illink.tasks TFM (#109634)
Replaces #109619 We made a similar change recently in arcade to not use the TFM but a normalized value of the TargetFrameworkIdentifier property for tools packages.
1 parent ee68c2c commit 7976f78

File tree

7 files changed

+28
-46
lines changed

7 files changed

+28
-46
lines changed

eng/liveILLink.targets

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
<PropertyGroup Condition="'$(_RequiresLiveILLink)' == 'true'">
2424
<!-- Don't use SDK's trimming functionality. -->
2525
<_RequiresILLinkPack>false</_RequiresILLinkPack>
26-
<!-- Keep in sync with SetTargetFramework metadata on the ProjectReference below. -->
27-
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(ToolsILLinkDir)$(NetCoreAppToolCurrent)\ILLink.Tasks.dll</ILLinkTasksAssembly>
28-
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(ToolsILLinkDir)$(NetFrameworkToolCurrent)\ILLink.Tasks.dll</ILLinkTasksAssembly>
26+
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(ToolsILLinkDir)net\ILLink.Tasks.dll</ILLinkTasksAssembly>
27+
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(ToolsILLinkDir)netframework\ILLink.Tasks.dll</ILLinkTasksAssembly>
2928
</PropertyGroup>
3029

3130
<ItemGroup Condition="'$(_RequiresLiveILLink)' == 'true'">

eng/packaging.targets

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

304304
<!-- Manual invoked target that can be used by toolset packages by adding it to the `TargetsForTfmSpecificContentInPackage` property. -->
305305
<Target Name="AddBuildOutputToToolsPackage">
306+
<PropertyGroup Condition="'$(BuildTaskTargetTfmSpecificFolder)' == ''">
307+
<BuildTaskTargetTfmSpecificFolder Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">net</BuildTaskTargetTfmSpecificFolder>
308+
<BuildTaskTargetTfmSpecificFolder Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">netframework</BuildTaskTargetTfmSpecificFolder>
309+
</PropertyGroup>
310+
311+
<Error Text="The 'BuildTaskTargetTfmSpecificFolder' property must be explicitly set when not targeting .NETCoreApp or .NETFramework"
312+
Condition="'$(BuildTaskTargetTfmSpecificFolder)' == ''" />
313+
306314
<ItemGroup>
307315
<!-- Include build outputs in the package under tools directory. -->
308316
<_BuildOutputPackageFile Include="$(OutputPath)**"
309317
Exclude="$(OutputPath)publish\**;
310318
$(OutputPath)" />
311319
<TfmSpecificPackageFile Include="@(_BuildOutputPackageFile)"
312-
PackagePath="tools/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)" />
320+
PackagePath="tools/$(BuildTaskTargetTfmSpecificFolder)/%(RecursiveDir)%(FileName)%(Extension)" />
313321
<TfmSpecificDebugSymbolsFile Include="@(TfmSpecificPackageFile->WithMetadataValue('Extension', '.pdb'))"
314322
TargetPath="/%(TfmSpecificPackageFile.PackagePath)/%(Filename)%(Extension)"
315323
TargetFramework="$(TargetFramework)"

eng/testing/linker/project.csproj.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
the same layout as the NuGet package. -->
1212
<!-- This must be done after the usual nuget props imports, to override the implicitly referenced
1313
Microsoft.NET.ILLink.Tasks.props from the SDK. -->
14-
<Import Project="$(ToolsILLinkDir)$(NetCoreAppToolCurrent)/build/Microsoft.NET.ILLink.Tasks.props" />
14+
<Import Project="$(ToolsILLinkDir)net/build/Microsoft.NET.ILLink.Tasks.props" />
1515

1616
<PropertyGroup>
1717
<!-- Don't use SDK's trimming functionality. -->
1818
<_RequiresILLinkPack>false</_RequiresILLinkPack>
19-
<ILLinkTasksAssembly>$(ToolsILLinkDir)$(NetCoreAppToolCurrent)/ILLink.Tasks.dll</ILLinkTasksAssembly>
19+
<ILLinkTasksAssembly>$(ToolsILLinkDir)net/ILLink.Tasks.dll</ILLinkTasksAssembly>
2020
</PropertyGroup>
2121

2222
<PropertyGroup>

src/mono/msbuild/apple/build/AppleBuild.LocalBuild.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
<_MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</_MonoAotCrossCompilerPath>
4545
<_MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(_MonoAotCrossCompilerPath).exe</_MonoAotCrossCompilerPath>
4646

47-
<ILLinkPropsPath>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(Configuration)', '$(_NetCoreAppToolCurrent)', 'build', 'Microsoft.NET.ILLink.Tasks.props'))</ILLinkPropsPath>
48-
<ILLinkTargetsPath>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(Configuration)', '$(_NetCoreAppToolCurrent)', 'build', 'Microsoft.NET.ILLink.targets'))</ILLinkTargetsPath>
49-
<_ILLinkTasksAssembly>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(Configuration)', '$(_NetCoreAppToolCurrent)', 'ILLink.Tasks.dll'))</_ILLinkTasksAssembly>
47+
<ILLinkPropsPath>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(Configuration)', 'net', 'build', 'Microsoft.NET.ILLink.Tasks.props'))</ILLinkPropsPath>
48+
<ILLinkTargetsPath>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(Configuration)', 'net', 'build', 'Microsoft.NET.ILLink.targets'))</ILLinkTargetsPath>
49+
<_ILLinkTasksAssembly>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'ILLink.Tasks', '$(Configuration)', 'net', 'ILLink.Tasks.dll'))</_ILLinkTasksAssembly>
5050
</PropertyGroup>
5151

5252
<PropertyGroup Condition="'$(RuntimeSrcDir)' == '' and '$(AppleBuildSupportDir)' != ''">
@@ -68,9 +68,9 @@
6868
<IlcSdkPath>$([MSBuild]::NormalizeDirectory('$(BuildBaseDir)', 'aotsdk'))</IlcSdkPath>
6969
<IlcFrameworkPath>$(MicrosoftNetCoreAppRuntimePackLibDir)</IlcFrameworkPath>
7070
<IlcFrameworkNativePath>$(MicrosoftNetCoreAppRuntimePackNativeDir)</IlcFrameworkNativePath>
71-
<ILLinkPropsPath>$([MSBuild]::NormalizePath('$(BuildBaseDir)', '$(_NetCoreAppToolCurrent)', 'build', ''Microsoft.NET.ILLink.Tasks.props''))</ILLinkPropsPath>
72-
<ILLinkTargetsPath>$([MSBuild]::NormalizePath('$(BuildBaseDir)', '$(_NetCoreAppToolCurrent)', 'build', 'Microsoft.NET.ILLink.targets'))</ILLinkTargetsPath>
73-
<_ILLinkTasksAssembly>$([MSBuild]::NormalizePath('$(BuildBaseDir)', '$(_NetCoreAppToolCurrent)', 'ILLink.Tasks.dll'))</_ILLinkTasksAssembly>
71+
<ILLinkPropsPath>$([MSBuild]::NormalizePath('$(BuildBaseDir)', 'net', 'build', ''Microsoft.NET.ILLink.Tasks.props''))</ILLinkPropsPath>
72+
<ILLinkTargetsPath>$([MSBuild]::NormalizePath('$(BuildBaseDir)', 'net', 'build', 'Microsoft.NET.ILLink.targets'))</ILLinkTargetsPath>
73+
<_ILLinkTasksAssembly>$([MSBuild]::NormalizePath('$(BuildBaseDir)', 'net', 'ILLink.Tasks.dll'))</_ILLinkTasksAssembly>
7474
<_MonoAotCrossCompilerPath>$([MSBuild]::NormalizePath($(MonoAotCrossDir), 'mono-aot-cross'))</_MonoAotCrossCompilerPath>
7575
<_MonoAotCrossCompilerPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(_MonoAotCrossCompilerPath).exe</_MonoAotCrossCompilerPath>
7676
</PropertyGroup>

src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddBuildOutputToToolsPackage</TargetsForTfmSpecificContentInPackage>
2121
<!-- TODO: Add package readme -->
2222
<EnableDefaultPackageReadmeFile>false</EnableDefaultPackageReadmeFile>
23+
<!-- Don't use the TFM but a short form of it without the version to simulate the package layout. -->
24+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
25+
<OutputPath Condition="'$(TargetFramework)' == '$(NetCoreAppToolCurrent)'">$(OutputPath)net\</OutputPath>
26+
<OutputPath Condition="'$(TargetFramework)' == '$(NetFrameworkToolCurrent)'">$(OutputPath)netframework\</OutputPath>
27+
<IntermediateOutputPath Condition="'$(TargetFramework)' == '$(NetCoreAppToolCurrent)'">$(IntermediateOutputPath)net\</IntermediateOutputPath>
28+
<IntermediateOutputPath Condition="'$(TargetFramework)' == '$(NetFrameworkToolCurrent)'">$(IntermediateOutputPath)netframework\</IntermediateOutputPath>
2329
</PropertyGroup>
2430

2531
<!-- Include the illink.runtimeconfig.pack.json file (which depends on the runtimeversion being built)
@@ -78,34 +84,4 @@
7884
</ProjectReference>
7985
</ItemGroup>
8086

81-
<Target Name="GenerateBuildMetadata" BeforeTargets="BeforeBuild"
82-
Inputs="$(MSBuildProjectFile)"
83-
Outputs="$(IntermediateOutputPath)Generated_BuildMetadata.cs">
84-
85-
<PropertyGroup>
86-
<BuildMetadataContents>
87-
<![CDATA[
88-
// <autogenerated />
89-
90-
internal static class BuildMetadata
91-
{
92-
public const string ILLinkImplFramework = "$(NetCoreAppToolCurrent)";
93-
}
94-
]]>
95-
</BuildMetadataContents>
96-
</PropertyGroup>
97-
98-
<WriteLinesToFile
99-
File="$(IntermediateOutputPath)Generated_BuildMetadata.cs"
100-
Lines="$([MSBuild]::Escape($(BuildMetadataContents)))"
101-
Overwrite="true" />
102-
103-
<ItemGroup>
104-
<Compile Include="$(IntermediateOutputPath)Generated_BuildMetadata.cs" />
105-
106-
<!-- Append to FileWrites so the file will be removed on clean -->
107-
<FileWrites Include="$(IntermediateOutputPath)Generated_BuildMetadata.cs" />
108-
</ItemGroup>
109-
</Target>
110-
11187
</Project>

src/tools/illink/src/ILLink.Tasks/LinkTask.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ public string ILLinkPath {
270270
#pragma warning restore IL3000 // Avoid accessing Assembly file path when publishing as a single file
271271

272272
// IL Linker always runs on .NET Core, even when using desktop MSBuild to host ILLink.Tasks.
273-
// ILLinkImplFramework ()= NetCoreAppToolCurrent) was used to build the corresponding illink.dll
274-
string path = Path.Combine (Path.GetDirectoryName (taskDirectory), BuildMetadata.ILLinkImplFramework, "illink.dll");
273+
string path = Path.Combine (Path.GetDirectoryName (taskDirectory), "net", "illink.dll");
275274

276275
Log.LogMessage(MessageImportance.Normal, $"ILLink.Tasks path: {path}");
277276

src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.Tasks.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Copyright (c) .NET Foundation. All rights reserved.
1818
<!-- Older SDKs used this property as a sentinel instead, to control the import of this file
1919
(but not the targets, which were included with the SDK). -->
2020
<UsingILLinkTasksSdk>true</UsingILLinkTasksSdk>
21-
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tools\net9.0\ILLink.Tasks.dll</ILLinkTasksAssembly>
22-
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tools\net472\ILLink.Tasks.dll</ILLinkTasksAssembly>
21+
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tools\net\ILLink.Tasks.dll</ILLinkTasksAssembly>
22+
<ILLinkTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tools\netframework\ILLink.Tasks.dll</ILLinkTasksAssembly>
2323

2424
<ILLinkAnalyzersPropsPath Condition="'$(ILLinkAnalyzersPropsPath)' == ''">$(MSBuildThisFileDirectory)Microsoft.NET.ILLink.Analyzers.props</ILLinkAnalyzersPropsPath>
2525
</PropertyGroup>

0 commit comments

Comments
 (0)