Skip to content

Commit

Permalink
Use .NET Core 3.0 SDK
Browse files Browse the repository at this point in the history
Use preview 8 of the .NET Core 3.0 SDK.
Swap net451 for net461.
Use Microsoft.NETFramework.ReferenceAssemblies to build on non-Windows platforms.
Remove redundant MSBuildAllProjects properties.
  • Loading branch information
martincostello committed Sep 16, 2019
1 parent 8338a4c commit 01172d8
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 48 deletions.
8 changes: 4 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ else {
}

function DotNetBuild {
param([string]$Project, [string]$Configuration, [string]$Framework)
& $dotnet build $Project --output (Join-Path $OutputPath $Framework) --framework $Framework --configuration $Configuration
param([string]$Project, [string]$Configuration)
& $dotnet build $Project --output $OutputPath --configuration $Configuration
if ($LASTEXITCODE -ne 0) {
throw "dotnet build failed with exit code $LASTEXITCODE"
}
Expand Down Expand Up @@ -131,8 +131,8 @@ $packageProjects = @(

Write-Host "Building $($projects.Count) projects..." -ForegroundColor Green
ForEach ($project in $projects) {
DotNetBuild $project $Configuration "netstandard2.0"
DotNetBuild $project $Configuration "net451"
DotNetBuild $project $Configuration
DotNetBuild $project $Configuration
}

if ($SkipTests -eq $false) {
Expand Down
7 changes: 2 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
<PackageReference Include="coverlet.msbuild" Version="2.6.3" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="ReportGenerator" Version="4.2.19" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)justeat-oss.snk</AssemblyOriginatorKeyFile>
Expand All @@ -23,8 +21,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<LangVersion>latest</LangVersion>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<LangVersion>preview</LangVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageIconUrl>https://avatars3.githubusercontent.com/u/1516790?s=64</PackageIconUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand Down
5 changes: 1 addition & 4 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<!-- disable sourcelink on mono, to workaround https://github.com/dotnet/sourcelink/issues/155 -->
<!-- Disable sourcelink on mono, to workaround https://github.com/dotnet/sourcelink/issues/155 -->
<Target Name="_RemoveMSSourceLinkGitHub" AfterTargets="CollectPackageReferences" Condition=" '$(OS)' != 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">
<ItemGroup>
<PackageReference Remove="Microsoft.SourceLink.GitHub" />
Expand Down
1 change: 0 additions & 1 deletion JustEat.StatsD.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assets", "Assets", "{06BE4D
JustEat.StatsD.ruleset = JustEat.StatsD.ruleset
LICENSE = LICENSE
README.md = README.md
ReferenceAssemblies.props = ReferenceAssemblies.props
version.props = version.props
EndProjectSection
EndProject
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ We use this library within our components to publish [StatsD](http://github.com/

### Supported platforms

`JustEat.Statsd` version 4 is built for these target frameworks:
`JustEat.StatsD` version 4.1.0 is built for these target frameworks:

* `net451`
* `net461`
* `netstandard2.0`
* `netstandard2.1`
* `netcoreapp2.1`
* `netcoreapp2.2`

Expand Down
5 changes: 3 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ if [ "$dotnet_version" != "$CLI_VERSION" ]; then
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version "$CLI_VERSION" --install-dir "$DOTNET_INSTALL_DIR"
fi

dotnet build src/JustEat.StatsD/JustEat.StatsD.csproj --output $artifacts --configuration $configuration || exit 1
dotnet build ./JustEat.StatsD.sln --output $artifacts --configuration $configuration || exit 1
dotnet pack ./src/JustEat.StatsD/JustEat.StatsD.csproj --output $artifacts --configuration $configuration || exit 1

if [ $skipTests == 0 ]; then
dotnet test tests/JustEat.StatsD.Tests/JustEat.StatsD.Tests.csproj --output $artifacts --configuration $configuration --framework "netcoreapp2.2" || exit 1
dotnet test ./tests/JustEat.StatsD.Tests/JustEat.StatsD.Tests.csproj --output $artifacts --configuration $configuration || exit 1
fi
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.401"
"version": "3.0.100-preview8-013656"
}
}
4 changes: 0 additions & 4 deletions src/JustEat.StatsD/Buffered/StatsDUtf8Formatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ internal sealed class StatsDUtf8Formatter
public StatsDUtf8Formatter(string prefix)
{
_utf8Prefix = string.IsNullOrWhiteSpace(prefix) ?
#if NET451
new byte[0] :
#else
Array.Empty<byte>() :
#endif
Encoding.UTF8.GetBytes(prefix + ".");
}

Expand Down
19 changes: 7 additions & 12 deletions src/JustEat.StatsD/JustEat.StatsD.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(MSBuildThisFileDirectory)/../../ReferenceAssemblies.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>A .NET library for publishing metrics to StatsD.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -8,20 +7,16 @@
<PackageId>JustEat.StatsD</PackageId>
<RootNamespace>JustEat.StatsD</RootNamespace>
<Summary>A .NET library for publishing metrics to StatsD.</Summary>
<TargetFrameworks>net451;netstandard2.0;netcoreapp2.1;netcoreapp2.2</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;netcoreapp2.1;netcoreapp2.2</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="System.Runtime" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Memory" Version="4.5.1" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<ItemGroup>
<AdditionalFiles Include="PublicAPI.Shipped.txt" />
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
</ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/JustEat.StatsD/SocketFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@ internal static Socket ForUdp()
{
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

#if !NET451
// See https://github.com/dotnet/corefx/pull/17853#issuecomment-291371266
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
socket.SendBufferSize = 0;
}
#else
socket.SendBufferSize = 0;
#endif

return socket;
}
Expand Down
2 changes: 0 additions & 2 deletions src/JustEat.StatsD/StatsDServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if !NET451
using System;
using JustEat.StatsD.EndpointLookups;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -132,4 +131,3 @@ private static IStatsDTransport ResolveStatsDTransport(IServiceProvider provider
}
}
}
#endif
2 changes: 1 addition & 1 deletion tests/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<NoWarn>$(NoWarn);CA1001;CA1822</NoWarn>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;netcoreapp2.2</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/JustEat.StatsD.Tests/JustEat.StatsD.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<NoWarn>$(NoWarn);CA1707;CA2007</NoWarn>
<RootNamespace>JustEat.StatsD</RootNamespace>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\JustEat.StatsD\JustEat.StatsD.csproj" />
Expand All @@ -11,8 +11,8 @@
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0-preview8.19405.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0-preview-20190808-03" />
<PackageReference Include="Moq" Version="4.13.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 0 additions & 2 deletions tests/JustEat.StatsD.Tests/WhenRegisteringStatsD.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if !NET451
using System;
using JustEat.StatsD.EndpointLookups;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -354,4 +353,3 @@ public void Send(in ArraySegment<byte> metrics)
#pragma warning restore CA1812
}
}
#endif
1 change: 0 additions & 1 deletion version.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<VersionPrefix>4.1.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
Expand Down

0 comments on commit 01172d8

Please sign in to comment.