dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.27k stars 4.73k forks source link

NativeAOT: Invalid handling of `nosinglewarnassembly` #93819

Closed vitek-karas closed 5 months ago

vitek-karas commented 1 year ago

Using a project file like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

<Target Name="ConfigureTrimming"
        BeforeTargets="PrepareForILLink">
  <ItemGroup>
    <ManagedAssemblyToLink Condition="'%(Filename)' == 'System.Xml'">
      <TrimmerSingleWarn>false</TrimmerSingleWarn>
    </ManagedAssemblyToLink>
  </ItemGroup>
</Target>

</Project>

This should end up adding --nosinglewarnassembly:System.Xml to the ilc command line. But in reality it adds --nosinglewarnassembly:System.

The bug is very likely in https://github.com/dotnet/runtime/blob/c7fd55cd4051b009d4cb7564c8246b6b8b337724/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets#L276C45-L276C45

The item group _IlcNoSingleWarnAssemblies already contains simple names of assemblies, not file names. So using %(Filename) seems to remove another "extension" from the name.

ghost commented 1 year ago

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.

Issue Details
Using a project file like this: ```xml Exe net8.0 enable enable false ``` This should end up adding `--nosinglewarnassembly:System.Xml` to the ilc command line. But in reality it adds `--nosinglewarnassembly:System`. The bug is very likely in https://github.com/dotnet/runtime/blob/c7fd55cd4051b009d4cb7564c8246b6b8b337724/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets#L276C45-L276C45 The item group `_IlcNoSingleWarnAssemblies` already contains simple names of assemblies, not file names. So using `%(Filename)` seems to remove another "extension" from the name.
Author: vitek-karas
Assignees: -
Labels: `area-NativeAOT-coreclr`
Milestone: -
LakshanF commented 5 months ago

I believe this was fixed with #101799

MichalStrehovsky commented 5 months ago

Yep.