Skip to content

Commit 0dbe5f7

Browse files
authored
Upgrade to .NET Standard 2.1 & .NET 6 (#135)
* chore: upgrade to .Net Standard 2.1 * chore: build workflow remove unused steps and upgrade actions * chore: remove .Net Standard 2.1 target on Web UI
1 parent 555ac79 commit 0dbe5f7

15 files changed

Lines changed: 93 additions & 242 deletions

File tree

.github/workflows/dotnet-build.yml

Lines changed: 9 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,38 @@
11
name: .NET build
2-
32
on:
43
push:
54
branches: [ master ]
65
pull_request:
76
branches: [ master ]
8-
97
jobs:
108
build:
11-
129
runs-on: ubuntu-latest
1310
steps:
14-
- name: Determine Git Checkout information
15-
id: checkout-info
16-
run: |
17-
if [ $GITHUB_EVENT_NAME == 'pull_request' ]; then
18-
BRANCH_NAME=$(echo ${{ github.event.pull_request.head.ref }})
19-
REPOSITORY_NAME=$(echo ${{ github.event.pull_request.head.repo.full_name }})
20-
else
21-
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
22-
REPOSITORY_NAME=$(echo ${{ github.repository }})
23-
fi
24-
25-
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
26-
echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV
27-
echo "Git checkout information:"
28-
echo "Branch name: $BRANCH_NAME"
29-
echo "Repository name: $REPOSITORY_NAME"
30-
3111
- name: Git Checkout
32-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
3313
with:
3414
ref: ${{github.event.pull_request.head.ref}}
3515
repository: ${{github.event.pull_request.head.repo.full_name}}
36-
37-
- name: Force fetch tags
38-
run: |
39-
# get current repository tags
40-
git fetch --tags --force
41-
42-
# deal with forked repositories
43-
git remote add upstream https://github.com/${{ github.repository }}
44-
git fetch --tags upstream
45-
46-
- name: Find last tag
47-
id: prev-version-tag
48-
run: |
49-
last_tag=$(git tag -l "*[0-9].*[0-9].*[0-9]*" --sort "-version:refname" | head -n 1)
50-
echo "::set-output name=tag::$last_tag"
51-
52-
- name: Find last commit message
53-
id: last-commit-message
54-
run: |
55-
last_commit_message=$(git log -1 --pretty=%s $BRANCH_NAME --)
56-
echo "Last commit message found:"
57-
echo " $last_commit_message"
58-
echo "LAST_COMMIT_MESSAGE=$last_commit_message" >> $GITHUB_ENV
59-
60-
- name: Bump next build version options
61-
id: semvers
62-
uses: "WyriHaximus/github-action-next-semvers@v1.0"
63-
with:
64-
version: ${{ steps.prev-version-tag.outputs.tag }}
65-
66-
- name: Set next build version
67-
id: build-context
68-
env:
69-
MAJOR: ${{steps.semvers.outputs.major}}
70-
MINOR: ${{steps.semvers.outputs.minor}}
71-
PATCH: ${{steps.semvers.outputs.patch}}
72-
CURRENT: ${{steps.prev-version-tag.outputs.tag}}
73-
run: |
74-
echo "::set-output name=current-version::$CURRENT"
75-
76-
if [[ $LAST_COMMIT_MESSAGE =~ ^major:.*$ ]]; then
77-
echo "Bumping to next major version."
78-
NEXT_VERSION="$MAJOR"
79-
elif [[ $LAST_COMMIT_MESSAGE =~ ^feat:.*$ ]]; then
80-
echo "Bumping to next minor version."
81-
NEXT_VERSION="$MINOR"
82-
elif [[ $LAST_COMMIT_MESSAGE =~ ^(fix|ci|refactor|chore):.*$ ]]; then
83-
echo "Bumping to next patch version."
84-
NEXT_VERSION="$PATCH"
85-
else
86-
echo "Skipping version bump."
87-
NEXT_VERSION="$CURRENT"
88-
fi
89-
90-
if [[ $BRANCH_NAME = 'master' ]]; then
91-
echo '::set-output name=context::release'
92-
elif [[ $NEXT_VERSION != $CURRENT ]]; then
93-
NEXT_VERSION="$NEXT_VERSION-beta"
94-
echo '::set-output name=context::beta'
95-
else
96-
echo '::set-output name=context::beta'
97-
fi
98-
99-
echo "::set-output name=next-version::$NEXT_VERSION"
100-
echo "Next version is: $NEXT_VERSION"
101-
echo "BUILD_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
102-
103-
- name: Print build version
104-
run: echo "Build version will be $BUILD_VERSION"
105-
106-
- name: Update project version
107-
uses: roryprimrose/set-vs-sdk-project-version@v1
108-
with:
109-
projectFilter: '*.csproj'
110-
version: ${{ env.BUILD_VERSION }}
111-
assemblyVersion: ${{ env.BUILD_VERSION }}
112-
fileVersion: ${{ env.BUILD_VERSION }}
113-
informationalVersion: ${{ env.BUILD_VERSION }}
114-
11516
- name: Setup .NET
116-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v3
11718
with:
118-
dotnet-version: |
119-
3.1.x
120-
6.0.x
121-
19+
dotnet-version: 6.0.x
20+
dotnet-quality: ga
12221
- name: Setup Report Generator
12322
run: dotnet tool install --global dotnet-reportgenerator-globaltool
124-
12523
- name: MongoDB in GitHub Actions
126-
uses: supercharge/mongodb-github-action@1.6.0
24+
uses: supercharge/mongodb-github-action@1.9.0
12725
with:
12826
mongodb-version: '4.4'
129-
13027
- name: Restore dependencies
13128
run: dotnet restore
132-
13329
- name: Build
13430
run: dotnet build --no-restore -c Release
135-
31+
# Generate code coverage reports, which are recovered by Codacy afterwards.
13632
- name: Test
137-
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory:"../../coverage-outputs" -m:1 -c Release
138-
33+
run: dotnet test --no-build --verbosity normal -m:1 -c Release --collect:"XPlat Code Coverage" --results-directory:"../../coverage-outputs"
13934
- name: Merge coverage results
14035
run: |
141-
reportgenerator -reports:"../../coverage-outputs/**/*.xml" -targetdir:"../../coverage-outputs" -reporttypes:SonarQube
36+
reportgenerator -reports:"../../coverage-outputs/**/*.xml" -targetdir:"../../coverage-outputs" -reporttypes:Cobertura
14237
rm -rfv ../../coverage-outputs/*/
143-
ls -la ../../coverage-outputs
144-
145-
- name: Clean
146-
run: dotnet clean -c Release
147-
148-
- name: Clear Nuget locals
149-
run: dotnet nuget locals all --clear
150-
151-
- name: Delete build tag if exists
152-
uses: dev-drprasad/delete-tag-and-release@v0.2.0
153-
continue-on-error: true
154-
with:
155-
delete_release: false
156-
tag_name: ${{ env.BUILD_VERSION }}
157-
env:
158-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159-
160-
- name: Set build tag
161-
uses: anothrNick/github-tag-action@1.26.0
162-
continue-on-error: true
163-
env:
164-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165-
DEFAULT_BUMP: none
166-
WITH_V: false
167-
CUSTOM_TAG: ${{ env.BUILD_VERSION }}
168-
TAG_CONTEXT: branch
169-
RELEASE_BRANCHES: .*
38+
ls -la ../../coverage-outputs

.github/workflows/dotnet-publish.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ jobs:
2020
- name: Setup .NET
2121
uses: actions/setup-dotnet@v1
2222
with:
23-
dotnet-version: |
24-
3.1.x
25-
6.0.x
23+
dotnet-version: 6.0.x
2624

2725
- name: Set packages authoring information
2826
id: set-packages-authoring-information

samples/Rules.Framework.InMemory.Sample/Rules.Framework.InMemory.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

src/Rules.Framework.Providers.MongoDb/Rules.Framework.Providers.MongoDb.csproj

Lines changed: 2 additions & 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>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<LangVersion>9.0</LangVersion>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<Authors></Authors>
@@ -27,7 +27,7 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Meziantou.Analyzer" Version="1.0.756">
30+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.29">
3131
<PrivateAssets>all</PrivateAssets>
3232
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3333
</PackageReference>

src/Rules.Framework.WebUI/Rules.Framework.WebUI.csproj

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<GenerateDocumentationFile>true</GenerateDocumentationFile>
55
<SignAssembly Condition="'$(OS)'=='Windows_NT'">true</SignAssembly>
6-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
6+
<TargetFrameworks>net6.0</TargetFrameworks>
77
<Authors></Authors>
88
<Version></Version>
99
<PackageVersion></PackageVersion>
@@ -35,14 +35,7 @@
3535
<EmbeddedResource Include="node_modules/rules_list.ico" />
3636
</ItemGroup>
3737

38-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
39-
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
40-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
41-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.9" />
42-
<PackageReference Include="System.Text.Json" Version="6.0.6" />
43-
</ItemGroup>
44-
45-
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
38+
<ItemGroup>
4639
<FrameworkReference Include="Microsoft.AspNetCore.App" />
4740
</ItemGroup>
4841

src/Rules.Framework.WebUI/WebUIMiddleware.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ namespace Rules.Framework.WebUI
1212
using Microsoft.Extensions.Logging;
1313
using Microsoft.Extensions.Options;
1414

15-
#if NETSTANDARD2_0
16-
17-
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
18-
19-
#endif
20-
2115
internal sealed class WebUIMiddleware
2216
{
2317
private readonly IEnumerable<IHttpRequestHandler> httpRequestHandlers;
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<LangVersion>9.0</LangVersion>
6-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7-
<Authors></Authors>
8-
<Version></Version>
9-
<PackageVersion></PackageVersion>
10-
<AssemblyVersion></AssemblyVersion>
11-
<FileVersion></FileVersion>
12-
<InformationalVersion></InformationalVersion>
13-
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
14-
<PackageProjectUrl></PackageProjectUrl>
15-
<RepositoryUrl></RepositoryUrl>
16-
<RepositoryType>Git</RepositoryType>
17-
<PackageTags>rules rulesframework</PackageTags>
18-
<Description>A generic rules framework that allows defining and evaluating rules for complex business scenarios.</Description>
19-
<Copyright></Copyright>
20-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<LangVersion>9.0</LangVersion>
6+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7+
<Authors></Authors>
8+
<Version></Version>
9+
<PackageVersion></PackageVersion>
10+
<AssemblyVersion></AssemblyVersion>
11+
<FileVersion></FileVersion>
12+
<InformationalVersion></InformationalVersion>
13+
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
14+
<PackageProjectUrl></PackageProjectUrl>
15+
<RepositoryUrl></RepositoryUrl>
16+
<RepositoryType>Git</RepositoryType>
17+
<PackageTags>rules rulesframework</PackageTags>
18+
<Description>A generic rules framework that allows defining and evaluating rules for complex business scenarios.</Description>
19+
<Copyright></Copyright>
20+
</PropertyGroup>
2121

22-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
23-
<DebugType>full</DebugType>
24-
<DebugSymbols>true</DebugSymbols>
25-
</PropertyGroup>
22+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
23+
<DebugType>full</DebugType>
24+
<DebugSymbols>true</DebugSymbols>
25+
</PropertyGroup>
2626

27-
<ItemGroup>
28-
<None Include="..\..\LICENSE.md" >
29-
<Pack>True</Pack>
30-
<PackagePath></PackagePath>
31-
</None>
32-
</ItemGroup>
27+
<ItemGroup>
28+
<None Include="..\..\LICENSE.md">
29+
<Pack>True</Pack>
30+
<PackagePath></PackagePath>
31+
</None>
32+
</ItemGroup>
3333

3434

35-
<ItemGroup>
36-
<PackageReference Include="FluentValidation" Version="10.3.6" />
37-
<PackageReference Include="Meziantou.Analyzer" Version="1.0.756">
38-
<PrivateAssets>all</PrivateAssets>
39-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
40-
</PackageReference>
41-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
42-
<PrivateAssets>all</PrivateAssets>
43-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
44-
</PackageReference>
45-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
46-
</ItemGroup>
35+
<ItemGroup>
36+
<PackageReference Include="FluentValidation" Version="10.3.6" />
37+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.29">
38+
<PrivateAssets>all</PrivateAssets>
39+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
40+
</PackageReference>
41+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
42+
<PrivateAssets>all</PrivateAssets>
43+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
44+
</PackageReference>
45+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
46+
</ItemGroup>
4747
</Project>

tests/Rules.Framework.IntegrationTests/Rules.Framework.IntegrationTests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="coverlet.collector" Version="3.1.2">
10+
<PackageReference Include="coverlet.collector" Version="3.2.0">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
14-
<PackageReference Include="FluentAssertions" Version="6.7.0" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
14+
<PackageReference Include="FluentAssertions" Version="6.10.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
1616
<PackageReference Include="xunit" Version="2.4.2" />
1717
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1818
<PrivateAssets>all</PrivateAssets>

tests/Rules.Framework.IntegrationTests/RulesFromJsonFile.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Rules.Framework.IntegrationTests
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Globalization;
56
using System.IO;
67
using System.Linq;
78
using System.Threading.Tasks;
@@ -112,14 +113,14 @@ private IConditionNode<TConditionType> CreateValueConditionNode<TConditionType>(
112113
return conditionNodeBuilder.AsValued(integrationTestsConditionType)
113114
.OfDataType<int>()
114115
.WithComparisonOperator(@operator)
115-
.SetOperand(Convert.ToInt32(conditionNodeDataModel.Operand))
116+
.SetOperand(Convert.ToInt32(conditionNodeDataModel.Operand, CultureInfo.InvariantCulture))
116117
.Build();
117118

118119
case DataTypes.Decimal:
119120
return conditionNodeBuilder.AsValued(integrationTestsConditionType)
120121
.OfDataType<decimal>()
121122
.WithComparisonOperator(@operator)
122-
.SetOperand(Convert.ToDecimal(conditionNodeDataModel.Operand))
123+
.SetOperand(Convert.ToDecimal(conditionNodeDataModel.Operand, CultureInfo.InvariantCulture))
123124
.Build();
124125

125126
case DataTypes.String:
@@ -133,7 +134,7 @@ private IConditionNode<TConditionType> CreateValueConditionNode<TConditionType>(
133134
return conditionNodeBuilder.AsValued(integrationTestsConditionType)
134135
.OfDataType<bool>()
135136
.WithComparisonOperator(@operator)
136-
.SetOperand(Convert.ToBoolean(conditionNodeDataModel.Operand))
137+
.SetOperand(Convert.ToBoolean(conditionNodeDataModel.Operand, CultureInfo.InvariantCulture))
137138
.Build();
138139

139140
default:

0 commit comments

Comments
 (0)