Skip to content

Publishing a native AOT library shouldn't publish managed symbols files of ProjectReferences #40488

Open
@eerhardt

Description

@eerhardt

Describe the bug

When publishing a native AOT library that has a ProjectReference to another class library, the other class library's managed .pdb symbols are being published along size the native AOT library. These are unnecessary files and should be excluded by default.

To Reproduce

Given 2 projects:

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

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <InvariantGlobalization>true</InvariantGlobalization>
    <PublishAot>true</PublishAot>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\AnotherClassLib\AnotherClassLib.csproj" />
  </ItemGroup>
</Project>
using AnotherClassLib;
using System.Runtime.InteropServices;

namespace MyLibrary;

public static class EntryPoints
{
    [UnmanagedCallersOnly(EntryPoint = "MyValidate")]
    public static int MyValidate()
    {
        Class1 c = new();
        c.Method();
        return 1;
    }
}
<Project Sdk="Microsoft.NET.Sdk">

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

</Project>
namespace AnotherClassLib;

public class Class1
{
    public void Method()
    {
        Console.WriteLine("Hello from a method");
    }
}

dotnet publish -r win-x64 the first project and inspect the publish folder.

image

The AnotherClassLib.pdb file shouldn't be there. It is unnecessary.

Exceptions (if any)

N/A

cc @agocke @MichalStrehovsky @sbomer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-NativeAOTNative AOT compilationuntriagedRequest triage from a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions