Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public void VerifyVersionFile()

private void ExtractFileFromTarball(string tarballPath, string filePath, string outputDir)
{
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {tarballPath} -C {outputDir} {filePath}", OutputHelper);
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"--wildcards -xzf {tarballPath} -C {outputDir} {filePath}", OutputHelper);
Comment on lines 64 to +66

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this net8.0 project can reference https://github.com/dotnet/sdk/blob/5638e0ffabae3eb5505d7aaf81e3449ce3641c36/src/RazorSdk/Tasks/Microsoft.NET.Sdk.Razor.Tasks.csproj#L43 and use:

using System.Formats.Tar;
using System.IO;
using System.IO.Compression;
using Microsoft.Extensions.FileSystemGlobbing;
...
private void ExtractFileFromTarball(string tarballPath, string filePath, string outputDir)
{
    Matcher matcher = new();
    matcher.AddInclude(filePath);

    using FileStream fileStream = File.OpenRead(tarballPath);
    using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
    using TarReader reader = new(decompressorStream);

    TarEntry entry;
    while ((entry = reader.GetNextEntry()) is not null)
    {
        if (matcher.Match(entry.Name).HasMatches)
        {
            string outputPath = Path.Join(outputDir, entry.Name);
            Directory.CreateDirectory(Path.GetDirectoryName(outputPath));

            using FileStream outputFileStream = File.Create(outputPath);
            entry.DataStream.CopyTo(outputFileStream);
            // break; ?
        }
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kasperk81 - Fixing this in #15765

}
}