New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require the users to do manual installation of TraceEvent when using Diagnostics package #962

Merged
merged 2 commits into from Nov 16, 2018

Conversation

Projects
None yet
3 participants
@wojtpl2
Copy link
Collaborator

wojtpl2 commented Nov 16, 2018

Currently, when you create application that use BenchmarkDotNet.Diagnostics.Window you should add reference to Microsoft.Diagnostics.Tracing.TraceEvent directly in your csproj:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="BenchmarkDotNet" Version="0.11.2-develop" />
    <PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.2-develop" />
    
    <!-- Add reference to Microsoft.Diagnostics.Tracing.TraceEvent -->
    <PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.26" />
  </ItemGroup>

</Project>

If you don't do this, you get error message:

Please install the latest Microsoft.Diagnostics.Tracing.TraceEvent package in the project with benchmarks so MSBuild can copy the native dependencies of TraceEvent to the output folder.

Unhandled Exception: System.ComponentModel.Win32Exception: The specified module could not be found
   at Microsoft.Diagnostics.Tracing.Extensions.ETWKernelControl.LoadKernelTraceControl()
   at Microsoft.Diagnostics.Tracing.Extensions.ETWKernelControl.StartKernelSession(UInt64& TraceHandle, Void* propertyBuff, Int32 propertyBuffLength, STACK_TRACING_EVENT_ID* stackTracingEventIds, Int32 cStackTracingEventIds)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableKernelProvider(Keywords flags, Keywords stackCapture)
   at BenchmarkDotNet.Diagnostics.Windows.KernelSession.EnableProviders()
   at BenchmarkDotNet.Diagnostics.Windows.EtwProfiler.Start(DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Extensions.CommonExtensions.ForEach[T](IList`1 source, Action`1 command)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, ArtifactsPaths artifactsPaths, IDiagnoser diagnoser, String executableName, IConfig config, IResolver resolver)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(ExecuteParameters executeParameters)
   at BenchmarkDotNet.Running.BenchmarkRunner.Execute(ILogger logger, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, IToolchain toolchain, BuildResult buildResult, IConfig config, IResolver resolver)
   at BenchmarkDotNet.Running.BenchmarkRunner.RunCore(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, ReadOnlyConfig config, IResolver resolver, BuildResult buildResult)
   at BenchmarkDotNet.Running.BenchmarkRunner.Run(BenchmarkRunInfo benchmarkRunInfo, Dictionary`2 buildResults, IResolver resolver, ILogger logger, List`1 artifactsToCleanup, String rootArtifactsFolderPath, StartedClock& runChronometer)
   at BenchmarkDotNet.Running.BenchmarkRunner.Run(BenchmarkRunInfo[] benchmarkRunInfos, IConfig commonSettingsConfig)
   at BenchmarkDotNet.Running.BenchmarkSwitcher.Run(String[] args, IConfig config)
   at Test_955.Program.Main(String[] args) in c:\Work\Test_955\Program.cs:line 13

I start application by command:

dotnet run -c Release -- --filter * --profiler ETW

In this PR I push changes that set PrivateAssets="contentfiles;analyzers" on nuget reference to Microsoft.Diagnostics.Tracing.TraceEvent. Default value is contentfiles;analyzers;build. There is documentation for this feature https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files.

After that you don't need reference to Microsoft.Diagnostics.Tracing.TraceEvent in csproj. You just need:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="BenchmarkDotNet" Version="0.11.2-develop" />
    <PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.2-develop" />
  </ItemGroup>

</Project>

But of course you can add a reference to the newer version.
I tested these changes using local feed.

@AndreyAkinshin AndreyAkinshin requested a review from adamsitnik Nov 16, 2018

@adamsitnik

This comment has been minimized.

Copy link
Member

adamsitnik commented Nov 16, 2018

@wojtpl2 excellent! big thanks for identifying the issue and getting rid of it! it was super annoying, now we are going to have much better first user experience for EtwProfiler!

@adamsitnik adamsitnik merged commit 4e65311 into dotnet:master Nov 16, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.

@wojtpl2 wojtpl2 deleted the wojtpl2:Improve_diagnostics_dll branch Nov 16, 2018

@AndreyAkinshin AndreyAkinshin added this to the v0.11.3 milestone Nov 16, 2018

@adamsitnik adamsitnik changed the title Improve diagnostics dll Don't require the users to do manual installation of TraceEvent when using Diagnostics package Nov 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment