From c13739b6b1332b58165d4f11a4e3d688955b57e1 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 9 Aug 2023 17:32:37 -0700 Subject: [PATCH] Use current runtime version in ILLink.Tasks package (#90197) The ILLink.Tasks package should have a runtimeconfig.json that matches the runtime version bundled with the SDK that references it. This used to be done by stomping the runtime version in the dotnet/sdk build, but ILLink.Tasks is no longer bundled with the SDK so we need to do this ourselves. Tests that use live ILLink bits need to continue working with the SDK specified in global.json, so this preserves the existing illink.runtimeconfig.json in the build output, but defines an additional illink.runtimeconfig.pack.json file that uses the current runtime version. The pack.json file is included in the package (with the name illink.runtimeconfig.json) instead of the original. This includes a fix for 429a5c3a2ea096758c2b9b8907a8231d4e686a46: we weren't actually using live illink for tests due to an ordering issue introduced in response to feedback on that change. The Directory.Build.props is imported too early (before the nuget props that this is trying to override), so we need to import Microsoft.NET.ILLink.props directly from the project file. --------- Co-authored-by: Viktor Hofer --- eng/packaging.targets | 7 ++-- .../linker/SupportFiles/Directory.Build.props | 9 ------ eng/testing/linker/project.csproj.template | 14 +++++--- .../illink/src/ILLink.Tasks/ILLink.Tasks.csproj | 14 ++++++++ src/tools/illink/src/linker/Mono.Linker.csproj | 37 ++++++++++++++++++++++ 5 files changed, 65 insertions(+), 16 deletions(-) diff --git a/eng/packaging.targets b/eng/packaging.targets index ea2f143..a36102a 100644 --- a/eng/packaging.targets +++ b/eng/packaging.targets @@ -274,9 +274,10 @@ - + - - - - - $(ToolsILLinkDir)$(NetCoreAppToolCurrent)/ILLink.Tasks.dll - - true true diff --git a/eng/testing/linker/project.csproj.template b/eng/testing/linker/project.csproj.template index bec1429..3916d05 100644 --- a/eng/testing/linker/project.csproj.template +++ b/eng/testing/linker/project.csproj.template @@ -1,4 +1,4 @@ - + @@ -6,7 +6,15 @@ {ToolsILLinkDir} - + + + + + $(ToolsILLinkDir)$(NetCoreAppToolCurrent)/ILLink.Tasks.dll + {TargetFramework} @@ -84,6 +92,4 @@ - - diff --git a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj index 9cd6c88..1199101 100644 --- a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj +++ b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj @@ -26,6 +26,20 @@ false + + + + + + + + diff --git a/src/tools/illink/src/linker/Mono.Linker.csproj b/src/tools/illink/src/linker/Mono.Linker.csproj index 16e5cf9..e5cdbb8 100644 --- a/src/tools/illink/src/linker/Mono.Linker.csproj +++ b/src/tools/illink/src/linker/Mono.Linker.csproj @@ -24,6 +24,43 @@ $(DefineConstants);ILLINK + + + $([System.IO.Path]::ChangeExtension($(ProjectRuntimeConfigFilePath), pack.json)) + + + + + + + <_RuntimeConfigContents>$([System.IO.File]::ReadAllText('$(ProjectRuntimeConfigFilePath)')) + "version": ".*" + "version": "$(Version)" + <_NewRuntimeConfigContents>$([System.Text.RegularExpressions.Regex]::Replace($(_RuntimeConfigContents), $(ReplacementPattern), $(ReplacementString))) + + + + + + + + + + + + -- 2.7.4