diff --git a/Build.ps1 b/Build.ps1 index ee95466..1a08e8e 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -31,7 +31,6 @@ Process { Exec { & nuget pack Workleap.DotNet.CodingStandards.nuspec -OutputDirectory $outputDir -Version $version -ForceEnglishOutput } # Run tests - Get-Command nuget Exec { & dotnet test } # Push to a NuGet feed if the environment variables are set diff --git a/tests/Workleap.DotNet.CodingStandards.Tests/PackageFixture.cs b/tests/Workleap.DotNet.CodingStandards.Tests/PackageFixture.cs index 8d8e325..3ecf995 100644 --- a/tests/Workleap.DotNet.CodingStandards.Tests/PackageFixture.cs +++ b/tests/Workleap.DotNet.CodingStandards.Tests/PackageFixture.cs @@ -13,18 +13,24 @@ public sealed class PackageFixture : IAsyncLifetime public async Task InitializeAsync() { // On CI the exe is already present - var exe = "nuget"; + var exe = FullPath.GetTempPath() / $"nuget-{Guid.NewGuid()}.exe"; + await DownloadFileAsync("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", exe); + + var nuspecPath = PathHelpers.GetRootDirectory() / "Workleap.DotNet.CodingStandards.nuspec"; + string[] args = ["pack", nuspecPath, "-ForceEnglishOutput", "-Version", "999.9.9", "-OutputDirectory", _packageDirectory.FullPath]; + if (OperatingSystem.IsWindows()) { - var downloadPath = FullPath.GetTempPath() / $"nuget-{Guid.NewGuid()}.exe"; - await DownloadFileAsync("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", downloadPath); - exe = downloadPath; + await Cli.Wrap(exe) + .WithArguments(args) + .ExecuteAsync(); + } + else + { + await Cli.Wrap("/bin/sh") + .WithArguments(["mono", exe, .. args]) + .ExecuteAsync(); } - - var nuspecPath = PathHelpers.GetRootDirectory() / "Workleap.DotNet.CodingStandards.nuspec"; - await Cli.Wrap(exe) - .WithArguments(["pack", nuspecPath, "-ForceEnglishOutput", "-Version", "999.9.9", "-OutputDirectory", _packageDirectory.FullPath]) - .ExecuteAsync(); } public async Task DisposeAsync()