зеркало из https://github.com/microsoft/msquic.git
Enable single file exe for QuicTrace (#2204)
* Enable single file exe for QuicTrace * Extra newline
This commit is contained in:
Родитель
abb91f74e5
Коммит
eec1bdaa05
|
@ -32,27 +32,20 @@ foreach ($RID in $RIDs) {
|
||||||
|
|
||||||
$FullOutputFile = Join-Path $BinFolder "Release/net6.0/$RID/publish/$ExeName"
|
$FullOutputFile = Join-Path $BinFolder "Release/net6.0/$RID/publish/$ExeName"
|
||||||
|
|
||||||
# Publish Non Trimmed Non Single File
|
# Publish Non Trimmed
|
||||||
dotnet publish $ToolDir -r $RID -c Release --self-contained true
|
dotnet publish $ToolDir -r $RID -c Release -p:PublishSingleFile=true --self-contained true -p:EnableCompressionInSingleFile=true
|
||||||
|
|
||||||
$ArtifactFolder = Join-Path $RootOutputFolder $RID
|
$ArtifactFolder = Join-Path $RootOutputFolder $RID
|
||||||
if (!(Test-Path $ArtifactFolder)) { New-Item -Path $ArtifactFolder -ItemType Directory -Force | Out-Null }
|
if (!(Test-Path $ArtifactFolder)) { New-Item -Path $ArtifactFolder -ItemType Directory -Force | Out-Null }
|
||||||
Copy-Item $FullOutputFile $ArtifactFolder
|
Copy-Item $FullOutputFile $ArtifactFolder
|
||||||
|
|
||||||
# # Publish Non Trimmed
|
# Clear out bin folder
|
||||||
# dotnet publish $ToolDir -r $RID -c Release -p:PublishSingleFile=true --self-contained true -p:EnableCompressionInSingleFile=true
|
if (Test-Path $BinFolder) { Remove-Item $BinFolder -Recurse -Force | Out-Null }
|
||||||
|
|
||||||
# $ArtifactFolder = Join-Path $RootOutputFolder $RID
|
# Publish Trimmed
|
||||||
# if (!(Test-Path $ArtifactFolder)) { New-Item -Path $ArtifactFolder -ItemType Directory -Force | Out-Null }
|
dotnet publish $ToolDir -r $RID -c Release -p:PublishSingleFile=true --self-contained true -p:EnableCompressionInSingleFile=true -p:PublishTrimmed=true
|
||||||
# Copy-Item $FullOutputFile $ArtifactFolder
|
|
||||||
|
|
||||||
# # Clear out bin folder
|
$TrimmedArtifactFolder = Join-Path $ArtifactFolder "trimmed"
|
||||||
# if (Test-Path $BinFolder) { Remove-Item $BinFolder -Recurse -Force | Out-Null }
|
if (!(Test-Path $TrimmedArtifactFolder)) { New-Item -Path $TrimmedArtifactFolder -ItemType Directory -Force | Out-Null }
|
||||||
|
Copy-Item $FullOutputFile $TrimmedArtifactFolder
|
||||||
# # 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
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.74" />
|
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.74" />
|
||||||
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent.SupportFiles" Version="1.0.23" />
|
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent.SupportFiles" Version="1.0.23" />
|
||||||
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.9-rc1" />
|
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.14-rc1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="$(SolutionDir)..\..\LICENSE">
|
<None Include="$(SolutionDir)..\..\LICENSE">
|
||||||
|
|
|
@ -61,7 +61,20 @@ namespace QuicTrace
|
||||||
//
|
//
|
||||||
// Create our runtime environment, add file, enable cookers, and process.
|
// Create our runtime environment, add file, enable cookers, and process.
|
||||||
//
|
//
|
||||||
using var dataSources = DataSourceSet.Create();
|
|
||||||
|
PluginSet pluginSet;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(typeof(QuicEtwSource).Assembly.Location))
|
||||||
|
{
|
||||||
|
// Single File EXE
|
||||||
|
pluginSet = PluginSet.Load(new[] { Environment.CurrentDirectory }, new SingleFileAssemblyLoader());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginSet = PluginSet.Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
using var dataSources = DataSourceSet.Create(pluginSet);
|
||||||
dataSources.AddFile(filePath);
|
dataSources.AddFile(filePath);
|
||||||
var info = new EngineCreateInfo(dataSources.AsReadOnly());
|
var info = new EngineCreateInfo(dataSources.AsReadOnly());
|
||||||
using var runtime = Engine.Create(info);
|
using var runtime = Engine.Create(info);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.9-rc1" />
|
<PackageReference Include="Microsoft.Performance.SDK" Version="1.0.14-rc1" />
|
||||||
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="1.0.9-rc1" />
|
<PackageReference Include="Microsoft.Performance.Toolkit.Engine" Version="1.0.14-rc1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\dll\QuicTraceLib.csproj" />
|
<ProjectReference Include="..\dll\QuicTraceLib.csproj" />
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.Performance.SDK;
|
||||||
|
using Microsoft.Performance.SDK.Runtime;
|
||||||
|
|
||||||
|
namespace QuicTrace
|
||||||
|
{
|
||||||
|
internal class SingleFileAssemblyLoader : IAssemblyLoader
|
||||||
|
{
|
||||||
|
private readonly string CurrentExePath = Environment.ProcessPath!;
|
||||||
|
|
||||||
|
public bool SupportsIsolation => false;
|
||||||
|
|
||||||
|
public bool IsAssembly(string path)
|
||||||
|
{
|
||||||
|
return path == CurrentExePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Assembly? LoadAssembly(string assemblyPath, out ErrorInfo error)
|
||||||
|
{
|
||||||
|
if (assemblyPath != CurrentExePath)
|
||||||
|
{
|
||||||
|
error = new ErrorInfo(ErrorCodes.AssemblyLoadFailed, $"AssemblyPath must be {CurrentExePath}, was {assemblyPath}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = ErrorInfo.None;
|
||||||
|
return typeof(QuicEtwSource).Assembly;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче