Skip to content

Commit ea0b3b4

Browse files
authored
Updates target frameworks to .NET 8 and 9 (#905)
* Removes global.json file Removes the global.json file, which is no longer needed. * Updates target frameworks to .NET 8 and 9 Updates the target frameworks for all projects to .NET 8 and .NET 9. This ensures that the libraries and tests are compatible with the latest .NET releases. * Migrates to .slnx solution file format Updates the solution file to the newer .slnx format, which is a simplified XML-based format. This change also updates the project's tooling, CI workflows, and documentation to use the new .slnx solution file. * Allows 429 status codes for link checks Updates the markdown link check configuration to consider 429 status codes as acceptable. This prevents false positives when GitHub's API rate limiting is triggered during the link checking process. * several updates after updating to target .net 8 and 9 * Revert "Migrates to .slnx solution file format" This reverts commit 9aa9304. * Removes obsolete content root configuration Removes the `.UseSolutionRelativeContentRoot` configuration from the `HttpResponseMockingWebApplicationFactory` as it is no longer needed and simplifies the content root configuration. * Updates dependencies to use central package management Migrates to central package management for dependency versioning. This change introduces a `Directory.Packages.props` file to manage package versions centrally, and removes version numbers from `Directory.Build.props` and project files. This ensures consistency across the solution and simplifies dependency updates. Also updates the documentation links to point to the correct tag. * Updates package versions Updates multiple NuGet package versions to their latest stable releases. This ensures that the project benefits from the latest features, bug fixes, and performance improvements provided by these libraries. The updated packages include analyzer and testing libraries.
1 parent fb7b8ab commit ea0b3b4

25 files changed

+139
-130
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ dotnet_diagnostic.CA1303.severity = none # CA1303: Do not pass literals a
9696
dotnet_diagnostic.CA1308.severity = none # CA1308: Normalize strings to uppercase
9797
# Maintainability rules https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/maintainability-warnings
9898
dotnet_diagnostic.CA1508.severity = none # CA1508: Avoid dead conditional code # This one seems to flag false positives in some cases
99+
dotnet_diagnostic.CA1515.severity = none # CA1515: Consider making public types internal # As of writing this there are several open issues about this rule but this one seems to sum the problem https://github.com/dotnet/roslyn-analyzers/issues/7192. Other issues: https://github.com/dotnet/roslyn-analyzers/issues?q=ca1515
99100
# Naming rules https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/naming-warnings
100101
dotnet_diagnostic.CA1711.severity = none # CA1711: Identifiers should not have incorrect suffix
101102
# Reliability rules https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/reliability-warnings
@@ -399,6 +400,7 @@ dotnet_diagnostic.MA0032.severity = warning # MA0032 Use an overload with a Canc
399400
dotnet_diagnostic.MA0048.severity = none # MA0048 File name must match type name
400401
dotnet_diagnostic.MA0076.severity = none # MA0076 Do not use implicit culture-sensitive ToString in interpolated strings
401402
dotnet_diagnostic.MA0101.severity = none # MA0101 String contains an implicit end of line character
403+
dotnet_diagnostic.MA0165.severity = none # MA0165 Make interpolated string. See https://github.com/meziantou/Meziantou.Analyzer/issues/764
402404

403405
##########################################
404406
# Rules for Microsoft.VisualStudio.Threading.Analyzers

.github/markdown-link-check-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
},
3535
"description": "Avoids 403s from GitHub docs"
3636
}
37-
]
37+
],
38+
"aliveStatusCodes": [429, 200]
3839
}

.github/workflows/build-test-package.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ jobs:
4343
uses: actions/setup-dotnet@v4
4444
with:
4545
dotnet-version: |
46-
6.0.x
47-
7.0.x
48-
global-json-file: global.json
46+
8.x
47+
9.x
4948
- name: Cache/Restore NuGets
5049
uses: actions/cache@v4
5150
with:
@@ -73,7 +72,7 @@ jobs:
7372
7473
$testResultsDir = $(Join-Path -Path (Get-Location) -ChildPath "tests/${{ matrix.os }}/test-results")
7574
$testCoverageDir = $(Join-Path -Path (Get-Location) -ChildPath "tests/${{ matrix.os }}/coverage-results/")
76-
$testCoverageFile = $(Join-Path -Path $testCoverageDir -ChildPath "coverage.net8.0.opencover.xml")
75+
$testCoverageFile = $(Join-Path -Path $testCoverageDir -ChildPath "coverage.net9.0.opencover.xml")
7776
Write-Output "test-results-dir=$testResultsDir" >> $env:GITHUB_OUTPUT
7877
Write-Output "test-coverage-dir=$testCoverageDir" >> $env:GITHUB_OUTPUT
7978
Write-Output "test-coverage-file=$testCoverageFile" >> $env:GITHUB_OUTPUT
@@ -85,7 +84,7 @@ jobs:
8584
Write-Output "::endgroup::"
8685
8786
$downloadArtifactMessage = "You can inspect the test results by downloading the workflow artifact named: ${{ env.TEST_RESULTS_ARTIFACT_NAME }}."
88-
$frameworkMonikers = @('net6.0','net7.0','net8.0')
87+
$frameworkMonikers = @('net8.0','net9.0')
8988
foreach($frameworkMoniker in $frameworkMonikers)
9089
{
9190
Write-Output "::group::Running dotnet test for target framework $frameworkMoniker."
@@ -167,27 +166,27 @@ jobs:
167166
#
168167
# By running this step, I make sure the test result filenames are deterministic so that on job reruns I will only get the latest test results on the the artifact with name env.TEST_RESULTS_ARTIFACT_NAME.
169168
# Example:
170-
# As of writing this I have 2 test projects and after running tests I will have one markdown file and one trx file per test project and framework. Let's consider the files for .net7.0:
169+
# As of writing this I have 2 test projects and after running tests I will have one markdown file and one trx file per test project and framework. Let's consider the files for .net9.0:
171170
# - one md and trx file for DotNet.Sdk.Extensions.Tests.csproj and another md and trx file for DotNet.Sdk.Extensions.Testing.Tests.csproj. Which for this example let's assume would be named:
172-
# - framework_net7.0_20230226152259.md
173-
# - framework_net7.0_20230226152312.md
174-
# - framework_net7.0_20230226152259.trx
175-
# - framework_net7.0_20230226152312.trx
171+
# - framework_net9.0_20230226152259.md
172+
# - framework_net9.0_20230226152312.md
173+
# - framework_net9.0_20230226152259.trx
174+
# - framework_net9.0_20230226152312.trx
176175
#
177176
# The filenames contain only the framework and a timestamp. Unfortunately the assembly name is not part of the filename so it's not possible to know which test project the file belongs without viewing its content.
178177
# After renaming we would have the following filenames:
179-
# - framework_net7.0_0.md
180-
# - framework_net7.0_1.md
181-
# - framework_net7.0_0.trx
182-
# - framework_net7.0_1.trx
178+
# - framework_net9.0_0.md
179+
# - framework_net9.0_1.md
180+
# - framework_net9.0_0.trx
181+
# - framework_net9.0_1.trx
183182
#
184183
# This way when re-running the job the test result filenames are deterministic and will always override existing files in the artifact with name env.TEST_RESULTS_ARTIFACT_NAME.
185184
# This does mean that the artifact with name env.TEST_RESULTS_ARTIFACT_NAME will always only contain the test results from the latest run.
186185
#
187186
188187
$testResultsDir = '${{ steps.dotnet-test.outputs.test-results-dir }}'
189188
# rename test result files for all frameworks
190-
$frameworkFilters = @('framework_net6.0*','framework_net7.0*','framework_net8.0*')
189+
$frameworkFilters = @('framework_net8.0*','framework_net9.0*')
191190
foreach($frameworkFilter in $frameworkFilters)
192191
{
193192
# for each framework group the files by extension. There will be .md and .trx file groups

.github/workflows/codeql.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ jobs:
4747
uses: actions/setup-dotnet@v4
4848
with:
4949
dotnet-version: |
50-
6.0.x
51-
7.0.x
52-
global-json-file: global.json
50+
8.x
51+
9.x
5352
- name: Cache/Restore NuGets
5453
uses: actions/cache@v4
5554
with:

.github/workflows/dotnet-format.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ jobs:
3737
uses: actions/setup-dotnet@v4
3838
with:
3939
dotnet-version: |
40-
6.0.x
41-
7.0.x
42-
global-json-file: global.json
40+
8.x
41+
9.x
4342
- name: Cache/Restore NuGets
4443
uses: actions/cache@v4
4544
with:

.github/workflows/upload-coverage-to-codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
if: github.event.workflow_run.event != 'pull_request'
5050
with:
5151
token: ${{ secrets.CODECOV_TOKEN }} # even though it's not required for public repos it helps with intermittent failures caused by https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954, https://github.com/codecov/codecov-action/issues/598,
52-
files: ./coverage.net8.0.opencover.xml
52+
files: ./coverage.net9.0.opencover.xml
5353
fail_ci_if_error: true
5454
verbose: true
5555
override_commit: '${{ github.event.workflow_run.head_sha }}'
@@ -59,7 +59,7 @@ jobs:
5959
if: github.event.workflow_run.event == 'pull_request'
6060
with:
6161
token: ${{ secrets.CODECOV_TOKEN }} # even though it's not required for public repos it helps with intermittent failures caused by https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954, https://github.com/codecov/codecov-action/issues/598,
62-
files: ./coverage.net8.0.opencover.xml
62+
files: ./coverage.net9.0.opencover.xml
6363
fail_ci_if_error: true
6464
verbose: true
6565
override_commit: '${{ github.event.workflow_run.head_sha }}'

Directory.Build.props

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,46 @@
4343
</PropertyGroup>
4444

4545
<ItemGroup>
46-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
46+
<PackageReference Include="Meziantou.Analyzer">
4747
<PrivateAssets>all</PrivateAssets>
4848
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4949
</PackageReference>
50-
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
50+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers">
5151
<PrivateAssets>all</PrivateAssets>
5252
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5353
</PackageReference>
54-
<PackageReference Include="Roslynator.Analyzers" Version="4.12.4">
54+
<PackageReference Include="Roslynator.Analyzers">
5555
<PrivateAssets>all</PrivateAssets>
5656
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5757
</PackageReference>
58-
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.4">
58+
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers">
5959
<PrivateAssets>all</PrivateAssets>
6060
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6161
</PackageReference>
62-
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.12.4">
62+
<PackageReference Include="Roslynator.Formatting.Analyzers">
6363
<PrivateAssets>all</PrivateAssets>
6464
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6565
</PackageReference>
66-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
66+
<PackageReference Include="StyleCop.Analyzers.Unstable">
6767
<PrivateAssets>all</PrivateAssets>
6868
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6969
</PackageReference>
7070
</ItemGroup>
7171

7272
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
73-
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
73+
<PackageReference Include="coverlet.msbuild">
7474
<PrivateAssets>all</PrivateAssets>
7575
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7676
</PackageReference>
77-
<PackageReference Include="NSubstitute" Version="5.1.0" />
78-
<PackageReference Include="Shouldly" Version="4.2.1" />
79-
<PackageReference Include="xunit.analyzers" Version="1.16.0" />
80-
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
81-
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
82-
<PackageReference Include="LiquidTestReports.Custom" Version="1.0.9" />
77+
<PackageReference Include="NSubstitute"/>
78+
<PackageReference Include="Shouldly" />
79+
<PackageReference Include="xunit.analyzers">
80+
<PrivateAssets>all</PrivateAssets>
81+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
82+
</PackageReference>
83+
<PackageReference Include="NSubstitute.Analyzers.CSharp" />
84+
<PackageReference Include="GitHubActionsTestLogger" />
85+
<PackageReference Include="LiquidTestReports.Custom" />
8386
</ItemGroup>
8487

8588
</Project>

Directory.Packages.props

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Enable central package management, https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management -->
4+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
5+
</PropertyGroup>
6+
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
7+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.16" />
8+
</ItemGroup>
9+
<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
10+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.5" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
14+
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.0.1" />
15+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
16+
<PackageVersion Include="xunit" Version="2.9.3" />
17+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.0" />
18+
<PackageVersion Include="System.Reactive" Version="6.0.1" />
19+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
20+
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="9.0.5" />
21+
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
22+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.201" />
23+
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.14.15" />
24+
<PackageVersion Include="Roslynator.Analyzers" Version="4.13.1" />
25+
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.13.1" />
26+
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.13.1" />
27+
<PackageVersion Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" />
28+
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
29+
<PackageVersion Include="NSubstitute" Version="5.3.0" />
30+
<PackageVersion Include="Shouldly" Version="4.2.1" />
31+
<PackageVersion Include="xunit.analyzers" Version="1.21.0" />
32+
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
33+
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
34+
<PackageVersion Include="LiquidTestReports.Custom" Version="1.0.9" />
35+
</ItemGroup>
36+
</Project>

README.md

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

2424
## Description
2525

26-
This repo contains extensions to help build .NET applications, as well as extensions for unit and [integration tests](https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?#introduction-to-integration-tests). It supports applications targeting .NET 6.0 or higher.
26+
This repo contains extensions to help build .NET applications, as well as extensions for unit and [integration tests](https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?#introduction-to-integration-tests). It supports applications targeting .NET 8.0 or higher.
2727

2828
## Installing
2929

docs/dev-notes/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ To run tests via WSL you need to have at least `Visual Studio 2022` and the Linu
5959
6060
- There is a set of NuGet packages that are only applied in test projects by using the condition `"'$(IsTestProject)' == 'true'"`. To make this work the `csproj` for the test projects must have the `<IsTestProject>true</IsTestProject>` property defined. Adding this property manually shouldn't be needed because it should be added by the `Microsoft.NET.Test.Sdk` package however there seems to be an issue with this when running tests outside of Visual Studio. See [this GitHub issue](https://github.com/dotnet/sdk/issues/3790#issuecomment-1100773198) for more info.
6161
62-
- When running `dotnet` CLI commands make sure you are at the root of the repo so that the `global.json` is respected. If you don't you might get unexpected results when building the solution. As explained in [global.json overview](https://learn.microsoft.com/en-us/dotnet/core/tools/global-json):
63-
64-
> The .NET SDK looks for a global.json file in the current working directory (which isn't necessarily the same as the project directory) or one of its parent directories.
65-
6662
## Deterministic Build configuration
6763
6864
Following the guide from [Deterministic Builds](https://github.com/clairernovotny/DeterministicBuilds) the `ContinuousIntegrationBuild` setting on the [Directory.Build.props](/Directory.Build.props) is set to true, if the build is being executed in GitHub actions.

0 commit comments

Comments
 (0)