dotnet/diagnostics

Publish /p:PublishSingleFile=true with Microsoft.Diagnostics.NETCore.Client installed will fail

uffebjorklund opened this issue · 3 comments

Description

Microsoft.Diagnostics.Tracing.TraceEvent cant be installed when publishing with the option /p:PublishSingleFile=true.
The publish will fail with these errors.

/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]
/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018: System.ArgumentException: Invalid input specification: Found multiple entries with the same BundleRelativePath [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]
/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018:    at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs) [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]
/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]
/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]
/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]
/usr/share/dotnet/sdk/5.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1016,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/home/uffe/Repositories/github/uffebjorklund/Diagnostics.NETCore.Client.Crash/Diagnostics.NETCore.Client.Crash.csproj]

Minimal repo to reproduce can be found here: https://github.com/uffebjorklund/Diagnostics.NETCore.Client.Crash

Configuration

  • Ubuntu 20.10
  • x64

dotnet --info

.NET SDK (reflecting any global.json):
 Version:   5.0.101
 Commit:    d05174dc5a

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.10
 OS Platform: Linux
 RID:         ubuntu.20.10-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.101/

Host (useful for support):
  Version: 5.0.1
  Commit:  b02e13abab

.NET SDKs installed:
  3.1.404 [/usr/share/dotnet/sdk]
  5.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Update: It seems that my assumption about this being Microsoft.Diagnostics.NETCore.Client was wrong, it actually only happens if the package Microsoft.Diagnostics.Tracing.TraceEvent is installed.

This should probably be moved to https://github.com/microsoft/perfview/issues

This should probably be moved to https://github.com/microsoft/perfview/issues

Agreed. This isn't the first time we've encountered this before. In fact, we had to work around this very issue when packaging the tools as single file bundles. See:

<!-- This is an ugly workaround needed to be able to do r2r/single file on packages that reference TraceEvent as the package's props inject a double
write to the same relative path. This is related to https://github.com/microsoft/perfview/issues/1002 -->
<Target Name="RemoveDupeAssemblies"
Condition="'$(PublishSingleFile)' == 'true'"
AfterTargets="ComputeResolvedFilesToPublishList"
BeforeTargets="CopyFilesToPublishDirectory">
<PropertyGroup>
<ExcludedTraceEventPath>$([MSBuild]::NormalizeDirectory($(PkgMicrosoft_Diagnostics_Tracing_TraceEvent), 'lib/netstandard1.6'))</ExcludedTraceEventPath>
</PropertyGroup>
<ItemGroup>
<ResolvedFileToPublish Condition="$([MSBuild]::NormalizePath(%(ResolvedFileToPublish.Identity)).StartsWith($(ExcludedTraceEventPath)))"
ExcludeFromSingleFile="true"/>
</ItemGroup>
</Target>

There is already an issue over there tracking a resolution.

CC @brianrob

@sywhang, thoughts on closing this in favor of the PerfView issue?

@josalem closing it as dup of PerfView issue sounds good to me. Thanks!