Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -15,7 +15,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Polly.Core" Version="8.4.1" />
<PackageReference Include="SharpCompress" Version="0.32.1" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
2 changes: 0 additions & 2 deletions tests/Microsoft.DotNet.Docker.Tests/PowerShellTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
using System.Threading.Tasks;
using Polly;
using Polly.Retry;
using SharpCompress.Common;
using SharpCompress.Readers;
using Xunit;
using Xunit.Abstractions;

Expand Down
22 changes: 18 additions & 4 deletions tests/Microsoft.DotNet.Docker.Tests/SdkImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
using System.Threading.Tasks;
using Polly;
using Polly.Retry;
using SharpCompress.Common;
using SharpCompress.Readers;
using System.Formats.Tar;
using System.IO.Compression;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -283,9 +283,23 @@ private IEnumerable<SdkContentFileInfo> GetActualSdkContents(ProductImageData im
private static IEnumerable<SdkContentFileInfo> EnumerateArchiveContents(string path)
{
using FileStream fileStream = File.OpenRead(path);
using IReader reader = ReaderFactory.Open(fileStream);
using var gzipStream = new GZipStream(fileStream, CompressionMode.Decompress);
using var tarReader = new TarReader(gzipStream);
using TempFolderContext tempFolderContext = FileHelper.UseTempFolder();
reader.WriteAllToDirectory(tempFolderContext.Path, new ExtractionOptions() { ExtractFullPath = true });

while (tarReader.GetNextEntry() is TarEntry entry)
{
string destinationPath = Path.Combine(tempFolderContext.Path, entry.Name);
if (entry.EntryType is TarEntryType.Directory)
{
Directory.CreateDirectory(destinationPath);
}
else if (entry.EntryType is TarEntryType.RegularFile)
{
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!);
entry.ExtractToFile(destinationPath, overwrite: false);
}
}

foreach (FileInfo file in new DirectoryInfo(tempFolderContext.Path).EnumerateFiles("*", SearchOption.AllDirectories))
{
Expand Down
Loading