From 857a9e46c472bf7e9e2f95e31a7e1b9f848d67fd Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister <4602612+bash@users.noreply.github.com> Date: Wed, 23 Nov 2022 15:41:10 +0100 Subject: [PATCH] =?UTF-8?q?Use=20CreateTempSubdirectory=20for=20.NET=20?= =?UTF-8?q?=E2=89=A5=207.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 8 ++++++-- TempDirectory.Test/TempDirectory.Test.csproj | 2 +- TempDirectory/TempDirectory.csproj | 2 +- TempDirectory/TempSubdirectory.cs | 5 +++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c82ed8..1c5f599 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v3 + name: Install .NET SDK 6.x + with: + version: 6.x - name: Restore dependencies run: dotnet restore /p:TreatWarningsAsErrors=true - name: Build @@ -22,8 +26,8 @@ jobs: name: Generate NuGet Packages runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-dotnet@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-dotnet@v3 name: Install Current .NET SDK - name: Generate NuGet Packages run: dotnet pack --configuration Release --output nupkg /p:TreatWarningsAsErrors=true diff --git a/TempDirectory.Test/TempDirectory.Test.csproj b/TempDirectory.Test/TempDirectory.Test.csproj index 2b3d3ab..6e60dcf 100644 --- a/TempDirectory.Test/TempDirectory.Test.csproj +++ b/TempDirectory.Test/TempDirectory.Test.csproj @@ -1,7 +1,7 @@ - net7.0 + net7.0;net6.0 false Messerli.TempDirectory.Test Messerli.TempDirectory.Test diff --git a/TempDirectory/TempDirectory.csproj b/TempDirectory/TempDirectory.csproj index 5b08290..fee301d 100644 --- a/TempDirectory/TempDirectory.csproj +++ b/TempDirectory/TempDirectory.csproj @@ -2,7 +2,7 @@ 0.3.0 - netstandard2.0 + net7.0;netstandard2.0 Messerli.TempDirectory Messerli.TempDirectory diff --git a/TempDirectory/TempSubdirectory.cs b/TempDirectory/TempSubdirectory.cs index 15e4a8b..5d48108 100644 --- a/TempDirectory/TempSubdirectory.cs +++ b/TempDirectory/TempSubdirectory.cs @@ -17,9 +17,14 @@ private TempSubdirectory(string fullName) /// Creates a temporary subdirectory in the temporary folder of the current user. public static TempSubdirectory Create(string? prefix = null) { +#if NET7_0_OR_GREATER + var tempSubdirectory = Directory.CreateTempSubdirectory(prefix); + return new TempSubdirectory(tempSubdirectory.FullName); +#else var fullName = Path.Combine(Path.GetTempPath(), $"{prefix}{Guid.NewGuid()}"); Directory.CreateDirectory(fullName); return new TempSubdirectory(fullName); +#endif } public void Dispose()