From 4885e2246926419e12697a974bf6f0d34ae1c5da Mon Sep 17 00:00:00 2001 From: Tony Redondo Date: Wed, 13 Nov 2024 00:16:17 +0100 Subject: [PATCH 1/3] Dotnet upgrade --- .github/workflows/ci.yml | 7 ++++--- src/Directory.Build.props | 4 ++-- .../TimeItSharp.FluentConfiguration.Sample.csproj | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fba995..81ac696 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,13 +15,14 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup .NET 6.0, 7.0, 8.0 + - name: Setup .NET 6.0, 7.0, 8.0, 9.0 uses: actions/setup-dotnet@v3 with: dotnet-version: | 6.0.x 7.0.x 8.0.x + 9.0.x - name: Restore dependencies run: dotnet restore @@ -31,11 +32,11 @@ jobs: - name: Run timeitsharp dotnet tool sample run: ./TimeItSharp config-example.json - working-directory: src/TimeItSharp/bin/Release/net8.0 + working-directory: src/TimeItSharp/bin/Release/net9.0 - name: Run timeitsharp engine sample run: ./TimeItSharp.FluentConfiguration.Sample - working-directory: test/TimeItSharp.FluentConfiguration.Sample/bin/Release/net8.0 + working-directory: test/TimeItSharp.FluentConfiguration.Sample/bin/Release/net9.0 - uses: actions/upload-artifact@v3 with: diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 4e55243..dfae7b2 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,8 +1,8 @@ - 0.1.21 + 0.1.22 Tony Redondo, Grégory Léocadie - net6.0;net7.0;net8.0 + net6.0;net7.0;net8.0;net9.0 enable enable 11 diff --git a/test/TimeItSharp.FluentConfiguration.Sample/TimeItSharp.FluentConfiguration.Sample.csproj b/test/TimeItSharp.FluentConfiguration.Sample/TimeItSharp.FluentConfiguration.Sample.csproj index da9f57a..9f97c96 100644 --- a/test/TimeItSharp.FluentConfiguration.Sample/TimeItSharp.FluentConfiguration.Sample.csproj +++ b/test/TimeItSharp.FluentConfiguration.Sample/TimeItSharp.FluentConfiguration.Sample.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable From 2eff7391bfe8fc98c4d320a28466608d45e44b29 Mon Sep 17 00:00:00 2001 From: Tony Redondo Date: Wed, 13 Nov 2024 00:23:53 +0100 Subject: [PATCH 2/3] changes --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index dfae7b2..0c07d81 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,7 +5,7 @@ net6.0;net7.0;net8.0;net9.0 enable enable - 11 + 13 true false From f571b9a8b5f8e0fd2bebe8e8b4dabe01276904b3 Mon Sep 17 00:00:00 2001 From: Tony Redondo Date: Wed, 13 Nov 2024 10:50:29 +0100 Subject: [PATCH 3/3] Improvements --- src/TimeItSharp.Common/ScenarioProcessor.cs | 15 ++++++++++++--- src/TimeItSharp.Common/TimeItSharp.Common.csproj | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/TimeItSharp.Common/ScenarioProcessor.cs b/src/TimeItSharp.Common/ScenarioProcessor.cs index 4272890..9d1c058 100644 --- a/src/TimeItSharp.Common/ScenarioProcessor.cs +++ b/src/TimeItSharp.Common/ScenarioProcessor.cs @@ -24,6 +24,8 @@ internal sealed class ScenarioProcessor private readonly IReadOnlyList _services; private readonly TimeItCallbacks.CallbacksTriggers _callbacksTriggers; + private static readonly IDictionary EnvironmentVariables = Environment.GetEnvironmentVariables(); + public ScenarioProcessor( Config configuration, TemplateVariables templateVariables, @@ -453,7 +455,7 @@ private async Task RunCommandAsync(int index, Scenario scenario, Time var timeoutCmdArguments = scenario.Timeout.ProcessArguments ?? string.Empty; var cmdEnvironmentVariables = new Dictionary(); - foreach (DictionaryEntry osEnv in Environment.GetEnvironmentVariables()) + foreach (DictionaryEntry osEnv in EnvironmentVariables) { if (osEnv.Key?.ToString() is { Length: > 0 } keyString) { @@ -472,8 +474,15 @@ private async Task RunCommandAsync(int index, Scenario scenario, Time } // add working directory as a path to resolve binary - var pathWithWorkingDir = workingDirectory + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH"); - Environment.SetEnvironmentVariable("PATH", pathWithWorkingDir); + if (!string.IsNullOrWhiteSpace(workingDirectory)) + { + var currentPath = Environment.GetEnvironmentVariable("PATH"); + if (currentPath != null && !currentPath.Contains(workingDirectory)) + { + var pathWithWorkingDir = workingDirectory + Path.PathSeparator + currentPath; + Environment.SetEnvironmentVariable("PATH", pathWithWorkingDir); + } + } // Setup the command var cmd = Cli.Wrap(cmdString) diff --git a/src/TimeItSharp.Common/TimeItSharp.Common.csproj b/src/TimeItSharp.Common/TimeItSharp.Common.csproj index 5191f6d..6cd3cff 100644 --- a/src/TimeItSharp.Common/TimeItSharp.Common.csproj +++ b/src/TimeItSharp.Common/TimeItSharp.Common.csproj @@ -23,8 +23,8 @@ - - + +