Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,34 @@
</ProjectReference>
</ItemGroup>

<Target Name="GenerateBuildMetadata" BeforeTargets="BeforeBuild"
Inputs="$(MSBuildProjectFile)"
Outputs="$(IntermediateOutputPath)Generated_BuildMetadata.cs">

<PropertyGroup>
<BuildMetadataContents>
<![CDATA[
// <autogenerated />

internal static class BuildMetadata
{
public const string ILLinkImplFramework = "$(NetCoreAppToolCurrent)";
}
]]>
</BuildMetadataContents>
</PropertyGroup>

<WriteLinesToFile
File="$(IntermediateOutputPath)Generated_BuildMetadata.cs"
Lines="$([MSBuild]::Escape($(BuildMetadataContents)))"
Overwrite="true" />

<ItemGroup>
<Compile Include="$(IntermediateOutputPath)Generated_BuildMetadata.cs" />

<!-- Append to FileWrites so the file will be removed on clean -->
<FileWrites Include="$(IntermediateOutputPath)Generated_BuildMetadata.cs" />
</ItemGroup>
Comment thread
ViktorHofer marked this conversation as resolved.
</Target>

</Project>
9 changes: 8 additions & 1 deletion src/tools/illink/src/ILLink.Tasks/LinkTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down