microsoft / perfview

PerfView is a CPU and memory performance-analysis tool
http://channel9.msdn.com/Series/PerfView-Tutorial
MIT License
4.05k stars 695 forks source link

Microsoft.Diagnostics.Tracing.TraceEvent NuGet not compatible with single file apps? #2035

Open ppekrol opened 1 month ago

ppekrol commented 1 month ago

Hi, my csproj to reproduce the issue is as simple as:

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

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

  <ItemGroup>
      <PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.77" />
  </ItemGroup>

</Project>

When I issue following command:

dotnet publish --configuration Release --runtime win-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true

All works fine and I'm ending up with 1 exe, but when I switch to linux-x64 (haven't checked other non-windows platforms)

dotnet publish --configuration Release --runtime linux-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true

Then I'm ending up with

image

Can I do something with this on my side or this needs to be handled on yours? Can you advise?

cincuranet commented 1 month ago

@brianrob We're now putting the native dependencies (like msdia) into build/native/amd64, etc. Maybe runtimes/{rid}/native (where rid would be win-x64, etc.) would be better place. That way it should not be selected for non-Windows publishes.

ppekrol commented 1 month ago

@cincuranet I think you are correct, our own package contains native libs and we are wrapping them up in 'runtimes'. Everything is working as expected then.

image

From my brief investigation it looks like those 3 directories do not even contain appropriate DLLs? The amd64 files are for windows-x64 and x86 one are for windows-x86? Nothing to do with linux there at all.

cincuranet commented 1 month ago

From my brief investigation it looks like those 3 directories do not even contain appropriate DLLs? The amd64 files are for windows-x64 and x86 one are for windows-x86? Nothing to do with linux there at all.

That's expected. These libraries are Windows-only.

brianrob commented 1 month ago

I believe that this is fixed in a newer version of TraceEvent. Can you please try this with the latest version? I believe the change you need is https://github.com/microsoft/perfview/pull/1845.

cincuranet commented 1 month ago

I confirmed the same behavior with Microsoft.Diagnostics.Tracing.TraceEvent 3.1.10

image

cincuranet commented 1 month ago

Mea culpa. The amd64 folder is actually empty. 🤦‍♂️

ppekrol commented 1 month ago

With <PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.10" /> and dotnet publish --configuration Release --runtime linux-x64 --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true I'm getting

image and the amd64 has image

cincuranet commented 1 month ago

OK, I re-tested what I tested :) and now I do have files in amd64 as well. Go figure. That means the runtimes folder should be viable option.

I'll try to test it next week. Sounds good @brianrob?