Skip to content

Commit

Permalink
Upgrade to .NET Core 3.1 (#201)
Browse files Browse the repository at this point in the history
* Augurk compiles against .NET Core 3.1

* Fix unit tests

* Fix integration tests

* Fix startup logic

* Upgrade pipeline for .NET Core 3.1

* Do not use deprecated tasks

* Switch to GitVersion task

* Attempt to fix pipeline

* Swap tasks around

* Update spec project

* Apply workaround for build

* Let's see what happens now

* Let's see if this fixes the Docker build

* Try to set environment variable at the highest level

* Attempt to fix publishing

* Switched to jsdelivr to be more reliable

* Fix issue with Swagger
  • Loading branch information
Jonathan Mezach committed Apr 23, 2020
1 parent bbc56bd commit cf8054e
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 158 deletions.
10 changes: 5 additions & 5 deletions .editorconfig
Expand Up @@ -68,10 +68,10 @@ end_of_line = lf
[*.{cs,csx,cake,vb}]
# "this." and "Me." qualifiers
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#this_and_me
dotnet_style_qualification_for_field = true:warning
dotnet_style_qualification_for_property = true:warning
dotnet_style_qualification_for_method = true:warning
dotnet_style_qualification_for_event = true:warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
# Language keywords instead of framework type names for type references
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language_keywords
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
Expand Down Expand Up @@ -148,7 +148,7 @@ csharp_prefer_braces = true:warning
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#usings
dotnet_sort_system_directives_first = true
# Using statement placement (Undocumented)
csharp_using_directive_placement = inside_namespace:warning
csharp_using_directive_placement = outside_namespace:warning
# C# formatting settings
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#c-formatting-settings
csharp_new_line_before_open_brace = all
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Augurk/bin/Debug/netcoreapp2.2/Augurk.dll",
"program": "${workspaceFolder}/src/Augurk/bin/Debug/netcoreapp3.1/Augurk.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Augurk",
"stopAtEntry": false,
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
@@ -1,6 +1,7 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
ARG Version
ARG InformationalVersion
ENV MSBUILDSINGLELOADCONTEXT 1
WORKDIR /app

# copy external library
Expand All @@ -15,7 +16,7 @@ RUN dotnet restore
# copy everything else and build app
COPY src/. ./
WORKDIR /app
RUN dotnet publish /p:Version=$Version /p:InformationalVersion=$InformationalVersion -c Release -o out
RUN dotnet publish /p:Version=$Version /p:InformationalVersion=$InformationalVersion -c Release -p:PublishDir=./out

# build unit test stage
FROM build AS unit-tests
Expand All @@ -28,7 +29,7 @@ WORKDIR /app/Augurk.IntegrationTest
ENTRYPOINT [ "dotnet", "test", "--logger:trx" ]

# build output image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app
COPY --from=build /app/Augurk/out ./
ENTRYPOINT ["dotnet", "Augurk.dll"]
34 changes: 19 additions & 15 deletions azure-pipelines.yml
Expand Up @@ -7,22 +7,23 @@
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core?view=vsts
variables:
buildConfiguration: 'Release'
MSBUILDSINGLELOADCONTEXT: 1

jobs:
- job: netcore
displayName: .NET Core Framework Dependent
pool:
vmImage: ubuntu-16.04
steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.2.300'
- task: UseGitVersion@5
displayName: Set version
inputs:
version: 2.2.300
versionSpec: '5.x'

- script: |
dotnet tool install --global GitVersion.Tool --version 4.0.1-beta1-50
dotnet-gitversion /output buildserver
displayName: Set version
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.201'
inputs:
version: 3.1.201

- task: DotNetCoreCLI@2
inputs:
Expand All @@ -32,12 +33,12 @@ jobs:
displayName: dotnet restore

- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
workingDirectory: 'src'
configuration: $(buildConfiguration)
arguments: '/p:Version=$(GitVersion.MajorMinorPatch) /p:InformationalVersion=$(GitVersion.InformationalVersion)'
displayName: dotnet build

- task: DotNetCoreCLI@2
inputs:
Expand Down Expand Up @@ -86,18 +87,21 @@ jobs:
pool:
vmImage: ubuntu-16.04
steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.2.300'
inputs:
version: 2.2.300
- script: |
dotnet tool install --global GitVersion.Tool --version 4.0.1-beta1-50
dotnet-gitversion /output buildserver
- task: UseGitVersion@5
displayName: Set version
inputs:
versionSpec: '5.x'

- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.201'
inputs:
version: 3.1.201

- script: |
echo '##vso[task.setvariable variable=prerelease]-preview'
displayName: Set prerelease tag
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
- script: |
echo '##vso[task.setvariable variable=prerelease]'
displayName: Set empty prerelease tag
Expand Down
13 changes: 8 additions & 5 deletions src/Augurk.IntegrationTest/Augurk.IntegrationTest.csproj
@@ -1,20 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Alba" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
<PackageReference Include="RavenDB.TestDriver" Version="4.2.0" />
<PackageReference Include="Alba" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
<PackageReference Include="RavenDB.TestDriver" Version="4.2.102" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions src/Augurk.Specifications/Augurk.Specifications.csproj
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="SpecFlow" Version="3.0.213" />
<PackageReference Include="SpecFlow.MsTest" Version="3.0.213" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.0.213" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="SpecFlow" Version="3.1.97" />
<PackageReference Include="SpecFlow.MsTest" Version="3.1.97" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.97" />
</ItemGroup>

</Project>
15 changes: 7 additions & 8 deletions src/Augurk.Test/Augurk.Test.csproj
@@ -1,24 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PackageReference Include="coverlet.collector" Version="1.2.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
<PackageReference Include="NSubstitute" Version="4.2.0" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.9" />
<PackageReference Include="RavenDb.TestDriver" Version="4.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.13" />
<PackageReference Include="RavenDb.TestDriver" Version="4.2.102" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Augurk.Test/Managers/FeatureManagerTests.cs
Expand Up @@ -367,7 +367,7 @@ public async Task CanInsertNewFeature()

using (var session = documentStoreProvider.Store.OpenAsyncSession())
{
var dbFeature = session.LoadAsync<DbFeature>(result.GetIdentifier());
var dbFeature = await session.LoadAsync<DbFeature>(result.GetIdentifier());
dbFeature.ShouldNotBeNull();
}
}
Expand Down Expand Up @@ -442,7 +442,7 @@ public async Task CanUpdateExistingFeature()

using (var session = documentStoreProvider.Store.OpenAsyncSession())
{
var dbFeature = session.LoadAsync<DbFeature>(result.GetIdentifier());
var dbFeature = await session.LoadAsync<DbFeature>(result.GetIdentifier());
dbFeature.ShouldNotBeNull();
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/Augurk/Augurk.csproj
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
</PropertyGroup>

<ItemGroup>
Expand All @@ -18,14 +18,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.48" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.1.1" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.76" />
<PackageReference Include="NuGet.Versioning" Version="4.8.0" />
<PackageReference Include="RavenDB.Embedded" Version="4.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="RavenDB.Embedded" Version="4.2.102" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.3" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Augurk/DataAccess/DocumentStoreProvider.cs
Expand Up @@ -19,6 +19,7 @@
using Augurk.Api;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using Raven.Client.Documents;
using Raven.Client.Documents.Conventions;
using Raven.Client.Documents.Indexes;
Expand All @@ -35,7 +36,7 @@ public class DocumentStoreProvider : IDocumentStoreProvider
/// <summary>
/// Default constructor for this class.
/// </summary>
public DocumentStoreProvider(IHostingEnvironment environment, ILogger<DocumentStoreProvider> logger)
public DocumentStoreProvider(IWebHostEnvironment environment, ILogger<DocumentStoreProvider> logger)
{
// Build the options for the server
string dotNetCoreVersion = EnvironmentUtils.GetNetCoreVersion();
Expand Down
55 changes: 0 additions & 55 deletions src/Augurk/Formatters/TextMediaTypeFormatter.cs

This file was deleted.

14 changes: 8 additions & 6 deletions src/Augurk/Program.cs
Expand Up @@ -13,21 +13,23 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Augurk
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

0 comments on commit cf8054e

Please sign in to comment.