Skip to content

Commit ed2759e

Browse files
committed
Switch from 7z to zip for test archive
This not only gets us able to address #125, but allows the test to run on .NET Core runtimes as well, since the 7z library we were using only ran on net461. The test from #125 is still broken though, on account of not regularly running.
1 parent b7707b3 commit ed2759e

File tree

4 files changed

+6
-27
lines changed

4 files changed

+6
-27
lines changed

src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
<EmbeddedResource Include="ManagedGit\tree*" />
2626
<EmbeddedResource Include="test.vcprj" />
2727
<EmbeddedResource Include="test.prj" />
28-
<EmbeddedResource Include="repos\submodules.7z" />
28+
<EmbeddedResource Include="repos\*" />
2929
</ItemGroup>
3030
<ItemGroup>
3131
<ProjectReference Include="..\Nerdbank.GitVersioning.Tasks\Nerdbank.GitVersioning.Tasks.csproj" />
3232
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
3333
</ItemGroup>
3434
<ItemGroup>
35-
<PackageReference Include="7z.NET" Version="1.0.3" />
3635
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
3736
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
3837
<PackageReference Include="Microsoft.Build" Version="15.1.548" ExcludeAssets="runtime" />

src/NerdBank.GitVersioning.Tests/TestUtilities.cs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#if NET461
2-
using SevenZipNET;
3-
#endif
4-
using Validation;
1+
using Validation;
52

63
using System;
74
using System.Collections.Generic;
@@ -67,36 +64,19 @@ internal static void ExtractEmbeddedResource(string resourcePath, string extract
6764

6865
internal static ExpandedRepo ExtractRepoArchive(string repoArchiveName)
6966
{
70-
#if NET461
7167
string archiveFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
7268
string expandedFolderPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
7369

74-
ExtractEmbeddedResource($"repos.{repoArchiveName}.7z", archiveFilePath);
70+
ExtractEmbeddedResource($"repos.{repoArchiveName}.zip", archiveFilePath);
7571
try
7672
{
77-
for (int retryCount = 0; ; retryCount++)
78-
{
79-
try
80-
{
81-
var extractor = new SevenZipExtractor(archiveFilePath);
82-
extractor.ExtractAll(expandedFolderPath);
83-
return new ExpandedRepo(expandedFolderPath);
84-
}
85-
catch (System.ComponentModel.Win32Exception) when (retryCount < 2)
86-
{
87-
}
88-
}
73+
System.IO.Compression.ZipFile.ExtractToDirectory(archiveFilePath, expandedFolderPath);
74+
return new ExpandedRepo(expandedFolderPath);
8975
}
9076
finally
9177
{
92-
if (File.Exists(archiveFilePath))
93-
{
94-
File.Delete(archiveFilePath);
95-
}
78+
File.Delete(archiveFilePath);
9679
}
97-
#else
98-
throw new PlatformNotSupportedException();
99-
#endif
10080
}
10181

10282
internal class ExpandedRepo : IDisposable
-9.1 KB
Binary file not shown.
35.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)