Skip to content

Commit

Permalink
Update QuicTrace app to .NET 6 and QuicTraceLib to newest SDK (micros…
Browse files Browse the repository at this point in the history
…oft#2123)

* Update QuicTrace app to .NET 6, Publish single file versions of app

* Run on windows 2022

* Install .NET 6 RC 2

* Fix spacing

* Another runtime attempt

* Revert updates, fix build

* Remove use sdk

* Update project to rc1 wpa dependencies

* 1 more version update

* Remove single file exe
  • Loading branch information
thhous-msft authored Dec 1, 2021
1 parent 61432fb commit c1bd30b
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 42 deletions.
25 changes: 13 additions & 12 deletions .azure/templates/build-config-quictrace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ jobs:
- job: build_quictrace
displayName: Any CPU
pool:
vmImage: windows-2019
vmImage: windows-2022
steps:
- checkout: self

- task: NuGetCommand@2
displayName: Nuget Restore
inputs:
restoreSolution: src\plugins\QuicTrace.sln

- task: VSBuild@1
- task: DotNetCoreCLI@2
continueOnError: true
inputs:
solution: src\plugins\QuicTrace.sln
platform: Any CPU
projects: src\plugins\QuicTrace.sln
command: build
configuration: Debug

- task: VSBuild@1
- task: DotNetCoreCLI@2
continueOnError: true
inputs:
solution: src\plugins\QuicTrace.sln
platform: Any CPU
projects: src\plugins\QuicTrace.sln
command: build
configuration: Release

- task: PowerShell@2
displayName: Publish Single File
inputs:
pwsh: true
filePath: scripts/publish-quictrace.ps1

- template: ./upload-artifacts.yml
58 changes: 58 additions & 0 deletions scripts/publish-quictrace.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<#
.SYNOPSIS
.EXAMPLE
public-quictrace.ps1
#>

Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'

$RIDs = @("win-x64", "linux-x64", "osx-x64")

# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent

$ToolDir = Join-Path $RootDir "src/plugins/trace/exe"
$BinFolder = Join-Path $ToolDir "bin"

$RootOutputFolder = Join-Path $RootDir "artifacts/bin/quictrace/published"


foreach ($RID in $RIDs) {
# Clear out bin folder
if (Test-Path $BinFolder) { Remove-Item $BinFolder -Recurse -Force | Out-Null }

$ExeName = "QuicTrace"
if ($RID.Contains("win")) {
$ExeName = "QuicTrace.exe"
}

$FullOutputFile = Join-Path $BinFolder "Release/net6.0/$RID/publish/$ExeName"

# Publish Non Trimmed Non Single File
dotnet publish $ToolDir -r $RID -c Release --self-contained true

$ArtifactFolder = Join-Path $RootOutputFolder $RID
if (!(Test-Path $ArtifactFolder)) { New-Item -Path $ArtifactFolder -ItemType Directory -Force | Out-Null }
Copy-Item $FullOutputFile $ArtifactFolder

# # Publish Non Trimmed
# dotnet publish $ToolDir -r $RID -c Release -p:PublishSingleFile=true --self-contained true -p:EnableCompressionInSingleFile=true

# $ArtifactFolder = Join-Path $RootOutputFolder $RID
# if (!(Test-Path $ArtifactFolder)) { New-Item -Path $ArtifactFolder -ItemType Directory -Force | Out-Null }
# Copy-Item $FullOutputFile $ArtifactFolder

# # Clear out bin folder
# if (Test-Path $BinFolder) { Remove-Item $BinFolder -Recurse -Force | Out-Null }

# # Publish Trimmed
# dotnet publish $ToolDir -r $RID -c Release -p:PublishSingleFile=true --self-contained true -p:EnableCompressionInSingleFile=true -p:PublishTrimmed=true

# $TrimmedArtifactFolder = Join-Path $ArtifactFolder "trimmed"
# if (!(Test-Path $TrimmedArtifactFolder)) { New-Item -Path $TrimmedArtifactFolder -ItemType Directory -Force | Out-Null }
# Copy-Item $FullOutputFile $TrimmedArtifactFolder
}
2 changes: 1 addition & 1 deletion src/plugins/trace/dll/DataModel/QuicEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public enum QuicEventId : ushort
//
// The base class for all QUIC events.
//
public class QuicEvent : IKeyedDataType<Guid>
public class QuicEvent : IKeyedDataType<Guid>, IComparable<Guid>
{
//
// Global configuration to control how parsing works. Defaults to WPA filter mode.
Expand Down
16 changes: 7 additions & 9 deletions src/plugins/trace/dll/QuicEtwSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace QuicTrace
/// <summary>
/// This custom data source defines processes MsQuic ETW events.
/// </summary>
[CustomDataSource(
[ProcessingSource(
"{FA99CEB6-7043-42FA-97BA-932337EE19F5}",
"MsQuic ETW Event",
"ETW events generated by MsQuic")]
[FileDataSource("etl", "Event Trace Log")]
public class QuicEtwSource : CustomDataSourceBase
public class QuicEtwSource : ProcessingSource
{
private IApplicationEnvironment? applicationEnvironment;

Expand All @@ -30,12 +30,10 @@ protected override ICustomDataProcessor CreateProcessorCore(
Debug.Assert(!(applicationEnvironment is null));

return new QuicEventProcessor(
new QuicEventParser(dataSources.Select(x => x.GetUri().LocalPath).ToArray(), QuicEventSourceType.ETW),
new QuicEventParser(dataSources.Select(x => x.Uri.LocalPath).ToArray(), QuicEventSourceType.ETW),
options,
applicationEnvironment,
processorEnvironment,
AllTables,
MetadataTables);
processorEnvironment);
}

/// <summary>
Expand All @@ -45,9 +43,9 @@ protected override ICustomDataProcessor CreateProcessorCore(
///
/// For this sample, we just assume that if the file name is a match, it is handled by this add-in.
/// </summary>
/// <param name="path">Path to the source file</param>
/// <returns>true when <param name="path"> is handled by this add-in</param></returns>
protected override bool IsFileSupportedCore(string path)
/// <param name="dataSource">Path to the source file</param>
/// <returns>true when <param name="dataSource"> is handled by this add-in</param></returns>
protected override bool IsDataSourceSupportedCore(IDataSource dataSource)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/trace/dll/QuicEventCooker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace QuicTrace
{
public sealed class QuicEventCooker : CookedDataReflector, ISourceDataCooker<QuicEvent, object, Guid>
{
public static readonly DataCookerPath CookerPath = new DataCookerPath(QuicEventParser.SourceId, "QUIC");
public static readonly DataCookerPath CookerPath = DataCookerPath.ForSource(QuicEventParser.SourceId, "QUIC");

public ReadOnlyHashSet<Guid> DataKeys => new ReadOnlyHashSet<Guid>(new HashSet<Guid>());

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/trace/dll/QuicEventParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum QuicEventSourceType
LTTng // TODO - Add support
}

public sealed class QuicEventParser : SourceParserBase<QuicEvent, object, Guid>
public sealed class QuicEventParser : SourceParser<QuicEvent, object, Guid>
{
public const string SourceId = "QUIC";

Expand Down
8 changes: 3 additions & 5 deletions src/plugins/trace/dll/QuicEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@

namespace QuicTrace
{
public class QuicEventProcessor : CustomDataProcessorBaseWithSourceParser<QuicEvent, object, Guid>
public class QuicEventProcessor : CustomDataProcessorWithSourceParser<QuicEvent, object, Guid>
{
internal QuicEventProcessor(
ISourceParser<QuicEvent, object, Guid> sourceParser,
ProcessorOptions options,
IApplicationEnvironment applicationEnvironment,
IProcessorEnvironment processorEnvironment,
IReadOnlyDictionary<TableDescriptor, Action<ITableBuilder, IDataExtensionRetrieval>> allTablesMapping,
IEnumerable<TableDescriptor> metadataTables)
: base(sourceParser, options, applicationEnvironment, processorEnvironment, allTablesMapping, metadataTables)
IProcessorEnvironment processorEnvironment)
: base(sourceParser, options, applicationEnvironment, processorEnvironment)
{
}
}
Expand Down
13 changes: 5 additions & 8 deletions src/plugins/trace/dll/QuicTraceLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<RootNamespace>QuicTrace</RootNamespace>
<NoWarn>1701;1702;CA1036;CA1815;CA1720;CA1008;CA1711;CA1028</NoWarn>
<NoWarn>1701;1702;CA1036;CA1815;CA1720;CA1008;CA1711;CA1028;CA1014;CA1002</NoWarn>
<Authors>Microsoft</Authors>
<Company>Microsoft Corporation</Company>
<Copyright>Microsoft Corporation</Copyright>
<PackageProjectUrl>https://github.com/microsoft/msquic</PackageProjectUrl>
<RepositoryUrl>https://github.com/microsoft/msquic.git</RepositoryUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.44" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent.SupportFiles" Version="1.0.17" />
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.74" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent.SupportFiles" Version="1.0.23" />
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.9-rc1" />
</ItemGroup>
<ItemGroup>
<None Include="$(SolutionDir)..\..\LICENSE">
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/trace/exe/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ static QuicState ProcessTraceFile(string filePath)
//
// Create our runtime environment, add file, enable cookers, and process.
//
var runtime = Engine.Create();
runtime.AddFile(filePath);
using var dataSources = DataSourceSet.Create();
dataSources.AddFile(filePath);
var info = new EngineCreateInfo(dataSources.AsReadOnly());
using var runtime = Engine.Create(info);
runtime.EnableCooker(QuicEventCooker.CookerPath);
Console.WriteLine("Processing...");
var results = runtime.Process();
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/trace/exe/QuicTrace.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Performance.SDK" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="0.108.2" />
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.9-rc1" />
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="1.0.9-rc1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\dll\QuicTraceLib.csproj" />
Expand Down

0 comments on commit c1bd30b

Please sign in to comment.