Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated readme to link to signed package #279

Merged
merged 9 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="./compiler.props" />
<Import Project="./package.props" />
</Project>
3 changes: 3 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="./package.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../Neovolve.Logging.Xunit.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ModelBuilder" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="coverlet.msbuild" />
</ItemGroup>

<ItemGroup>
<Compile Include="../Neovolve.Logging.Xunit.UnitTests/**/*.cs" Exclude="../Neovolve.Logging.Xunit.UnitTests/**/obj/**/*.cs;../Neovolve.Logging.Xunit.UnitTests/**/bin/**/*.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Neovolve.Logging.Xunit.Signed\Neovolve.Logging.Xunit.Signed.csproj" />
</ItemGroup>

</Project>
29 changes: 21 additions & 8 deletions Neovolve.Logging.Xunit.Signed/Neovolve.Logging.Xunit.Signed.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<Project ToolsVersion="Current">
<Import Project="..\Neovolve.Logging.Xunit\Neovolve.Logging.Xunit.csproj" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Neovolve.Logging.Xunit.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>../Neovolve.Logging.Xunit.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<PropertyGroup>
<FileUpgradeFlags></FileUpgradeFlags>
<UpgradeBackupLocation></UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<ItemGroup>
<Compile Include="../Neovolve.Logging.Xunit/**/*.cs" Exclude="../Neovolve.Logging.Xunit/**/obj/**/*.cs;../Neovolve.Logging.Xunit/**/bin/**/*.cs" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Neovolve.Logging.Xunit.Signed.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="Xunit.Abstractions" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Neovolve.Logging.Xunit.Signed.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100dd30790ca0897e79e1ece18ca15de9ed79e9ae54164385aef9dee6d9b8f2fd9ec278ce7308b21cd594ae655e6f4954c7fa1972b61ad3f6eee16550fd3f0ee9b5ba848661fb809e7cef7bc5d2ebdc7068eee4e04bc8f91ff5b08c01a932dc4d54a9cc79bce320268bbcc11a6a62587c7da81d7f374030d4ce7d63ec6f7835bfca" />
</ItemGroup>

</Project>
11 changes: 0 additions & 11 deletions Neovolve.Logging.Xunit.Signed/snk.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion Neovolve.Logging.Xunit.UnitTests/CustomFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>False</IsPackable>
<CodeAnalysisRuleSet>..\Solution Items\UnitTest.ruleset</CodeAnalysisRuleSet>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 13 additions & 1 deletion Neovolve.Logging.Xunit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions Neovolve.Logging.Xunit/AssemblyInfo.cs

This file was deleted.

31 changes: 6 additions & 25 deletions Neovolve.Logging.Xunit/Neovolve.Logging.Xunit.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<CodeAnalysisRuleSet>..\Solution Items\Application.ruleset</CodeAnalysisRuleSet>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>

<Title>ILogger for xUnit</Title>
<Authors>rprimrose</Authors>
<Company>Neovolve</Company>
<Description>This library provides Microsoft.Extensions.Logging support for Xunit.</Description>
<Copyright>Copyright © Neovolve 2018</Copyright>
<IncludeSymbols>true</IncludeSymbols>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageProjectUrl>https://github.com/roryprimrose/Neovolve.Logging.Xunit</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/roryprimrose/Neovolve.Logging.Xunit</RepositoryUrl>
<PackageTags>xUnit;Logging</PackageTags>
<Version>1.0.0-alpha</Version>
<IncludeSymbols>true</IncludeSymbols>
<PackageReadmeFile>README.md</PackageReadmeFile>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Neovolve.Logging.Xunit.xml</DocumentationFile>
</PropertyGroup>
Expand All @@ -38,4 +15,8 @@
<PackageReference Include="Xunit.Abstractions" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Neovolve.Logging.Xunit.UnitTests" />
</ItemGroup>

</Project>
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

Neovolve.Logging.Xunit is a NuGet package that returns an `ILogger` or `ILogger<T>` 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)&nbsp;[![Nuget](https://img.shields.io/nuget/v/Neovolve.Logging.Xunit.svg)&nbsp;![Nuget](https://img.shields.io/nuget/dt/Neovolve.Logging.Xunit.svg)](https://www.nuget.org/packages/Neovolve.Logging.Xunit)&nbsp;[![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)&nbsp;[![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)&nbsp;![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)&nbsp;![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)
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions compiler.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<CodeAnalysisRuleSet>../Solution Items/Application.ruleset</CodeAnalysisRuleSet>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('Tests'))">
<NoWarn>$(NoWarn);CA1806;CA1305</NoWarn>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions package.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<Title>ILogger for xUnit</Title>
<Authors>rprimrose</Authors>
<Company>Neovolve</Company>
<Description>This library provides Microsoft.Extensions.Logging support for Xunit.</Description>
<Copyright>Copyright © Neovolve 2018</Copyright>
<IncludeSymbols>true</IncludeSymbols>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageProjectUrl>https://github.com/roryprimrose/Neovolve.Logging.Xunit</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/roryprimrose/Neovolve.Logging.Xunit</RepositoryUrl>
<PackageTags>xUnit;Logging</PackageTags>
<Version>1.0.0-alpha</Version>
<IncludeSymbols>true</IncludeSymbols>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

</Project>
5 changes: 5 additions & 0 deletions package.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
44 changes: 44 additions & 0 deletions snk.ps1
Original file line number Diff line number Diff line change
@@ -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
Loading