Skip to content

Commit

Permalink
Introduced NLog.Extensions.Hosting credits @bryan5989
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepReaper authored and snakefoot committed Sep 2, 2018
1 parent c5a81f5 commit 6971370
Show file tree
Hide file tree
Showing 31 changed files with 3,474 additions and 50 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ install:

# Restore dependencies
- dotnet restore src/NLog.Extensions.Logging
- dotnet restore test
- dotnet restore src/NLog.Extensions.Hosting
- dotnet restore test/NLog.Extensions.Hosting.Tests
- dotnet restore test/NLog.Extensions.Logging.Tests

script:
# Run tests
- dotnet test test --configuration Release --framework netcoreapp2.0
- dotnet test test/NLog.Extensions.Hosting.Tests --configuration Release --framework netcoreapp2.0
- dotnet test test/NLog.Extensions.Logging.Tests --configuration Release --framework netcoreapp2.0
49 changes: 35 additions & 14 deletions NLog.Extensions.Logging.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,61 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C21FD102-21B
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BD106966-02BE-4137-B9DC-4ECE56B4C204}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Extensions.Logging", "src\NLog.Extensions.Logging\NLog.Extensions.Logging.csproj", "{5BB808CD-F633-47C7-98B0-79B2A9BAE24A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Extensions.Logging.Tests", "test\NLog.Extensions.Logging.Tests.csproj", "{7D396A98-C026-4C20-8F5E-2EA76A14CA7D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Extensions.Logging", "src\NLog.Extensions.Logging\NLog.Extensions.Logging.csproj", "{6A236D76-C9D9-4B1D-8DDE-F6978D110288}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{FBD2E07B-F25B-4D2F-AEF6-6D1E10F1E523}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleExample", "Examples\NetCore2\ConsoleExample\ConsoleExample.csproj", "{CF2D8DDE-5876-4EF0-B99D-3C536E887E18}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleExample", "Examples\NetCore2\ConsoleExample\ConsoleExample.csproj", "{CF2D8DDE-5876-4EF0-B99D-3C536E887E18}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Extensions.Hosting", "src\NLog.Extensions.Hosting\NLog.Extensions.Hosting.csproj", "{548E65CE-0378-4812-AE00-B173F1251D3C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Extensions.Hosting.Tests", "test\NLog.Extensions.Hosting.Tests\NLog.Extensions.Hosting.Tests.csproj", "{0DC000BA-2DF8-48E5-A7BC-D76CB9D3FC61}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Extensions.Logging.Tests", "test\NLog.Extensions.Logging.Tests\NLog.Extensions.Logging.Tests.csproj", "{DC42BF57-6316-4FCA-AD33-48FFDAFB4712}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostingExample", "examples\NetCore2\HostingExample\HostingExample.csproj", "{07D358DF-D77A-434B-B034-95785DF7106F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5BB808CD-F633-47C7-98B0-79B2A9BAE24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BB808CD-F633-47C7-98B0-79B2A9BAE24A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BB808CD-F633-47C7-98B0-79B2A9BAE24A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BB808CD-F633-47C7-98B0-79B2A9BAE24A}.Release|Any CPU.Build.0 = Release|Any CPU
{7D396A98-C026-4C20-8F5E-2EA76A14CA7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D396A98-C026-4C20-8F5E-2EA76A14CA7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D396A98-C026-4C20-8F5E-2EA76A14CA7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D396A98-C026-4C20-8F5E-2EA76A14CA7D}.Release|Any CPU.Build.0 = Release|Any CPU
{6A236D76-C9D9-4B1D-8DDE-F6978D110288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A236D76-C9D9-4B1D-8DDE-F6978D110288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A236D76-C9D9-4B1D-8DDE-F6978D110288}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A236D76-C9D9-4B1D-8DDE-F6978D110288}.Release|Any CPU.Build.0 = Release|Any CPU
{CF2D8DDE-5876-4EF0-B99D-3C536E887E18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF2D8DDE-5876-4EF0-B99D-3C536E887E18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF2D8DDE-5876-4EF0-B99D-3C536E887E18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF2D8DDE-5876-4EF0-B99D-3C536E887E18}.Release|Any CPU.Build.0 = Release|Any CPU
{548E65CE-0378-4812-AE00-B173F1251D3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{548E65CE-0378-4812-AE00-B173F1251D3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{548E65CE-0378-4812-AE00-B173F1251D3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{548E65CE-0378-4812-AE00-B173F1251D3C}.Release|Any CPU.Build.0 = Release|Any CPU
{0DC000BA-2DF8-48E5-A7BC-D76CB9D3FC61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DC000BA-2DF8-48E5-A7BC-D76CB9D3FC61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DC000BA-2DF8-48E5-A7BC-D76CB9D3FC61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DC000BA-2DF8-48E5-A7BC-D76CB9D3FC61}.Release|Any CPU.Build.0 = Release|Any CPU
{DC42BF57-6316-4FCA-AD33-48FFDAFB4712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC42BF57-6316-4FCA-AD33-48FFDAFB4712}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC42BF57-6316-4FCA-AD33-48FFDAFB4712}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC42BF57-6316-4FCA-AD33-48FFDAFB4712}.Release|Any CPU.Build.0 = Release|Any CPU
{07D358DF-D77A-434B-B034-95785DF7106F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07D358DF-D77A-434B-B034-95785DF7106F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07D358DF-D77A-434B-B034-95785DF7106F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07D358DF-D77A-434B-B034-95785DF7106F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5BB808CD-F633-47C7-98B0-79B2A9BAE24A} = {C21FD102-21B1-46DB-AD62-86692558AD01}
{7D396A98-C026-4C20-8F5E-2EA76A14CA7D} = {FBD2E07B-F25B-4D2F-AEF6-6D1E10F1E523}
{6A236D76-C9D9-4B1D-8DDE-F6978D110288} = {C21FD102-21B1-46DB-AD62-86692558AD01}
{CF2D8DDE-5876-4EF0-B99D-3C536E887E18} = {BD106966-02BE-4137-B9DC-4ECE56B4C204}
{548E65CE-0378-4812-AE00-B173F1251D3C} = {C21FD102-21B1-46DB-AD62-86692558AD01}
{0DC000BA-2DF8-48E5-A7BC-D76CB9D3FC61} = {FBD2E07B-F25B-4D2F-AEF6-6D1E10F1E523}
{DC42BF57-6316-4FCA-AD33-48FFDAFB4712} = {FBD2E07B-F25B-4D2F-AEF6-6D1E10F1E523}
{07D358DF-D77A-434B-B034-95785DF7106F} = {BD106966-02BE-4137-B9DC-4ECE56B4C204}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46DF0C22-7B6A-4A64-BC63-7B2F6A14F334}
Expand Down
8 changes: 6 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ install:

build_script:
- ps: .\build.ps1

nuget:
disable_publish_on_pr: true

artifacts:
- path: 'artifacts\*.nupkg'

test_script:
- nuget.exe install OpenCover -ExcludeVersion -DependencyVersion Ignore
- OpenCover\tools\OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp1.1" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp2.0" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp1.1 NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp2.0 NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp2.0 NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- pip install codecov
- codecov -f "coverage.xml"
- ps: .\run-sonar.ps1
Expand Down
14 changes: 13 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ $versionProduct = $versionPrefix;
if (-Not $versionSuffix.Equals(""))
{ $versionProduct = $versionProduct + "-" + $versionSuffix }

msbuild /t:Restore,Pack .\src\NLog.Extensions.Logging\ /p:targetFrameworks='"net451;net461;netstandard1.3;netstandard1.5;netstandard2.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:PackageOutputPath=..\..\artifacts /verbosity:minimal
dotnet restore .\src\NLog.Extensions.Logging\
if (-Not $LastExitCode -eq 0)
{ exit $LastExitCode }

dotnet restore .\src\NLog.Extensions.Hosting\
if (-Not $LastExitCode -eq 0)
{ exit $LastExitCode }

msbuild /t:Pack .\src\NLog.Extensions.Logging\ /p:targetFrameworks='"net451;net461;netstandard1.3;netstandard1.5;netstandard2.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:PackageOutputPath=..\..\artifacts /verbosity:minimal
if (-Not $LastExitCode -eq 0)
{ exit $LastExitCode }

msbuild /t:Pack .\src\NLog.Extensions.Hosting\ /p:targetFrameworks='"netstandard2.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:PackageOutputPath=..\..\artifacts /verbosity:minimal
if (-Not $LastExitCode -eq 0)
{ exit $LastExitCode }

Expand Down
5 changes: 3 additions & 2 deletions examples/NetCore2/ConsoleExample/ConsoleExample.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions examples/NetCore2/ConsoleExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class Program
{
static void Main(string[] args)
{
var logger = NLog.LogManager.LoadConfiguration("nlog.config").GetCurrentClassLogger();
var logger = NLog.LogManager.GetCurrentClassLogger();
try
{
using (var servicesProvider = BuildDi())
var servicesProvider = BuildDi();
using (servicesProvider as IDisposable)
{
var runner = servicesProvider.GetRequiredService<Runner>();
runner.DoAction("Action1");
Expand All @@ -35,7 +36,7 @@ static void Main(string[] args)
}


private static ServiceProvider BuildDi()
private static IServiceProvider BuildDi()
{
var services = new ServiceCollection();

Expand Down
26 changes: 26 additions & 0 deletions examples/NetCore2/HostingExample/HostingExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\NLog.Extensions.Hosting\NLog.Extensions.Hosting.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading

0 comments on commit 6971370

Please sign in to comment.