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
26 changes: 20 additions & 6 deletions test/coverlet.integration.tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,30 @@ protected BuildConfiguration GetAssemblyBuildConfiguration()

private protected string GetPackageVersion(string filter)
{
if (!Directory.Exists($"../../../../../bin/{GetAssemblyBuildConfiguration()}/Packages"))
string packagesPath = $"../../../../../bin/{GetAssemblyBuildConfiguration()}/Packages";

if (!Directory.Exists(packagesPath))
{
throw new DirectoryNotFoundException("Package directory not found, run 'dotnet pack' on repository root");
}

using Stream pkg = File.OpenRead(Directory.GetFiles($"../../../../../bin/{GetAssemblyBuildConfiguration()}/Packages", filter).Single());
using var reader = new PackageArchiveReader(pkg);
using Stream nuspecStream = reader.GetNuspec();
var manifest = Manifest.ReadFrom(nuspecStream, false);
return manifest.Metadata.Version.OriginalVersion;
var files = Directory.GetFiles(packagesPath, filter).ToList();
if (files.Count == 0)
{
throw new InvalidOperationException($"Could not find any package using filter '{filter}' in folder '{Path.GetFullPath(packagesPath)}'. Make sure 'dotnet pack' was called.");
}
else if (files.Count > 1)
{
throw new InvalidOperationException($"Found more than one package using filter '{filter}' in folder '{Path.GetFullPath(packagesPath)}'. Make sure 'dotnet pack' was only called once.");
}
else
{
using Stream pkg = File.OpenRead(files[0]);
using var reader = new PackageArchiveReader(pkg);
using Stream nuspecStream = reader.GetNuspec();
var manifest = Manifest.ReadFrom(nuspecStream, false);
return manifest.Metadata.Version.OriginalVersion;
}
}

private protected ClonedTemplateProject CloneTemplateProject(bool cleanupOnDispose = true, string testSDKVersion = "16.5.0")
Expand Down