Skip to content

Commit 6bba8f3

Browse files
authored
Merge pull request #25 from lankaapura/dev
Add .NET core support via Windows Compatibility Pack
2 parents 0358c4d + 5fe7a94 commit 6bba8f3

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

appveyor.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
version: '{build}'
22
skip_tags: true
3-
image: Visual Studio 2015
3+
image: Visual Studio 2017
44
configuration: Release
55
install:
6-
- ps: mkdir -Force ".\build\" | Out-Null
7-
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
8-
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
9-
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.1'
10-
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
6+
- ps: mkdir -Force ".\build\" | Out-Null
117
build_script:
128
- ps: ./Build.ps1
139
test: off
@@ -27,4 +23,3 @@ deploy:
2723
tag: v$(appveyor_build_version)
2824
on:
2925
branch: master
30-

sample/Sample/Sample.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net452</TargetFramework>
4+
<TargetFrameworks>net452;net461;netcoreapp2.0;</TargetFrameworks>
55
<AssemblyName>Sample</AssemblyName>
66
<OutputType>Exe</OutputType>
77
<PackageId>Sample</PackageId>
@@ -19,5 +19,4 @@
1919
<Reference Include="System" />
2020
<Reference Include="Microsoft.CSharp" />
2121
</ItemGroup>
22-
2322
</Project>

src/Serilog.Sinks.EventLog/LoggerConfigurationEventLogExtensions.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
using Serilog.Sinks.EventLog;
2020
using Serilog.Formatting;
2121

22+
#if NETSTANDARD2_0
23+
using System.Runtime.InteropServices;
24+
#endif
25+
2226
namespace Serilog
2327
{
2428
/// <summary>
@@ -53,8 +57,19 @@ public static LoggerConfiguration EventLog(
5357
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
5458
IEventIdProvider eventIdProvider = null)
5559
{
56-
if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
60+
if (loggerConfiguration == null)
61+
{
62+
throw new ArgumentNullException(nameof(loggerConfiguration));
63+
}
5764

65+
66+
#if NETSTANDARD2_0
67+
// Verify the code is running on Windows.
68+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
69+
{
70+
throw new PlatformNotSupportedException(RuntimeInformation.OSDescription);
71+
}
72+
#endif
5873
var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
5974

6075
if (eventIdProvider == null)

src/Serilog.Sinks.EventLog/Serilog.Sinks.EventLog.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en-US</NeutralLanguage>
88
<VersionPrefix>3.1.0</VersionPrefix>
99
<Authors>Jeremy Clarke;Fabian Wetzel</Authors>
10-
<TargetFramework>net45</TargetFramework>
10+
<TargetFrameworks>net45;netstandard2.0;</TargetFrameworks>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1212
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1313
<AssemblyName>Serilog.Sinks.EventLog</AssemblyName>
@@ -28,9 +28,14 @@
2828
<PackageReference Include="Serilog" Version="2.3.0" />
2929
</ItemGroup>
3030

31+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
32+
<PackageReference Include="System.Diagnostics.EventLog">
33+
<Version>4.5.0-preview1-25914-04</Version>
34+
</PackageReference>
35+
</ItemGroup>
36+
3137
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
3238
<Reference Include="System" />
3339
<Reference Include="Microsoft.CSharp" />
3440
</ItemGroup>
35-
3641
</Project>

test/Serilog.Sinks.EventLog.Tests/Serilog.Sinks.EventLog.Tests.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net451</TargetFramework>
4+
<TargetFrameworks>net451;net461;netcoreapp2.0;</TargetFrameworks>
55
<AssemblyName>Serilog.Sinks.EventLog.Tests</AssemblyName>
66
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
77
<SignAssembly>true</SignAssembly>
@@ -21,22 +21,22 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
25-
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0-alpha1" />
24+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
25+
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
2626
<PackageReference Include="Serilog" Version="2.3.0" />
2727
<PackageReference Include="Serilog.Settings.Configuration" Version="2.3.1" />
2828
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="1.0.0" />
2929
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
30-
<PackageReference Include="NUnit" Version="3.5.0" />
31-
</ItemGroup>
32-
33-
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
34-
<Reference Include="System" />
35-
<Reference Include="Microsoft.CSharp" />
30+
<PackageReference Include="NUnit" Version="3.9.0" />
3631
</ItemGroup>
3732

3833
<ItemGroup>
3934
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
4035
</ItemGroup>
4136

37+
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
38+
<Reference Include="System" />
39+
<Reference Include="Microsoft.CSharp" />
40+
</ItemGroup>
41+
4242
</Project>

0 commit comments

Comments
 (0)