diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d9390f..0800c3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,15 +18,15 @@ jobs: steps: + - name: Resolve project name + shell: pwsh + run: Add-Content -Path ${env:GITHUB_ENV} "`nprojectName=$(${env:GITHUB_REPOSITORY}.substring(${env:GITHUB_REPOSITORY}.IndexOf('/') + 1))" -Encoding utf8 + - name: Checkout uses: actions/checkout@v4.1.7 with: fetch-depth: 0 - - name: Resolve project name - shell: pwsh - run: Add-Content -Path ${env:GITHUB_ENV} "`nprojectName=$(${env:GITHUB_REPOSITORY}.substring(${env:GITHUB_REPOSITORY}.IndexOf('/') + 1))" -Encoding utf8 - - name: Install GitVersion uses: gittools/actions/gitversion/setup@v3.0.0 with: @@ -42,6 +42,7 @@ jobs: - name: Update project version uses: roryprimrose/set-vs-sdk-project-version@v1.0.6 with: + projectFilter: 'package.props' version: ${{ steps.gitversion.outputs.NuGetVersionV2 }} assemblyVersion: ${{ steps.gitversion.outputs.AssemblySemVer }} fileVersion: ${{ steps.gitversion.outputs.MajorMinorPatch }} @@ -53,7 +54,7 @@ jobs: dotnet-version: '6.0.x' # SDK Version to use. - name: Download snk file - run: echo "${{ secrets.SNK_FILE }}" | base64 --decode > ./Neovolve.Logging.Xunit.Signed/Neovolve.Logging.Xunit.snk + run: echo "${{ secrets.SNK_FILE }}" | base64 --decode > Neovolve.Logging.Xunit.snk - name: Restore run: dotnet restore @@ -107,8 +108,8 @@ jobs: needs: build runs-on: ubuntu-latest # Only run on pushes which should only be on the base repository - if: github.event_name == 'push' && github.actor != 'dependabot[bot]' - + if: (github.event_name == 'push' || github.event_name == 'pull_request') && github.actor != 'dependabot[bot]' + steps: - name: Resolve project name @@ -159,7 +160,7 @@ jobs: needs: build runs-on: ubuntu-latest # Only run on pushes which should only be on the base repository and only where the branch is main or is a version tagged build - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.actor != 'dependabot[bot]' + if: (github.event_name == 'push' || github.event_name == 'pull_request') && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.actor != 'dependabot[bot]' steps: diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..163da95 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..6b34b18 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,3 @@ + + + diff --git a/Neovolve.Logging.Xunit.Signed.UnitTests/Neovolve.Logging.Xunit.Signed.UnitTests.csproj b/Neovolve.Logging.Xunit.Signed.UnitTests/Neovolve.Logging.Xunit.Signed.UnitTests.csproj new file mode 100644 index 0000000..c87c62b --- /dev/null +++ b/Neovolve.Logging.Xunit.Signed.UnitTests/Neovolve.Logging.Xunit.Signed.UnitTests.csproj @@ -0,0 +1,30 @@ + + + + net8.0 + true + ../Neovolve.Logging.Xunit.snk + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Neovolve.Logging.Xunit.Signed/Neovolve.Logging.Xunit.Signed.csproj b/Neovolve.Logging.Xunit.Signed/Neovolve.Logging.Xunit.Signed.csproj index b386b98..e746b30 100644 --- a/Neovolve.Logging.Xunit.Signed/Neovolve.Logging.Xunit.Signed.csproj +++ b/Neovolve.Logging.Xunit.Signed/Neovolve.Logging.Xunit.Signed.csproj @@ -1,15 +1,28 @@ - - + + - netstandard2.0 + netstandard2.0 + true true - Neovolve.Logging.Xunit.snk + ../Neovolve.Logging.Xunit.snk - - - - 2.0 + + + + + + bin\$(Configuration)\$(TargetFramework)\Neovolve.Logging.Xunit.Signed.xml + + + + + + + + + + \ No newline at end of file diff --git a/Neovolve.Logging.Xunit.Signed/snk.ps1 b/Neovolve.Logging.Xunit.Signed/snk.ps1 deleted file mode 100644 index f01e618..0000000 --- a/Neovolve.Logging.Xunit.Signed/snk.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -$file = "Neovolve.Logging.Xunit.snk" -$bytesFromFile = Get-Content $file -Raw -AsByteStream; -$encodedBytes = [System.Convert]::ToBase64String($bytesFromFile); -# Display base 64 string -Write-Output "File: $file converted to base64:"; -Write-Output " "; -Write-Output $encodedBytes; -Write-Output " "; -# Compute and show hash of original file -$fileHashInfo = Get-FileHash $file; -Write-Output "Hash: $($fileHashInfo.Hash)"; \ No newline at end of file diff --git a/Neovolve.Logging.Xunit.UnitTests/CustomFormatter.cs b/Neovolve.Logging.Xunit.UnitTests/CustomFormatter.cs index 5d10601..05ebe20 100644 --- a/Neovolve.Logging.Xunit.UnitTests/CustomFormatter.cs +++ b/Neovolve.Logging.Xunit.UnitTests/CustomFormatter.cs @@ -57,7 +57,7 @@ private static string GetShortLogLevelString(LogLevel level) case LogLevel.Error: return "Error"; case LogLevel.Critical: return "Crit "; case LogLevel.None: return "None "; - default: throw new("invalid"); + default: throw new NotSupportedException("invalid"); } } } diff --git a/Neovolve.Logging.Xunit.UnitTests/Neovolve.Logging.Xunit.UnitTests.csproj b/Neovolve.Logging.Xunit.UnitTests/Neovolve.Logging.Xunit.UnitTests.csproj index 7df1e30..655fd8d 100644 --- a/Neovolve.Logging.Xunit.UnitTests/Neovolve.Logging.Xunit.UnitTests.csproj +++ b/Neovolve.Logging.Xunit.UnitTests/Neovolve.Logging.Xunit.UnitTests.csproj @@ -2,10 +2,6 @@ net8.0 - False - ..\Solution Items\UnitTest.ruleset - latest - enable diff --git a/Neovolve.Logging.Xunit.sln b/Neovolve.Logging.Xunit.sln index 6c5f77a..e4b39e2 100644 --- a/Neovolve.Logging.Xunit.sln +++ b/Neovolve.Logging.Xunit.sln @@ -12,11 +12,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitattributes = .gitattributes .gitignore = .gitignore Solution Items\Application.ruleset = Solution Items\Application.ruleset + compiler.props = compiler.props + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props GitVersion.yml = GitVersion.yml LICENSE = LICENSE NuGet.config = NuGet.config + package.props = package.props + package.targets = package.targets README.md = README.md + snk.ps1 = snk.ps1 Solution Items\UnitTest.ruleset = Solution Items\UnitTest.ruleset EndProjectSection EndProject @@ -30,7 +36,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\ci.yml = .github\workflows\ci.yml EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neovolve.Logging.Xunit.Signed", "Neovolve.Logging.Xunit.Signed\Neovolve.Logging.Xunit.Signed.csproj", "{37008AC1-E442-4B03-8DC2-C57B910FD434}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neovolve.Logging.Xunit.Signed", "Neovolve.Logging.Xunit.Signed\Neovolve.Logging.Xunit.Signed.csproj", "{37008AC1-E442-4B03-8DC2-C57B910FD434}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neovolve.Logging.Xunit.Signed.UnitTests", "Neovolve.Logging.Xunit.Signed.UnitTests\Neovolve.Logging.Xunit.Signed.UnitTests.csproj", "{599135FC-0074-4C3C-99FC-221FB04E2367}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -50,6 +58,10 @@ Global {37008AC1-E442-4B03-8DC2-C57B910FD434}.Debug|Any CPU.Build.0 = Debug|Any CPU {37008AC1-E442-4B03-8DC2-C57B910FD434}.Release|Any CPU.ActiveCfg = Release|Any CPU {37008AC1-E442-4B03-8DC2-C57B910FD434}.Release|Any CPU.Build.0 = Release|Any CPU + {599135FC-0074-4C3C-99FC-221FB04E2367}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {599135FC-0074-4C3C-99FC-221FB04E2367}.Debug|Any CPU.Build.0 = Debug|Any CPU + {599135FC-0074-4C3C-99FC-221FB04E2367}.Release|Any CPU.ActiveCfg = Release|Any CPU + {599135FC-0074-4C3C-99FC-221FB04E2367}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Neovolve.Logging.Xunit/AssemblyInfo.cs b/Neovolve.Logging.Xunit/AssemblyInfo.cs deleted file mode 100644 index 38b3997..0000000 --- a/Neovolve.Logging.Xunit/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Neovolve.Logging.Xunit.UnitTests")] \ No newline at end of file diff --git a/Neovolve.Logging.Xunit/Neovolve.Logging.Xunit.csproj b/Neovolve.Logging.Xunit/Neovolve.Logging.Xunit.csproj index f1bad99..20321f2 100644 --- a/Neovolve.Logging.Xunit/Neovolve.Logging.Xunit.csproj +++ b/Neovolve.Logging.Xunit/Neovolve.Logging.Xunit.csproj @@ -1,33 +1,10 @@ - + - netstandard2.0 - ..\Solution Items\Application.ruleset - latest - enable - True - - ILogger for xUnit - rprimrose - Neovolve - This library provides Microsoft.Extensions.Logging support for Xunit. - Copyright © Neovolve 2018 - true - en-US - https://github.com/roryprimrose/Neovolve.Logging.Xunit - MIT - https://github.com/roryprimrose/Neovolve.Logging.Xunit - xUnit;Logging - 1.0.0-alpha - true - README.md + netstandard2.0 true - - - - bin\$(Configuration)\$(TargetFramework)\Neovolve.Logging.Xunit.xml @@ -38,4 +15,8 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 33f87f7..f88d970 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,13 @@ Neovolve.Logging.Xunit is a NuGet package that returns an `ILogger` or `ILogger` that wraps around the `ITestOutputHelper` supplied by xUnit. xUnit uses this helper to write log messages to the test output of each test execution. This means that any log messages from classes being tested will end up in the xUnit test result output. -[![GitHub license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/roryprimrose/Neovolve.Logging.Xunit/blob/master/LICENSE) [![Nuget](https://img.shields.io/nuget/v/Neovolve.Logging.Xunit.svg) ![Nuget](https://img.shields.io/nuget/dt/Neovolve.Logging.Xunit.svg)](https://www.nuget.org/packages/Neovolve.Logging.Xunit) [![Actions Status](https://github.com/roryprimrose/Neovolve.Logging.Xunit/workflows/CI/badge.svg)](https://github.com/roryprimrose/Neovolve.Logging.Xunit/actions) +[![GitHub license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/roryprimrose/Neovolve.Logging.Xunit/blob/master/LICENSE) [![Actions Status](https://github.com/roryprimrose/Neovolve.Logging.Xunit/workflows/CI/badge.svg)](https://github.com/roryprimrose/Neovolve.Logging.Xunit/actions) + +Neovolve.Logging.Xunit +[![Nuget](https://img.shields.io/nuget/v/Neovolve.Logging.Xunit.svg) ![Nuget](https://img.shields.io/nuget/dt/Neovolve.Logging.Xunit.svg)](https://www.nuget.org/packages/Neovolve.Logging.Xunit) + +Neovolve.Logging.Xunit.Signed +[![Nuget](https://img.shields.io/nuget/v/Neovolve.Logging.Xunit.Signed.svg) ![Nuget](https://img.shields.io/nuget/dt/Neovolve.Logging.Xunit.Signed.svg)](https://www.nuget.org/packages/Neovolve.Logging.Xunit.Signed) - [Installation](#installation) - [Usage](#usage) @@ -19,6 +25,10 @@ Run the following in the NuGet command line or visit the [NuGet package page](ht `Install-Package Neovolve.Logging.Xunit` +If you need a strong named version of this library, run the following in the NuGet command line or visit the [NuGet package page](https://nuget.org/packages/Neovolve.Logging.Xunit.Signed). + +`Install-Package Neovolve.Logging.Xunit.Signed` + [Back to top][0] ## Usage diff --git a/compiler.props b/compiler.props new file mode 100644 index 0000000..ba6e431 --- /dev/null +++ b/compiler.props @@ -0,0 +1,12 @@ + + + ../Solution Items/Application.ruleset + latest + enable + True + + + + $(NoWarn);CA1806;CA1305 + + \ No newline at end of file diff --git a/package.props b/package.props new file mode 100644 index 0000000..12f786e --- /dev/null +++ b/package.props @@ -0,0 +1,19 @@ + + + ILogger for xUnit + rprimrose + Neovolve + This library provides Microsoft.Extensions.Logging support for Xunit. + Copyright © Neovolve 2018 + true + en-US + https://github.com/roryprimrose/Neovolve.Logging.Xunit + MIT + https://github.com/roryprimrose/Neovolve.Logging.Xunit + xUnit;Logging + 1.0.0-alpha + true + README.md + + + \ No newline at end of file diff --git a/package.targets b/package.targets new file mode 100644 index 0000000..e8c204d --- /dev/null +++ b/package.targets @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/snk.ps1 b/snk.ps1 new file mode 100644 index 0000000..d1979af --- /dev/null +++ b/snk.ps1 @@ -0,0 +1,44 @@ +$file = "Neovolve.Logging.Xunit.snk" + +function Get-SnPath { + $possiblePaths = @( + "C:\Program Files\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe", + "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sn.exe", + "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe", + "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Bin\sn.exe" + ) + + foreach ($path in $possiblePaths) { + if (Test-Path $path) { + Write-Host "Found sn.exe at $path" + + return $path + } + } + + throw "sn.exe not found in common installation paths." +} + +$snPath = Get-SnPath + +if (-not (Test-Path $file)) { + + Write-Output "Creating $file"; + & $snPath -k $file +} + +$bytesFromFile = Get-Content $file -Raw -AsByteStream; +$encodedBytes = [System.Convert]::ToBase64String($bytesFromFile); +# Display base 64 string +Write-Output "File: $file converted to base64:"; +Write-Output " "; +Write-Output $encodedBytes; +Write-Output " "; +# Compute and show hash of original file +$fileHashInfo = Get-FileHash $file; +Write-Output "Hash: $($fileHashInfo.Hash)"; + +$tempPath = [System.IO.Path]::GetTempFileName() +& $snPath -p $file $tempPath +& $snPath -tp $tempPath +Remove-Item $tempPath \ No newline at end of file