diff --git a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj index 6332aeb7bc356c..155ed36c8bb0ee 100644 --- a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj +++ b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj @@ -78,4 +78,34 @@ + + + + + + +internal static class BuildMetadata +{ + public const string ILLinkImplFramework = "$(NetCoreAppToolCurrent)"; +} +]]> + + + + + + + + + + + + + diff --git a/src/tools/illink/src/ILLink.Tasks/LinkTask.cs b/src/tools/illink/src/ILLink.Tasks/LinkTask.cs index ce24b35de9e485..b54b2c7510df1d 100644 --- a/src/tools/illink/src/ILLink.Tasks/LinkTask.cs +++ b/src/tools/illink/src/ILLink.Tasks/LinkTask.cs @@ -268,8 +268,15 @@ public string ILLinkPath { #pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file var taskDirectory = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location); #pragma warning restore IL3000 // Avoid accessing Assembly file path when publishing as a single file + // IL Linker always runs on .NET Core, even when using desktop MSBuild to host ILLink.Tasks. - _illinkPath = Path.Combine (Path.GetDirectoryName (taskDirectory), "net9.0", "illink.dll"); + // ILLinkImplFramework ()= NetCoreAppToolCurrent) was used to build the corresponding illink.dll + string path = Path.Combine (Path.GetDirectoryName (taskDirectory), BuildMetadata.ILLinkImplFramework, "illink.dll"); + + Log.LogMessage(MessageImportance.Normal, $"ILLink.Tasks path: {path}"); + + _illinkPath = path; + return _illinkPath; } set => _illinkPath = value;