Skip to content

ILC should run after ComputeResolvedFilesToPublishList #108909

@sbomer

Description

@sbomer

Native AOT hooks into the publish logic using BeforeTargets="ComputeResolvedFilesToPublishList":

<Target Name="ComputeLinkedFilesToPublish"
BeforeTargets="ComputeResolvedFilesToPublishList"
DependsOnTargets="_ComputeAssembliesToCompileToNative;LinkNative">

However, this target has some conflict resolution that should be done before ILC runs:
https://github.com/dotnet/sdk/blob/456aa42f693f9ff022c7e5f9f7473e0dc5d3b2f4/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L542-L559

I noticed this in a local build where ILLink was picking a different version of an assembly than ILC (because ILLink runs after ComputeResolvedFilesToPublishList:
https://github.com/dotnet/sdk/blob/456aa42f693f9ff022c7e5f9f7473e0dc5d3b2f4/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L453-L456

The ilc.rsp file in my scenario has both:

-r:C:\Users\svbomer\.nuget\packages\microsoft.azure.amqp\2.6.7\lib\netstandard2.0\Microsoft.Azure.Amqp.dll
-r:D:\azure-amqp\bin\Release\Microsoft.Azure.Amqp\net9.0\Microsoft.Azure.Amqp.dll

ILC seems to use the first dll passed on the command-line.

Compare this with the PublishSelfContained output. During ComputeResolvedFilesToPublishList, the conflict is resolved and only the dll from the nuget package is removed, leaving the one from a local build. The local build is passed to ILLink.

Unfortunately I wasn't able to come up with a simple repro, but the project file looked like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <!-- <PublishTrimmed>true</PublishTrimmed>
    <PublishAot>true</PublishAot> -->
    <PublishSelfContained>true</PublishSelfContained>
    <TrimmerSingleWarn>false</TrimmerSingleWarn>
    <IsTestSupportProject>true</IsTestSupportProject>
    <_TrimmerDumpDependencies>true</_TrimmerDumpDependencies>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\..\sdk\eventhub\Azure.Messaging.EventHubs.Processor\src\Azure.Messaging.EventHubs.Processor.csproj" />
    <ProjectReference Include="..\..\..\..\sdk\eventhub\Azure.Messaging.EventHubs\src\Azure.Messaging.EventHubs.csproj" />
    <ProjectReference Include="D:\azure-amqp\src\Microsoft.Azure.Amqp.csproj" />
    <TrimmerRootAssembly Include="Azure.Messaging.EventHubs.Processor" />
  </ItemGroup>
  <ItemGroup>
    <!-- Update this dependency to its latest, which has all the annotations -->
    <PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
  </ItemGroup>
</Project>

Binlogs available upon request.

Metadata

Metadata

Assignees

Labels

area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions