Skip to content

Commit

Permalink
Merge pull request #7 from espenekvang/upgrade
Browse files Browse the repository at this point in the history
Upgrade to .NET Standard
  • Loading branch information
nblumhardt authored Nov 29, 2017
2 parents 906deee + d3605ec commit 8c61c8d
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 235 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,6 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/

# Visual Studio 2015/2017 cache/options directory
.vs/
96 changes: 24 additions & 72 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,85 +1,37 @@
param(
[String] $majorMinor = "0.0", # 2.0
[String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
[String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
[Switch] $notouch,
[String] $sln # e.g serilog-sink-name
)
echo "build: Build started"

function Set-AssemblyVersions($informational, $assembly)
{
(Get-Content assets/CommonAssemblyInfo.cs) |
ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } |
Set-Content assets/CommonAssemblyInfo.cs
}

function Install-NuGetPackages($solution)
{
nuget restore $solution
}

function Invoke-MSBuild($solution, $customLogger)
{
if ($customLogger)
{
msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
}
else
{
msbuild "$solution" /verbosity:minimal /p:Configuration=Release
}
}
Push-Location $PSScriptRoot

function Invoke-NuGetPackProj($csproj)
{
nuget pack -Prop Configuration=Release -Symbols $csproj
if(Test-Path .\artifacts) {
echo "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

function Invoke-NuGetPackSpec($nuspec, $version)
{
nuget pack $nuspec -Version $version -OutputDirectory ..\..\
}
& dotnet restore --no-cache

function Invoke-NuGetPack($version)
{
ls src/**/*.csproj |
Where-Object { -not ($_.Name -like "*net40*") } |
ForEach-Object { Invoke-NuGetPackProj $_ }
}
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

function Invoke-Build($majorMinor, $patch, $customLogger, $notouch, $sln)
{
$package="$majorMinor.$patch"
$slnfile = "$sln.sln"
echo "build: Package version suffix is $suffix"
echo "build: Build version suffix is $buildSuffix"

Write-Output "$sln $package"
foreach ($src in ls src/*) {
Push-Location $src

if (-not $notouch)
{
$assembly = "$majorMinor.0.0"
echo "build: Packaging project in $src"

Write-Output "Assembly version will be set to $assembly"
Set-AssemblyVersions $package $assembly
& dotnet build -c Release --version-suffix=$buildSuffix
if ($suffix) {
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
& dotnet pack -c Release --include-source -o ..\..\artifacts --no-build
}
if($LASTEXITCODE -ne 0) { exit 1 }

Install-NuGetPackages $slnfile

Invoke-MSBuild $slnfile $customLogger

Invoke-NuGetPack $package
}

$ErrorActionPreference = "Stop"

if (-not $sln)
{
$slnfull = ls *.sln |
Where-Object { -not ($_.Name -like "*net40*") } |
Select -first 1

$sln = $slnfull.BaseName
Pop-Location
}

Invoke-Build $majorMinor $patch $customLogger $notouch $sln
Pop-Location
25 changes: 25 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
configuration: Release
install:
- ps: mkdir -Force ".\build\" | Out-Null
build_script:
- ps: ./Build.ps1
test: off
artifacts:
- path: artifacts/Serilog.*.nupkg
deploy:
- provider: NuGet
api_key:
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
skip_symbols: true
on:
branch: /^(master|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
tag: v$(appveyor_build_version)
on:
branch: master
5 changes: 0 additions & 5 deletions assets/CommonAssemblyInfo.cs

This file was deleted.

17 changes: 10 additions & 7 deletions serilog-sinks-azureeventhub.sln
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.AzureEventHub", "src\Serilog.Sinks.AzureEventHub\Serilog.Sinks.AzureEventHub.csproj", "{F779C831-866F-4B87-B733-1BD1DB1E1606}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.AzureEventHub", "src\Serilog.Sinks.AzureEventHub\Serilog.Sinks.AzureEventHub.csproj", "{4F30F48A-E294-456B-810F-E6D5B0191421}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F779C831-866F-4B87-B733-1BD1DB1E1606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F779C831-866F-4B87-B733-1BD1DB1E1606}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F779C831-866F-4B87-B733-1BD1DB1E1606}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F779C831-866F-4B87-B733-1BD1DB1E1606}.Release|Any CPU.Build.0 = Release|Any CPU
{4F30F48A-E294-456B-810F-E6D5B0191421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F30F48A-E294-456B-810F-E6D5B0191421}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F30F48A-E294-456B-810F-E6D5B0191421}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F30F48A-E294-456B-810F-E6D5B0191421}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E0B607D3-51F2-4422-AD79-617F980AE0F1}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.ServiceBus.Messaging;
using Microsoft.Azure.EventHubs;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
Expand Down Expand Up @@ -153,7 +153,12 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");

var client = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);
var connectionstringBuilder = new EventHubsConnectionStringBuilder(connectionString)
{
EntityPath = eventHubName
};

var client = EventHubClient.CreateFromConnectionString(connectionstringBuilder.ToString());

return AzureEventHub(loggerConfiguration, client, outputTemplate, formatProvider, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit);
}
Expand Down Expand Up @@ -190,7 +195,11 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");

var client = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);
var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString)
{
EntityPath = eventHubName
};
var client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());

return AzureEventHub(loggerConfiguration, formatter, client, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit);
}
Expand Down
12 changes: 0 additions & 12 deletions src/Serilog.Sinks.AzureEventHub/Properties/AssemblyInfo.cs

This file was deleted.

127 changes: 32 additions & 95 deletions src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj
Original file line number Diff line number Diff line change
@@ -1,95 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F779C831-866F-4B87-B733-1BD1DB1E1606}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Serilog</RootNamespace>
<AssemblyName>Serilog.Sinks.AzureEventHub</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Serilog.Sinks.AzureEventHub.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\assets\Serilog.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\WindowsAzure.ServiceBus.3.4.0\lib\net45-full\Microsoft.ServiceBus.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.1\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.2.3.0\lib\net45\Serilog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Serilog.Sinks.PeriodicBatching, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\..\packages\Serilog.Sinks.PeriodicBatching.2.0.1\lib\net45\Serilog.Sinks.PeriodicBatching.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\assets\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="LoggerConfigurationAzureEventHubExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sinks\AzureEventHub\AzureEventHubBatchingSink.cs" />
<Compile Include="Sinks\AzureEventHub\AzureEventHubSink.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\assets\Serilog.snk">
<Link>Serilog.snk</Link>
</None>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Serilog.Sinks.AzureEventHub.nuspec">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Write Serilog events to Azure Event Hub</Description>
<VersionPrefix>4.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Serilog.Sinks.AzureEventHub</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.AzureEventHub</PackageId>
<PackageTags>serilog;;azure;eventhub</PackageTags>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<RootNamespace>Serilog</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Don't reference the full NETStandard.Library -->
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.EventHubs" Version="1.0.3" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="2.0.0" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
</ItemGroup>

</Project>
Loading

0 comments on commit 8c61c8d

Please sign in to comment.