From df2940d172ad7b3d2dee859fa9dbe3572fca5d0a Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Sep 2024 01:00:07 +0900 Subject: [PATCH] feat: add .NET 9 support (And drop .NET 6 support) --- .github/actions/build/action.yml | 2 +- .github/workflows/ci.yml | 6 ++--- .github/workflows/nightly.yml | 5 ----- Directory.Build.props | 2 +- Directory.Packages.props | 16 +------------- docs/docs/dotnet-api-docs.md | 2 +- docs/index.md | 2 +- ...pe_of_documentation_with_custom_plug-in.md | 2 +- samples/extensions/build/build.csproj | 2 +- .../Project.Core/BuildFromProject.Core.csproj | 2 +- .../project/Project/BuildFromProject.csproj | 2 +- .../CatLibrary.Core/CatLibrary.Core.csproj | 4 ++-- .../solution/CatLibrary/CatLibrary.csproj | 2 +- src/Docfx.Dotnet/Docfx.Dotnet.csproj | 5 ----- src/Docfx.Dotnet/DotnetApiCatalog.cs | 22 ------------------- src/docfx/docfx.csproj | 2 +- .../CatLibrary.CatException-1.verified.md | 1 - .../multi-frameworks-test.csproj.sample.1 | 4 ++-- test/docfx.Tests/Assets/ref.csproj.sample.1 | 4 ++-- .../Assets/template/plugins/plugins.csproj | 4 ++-- test/docfx.Tests/Assets/test.csproj.sample.1 | 4 ++-- test/docfx.Tests/Assets/test.vbproj.sample.1 | 2 +- test/docfx.Tests/MetadataCommandTest.cs | 2 +- 23 files changed, 26 insertions(+), 73 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index f8cb2d25c96..b01201d575e 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -10,7 +10,7 @@ runs: - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.x + 9.x - run: npm install shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1be8953f9cb..e949fc2d4a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,9 +34,9 @@ jobs: - run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" id: test-net80 - - run: dotnet test -c Release -f net6.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" + - run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" if: matrix.os == 'ubuntu-latest' - id: test-net60 + id: test-net90 - run: npm i -g @percy/cli if: matrix.os == 'ubuntu-latest' @@ -74,7 +74,7 @@ jobs: path: /tmp/coredump* - name: Report failed tests - if: ${{ failure() && (steps.test-net80.outcome == 'failure' || steps.test-net60.outcome == 'failure') }} + if: ${{ failure() && (steps.test-net80.outcome == 'failure' || steps.test-net90.outcome == 'failure') }} uses: ./.github/actions/report-failed-tests publish-docs: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 727c9c9464c..6ba3f724aba 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,11 +13,6 @@ jobs: permissions: packages: write steps: - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 9.x - - uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/Directory.Build.props b/Directory.Build.props index 46f3e4a1dc1..5dd3cbb2875 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ true - net6.0;net8.0 + net8.0;net9.0 net8.0;net9.0 Preview enable diff --git a/Directory.Packages.props b/Directory.Packages.props index 1212dc1164b..11bc1ad550f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -28,21 +28,7 @@ - - - - - - - - - - - - - - - + diff --git a/docs/docs/dotnet-api-docs.md b/docs/docs/dotnet-api-docs.md index a1ff5da1474..a1d81f5be61 100644 --- a/docs/docs/dotnet-api-docs.md +++ b/docs/docs/dotnet-api-docs.md @@ -87,7 +87,7 @@ If your project targets multiple target frameworks, docfx internally builds each }], "dest": "api", "properties": { - "TargetFramework": "net6.0" + "TargetFramework": "net8.0" } }, } diff --git a/docs/index.md b/docs/index.md index 5134ddb7a2f..ec5c7c07c83 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,7 +8,7 @@ In this section we will build a simple documentation site on your local machine. > Prerequisites > - Familiarity with the command line -> - Install [.NET SDK](https://dotnet.microsoft.com/en-us/download) 6.0 or higher +> - Install [.NET SDK](https://dotnet.microsoft.com/en-us/download) 8.0 or higher Make sure you have [.NET SDK](https://dotnet.microsoft.com/en-us/download) installed, then open a terminal and enter the following command to install the latest docfx: diff --git a/docs/tutorial/howto_build_your_own_type_of_documentation_with_custom_plug-in.md b/docs/tutorial/howto_build_your_own_type_of_documentation_with_custom_plug-in.md index 8d70d6af0a0..3568acc2153 100644 --- a/docs/tutorial/howto_build_your_own_type_of_documentation_with_custom_plug-in.md +++ b/docs/tutorial/howto_build_your_own_type_of_documentation_with_custom_plug-in.md @@ -15,7 +15,7 @@ Goal and limitation Preparation ----------- -1. Create a new C# class library targeting `net6.0` or later. +1. Create a new C# class library targeting `net8.0` or later. 2. Add NuGet package reference to `System.Composition`, `Docfx.Plugins` and `Docfx.Common`. diff --git a/samples/extensions/build/build.csproj b/samples/extensions/build/build.csproj index c762e1104c0..ff4751c5219 100644 --- a/samples/extensions/build/build.csproj +++ b/samples/extensions/build/build.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable diff --git a/samples/seed/dotnet/project/Project.Core/BuildFromProject.Core.csproj b/samples/seed/dotnet/project/Project.Core/BuildFromProject.Core.csproj index a90328379a1..639eaa34ad3 100644 --- a/samples/seed/dotnet/project/Project.Core/BuildFromProject.Core.csproj +++ b/samples/seed/dotnet/project/Project.Core/BuildFromProject.Core.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 latest enable enable diff --git a/samples/seed/dotnet/project/Project/BuildFromProject.csproj b/samples/seed/dotnet/project/Project/BuildFromProject.csproj index c3271976a56..bfef038c926 100644 --- a/samples/seed/dotnet/project/Project/BuildFromProject.csproj +++ b/samples/seed/dotnet/project/Project/BuildFromProject.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 latest enable enable diff --git a/samples/seed/dotnet/solution/CatLibrary.Core/CatLibrary.Core.csproj b/samples/seed/dotnet/solution/CatLibrary.Core/CatLibrary.Core.csproj index 6f2aed608ee..9d5a3ce7408 100644 --- a/samples/seed/dotnet/solution/CatLibrary.Core/CatLibrary.Core.csproj +++ b/samples/seed/dotnet/solution/CatLibrary.Core/CatLibrary.Core.csproj @@ -1,5 +1,5 @@  - net6.0 + net8.0 - \ No newline at end of file + diff --git a/samples/seed/dotnet/solution/CatLibrary/CatLibrary.csproj b/samples/seed/dotnet/solution/CatLibrary/CatLibrary.csproj index a24c9ef8923..f4377e8b0af 100644 --- a/samples/seed/dotnet/solution/CatLibrary/CatLibrary.csproj +++ b/samples/seed/dotnet/solution/CatLibrary/CatLibrary.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 true diff --git a/src/Docfx.Dotnet/Docfx.Dotnet.csproj b/src/Docfx.Dotnet/Docfx.Dotnet.csproj index 2864dce696b..ac476581f20 100644 --- a/src/Docfx.Dotnet/Docfx.Dotnet.csproj +++ b/src/Docfx.Dotnet/Docfx.Dotnet.csproj @@ -28,11 +28,6 @@ - - - - - diff --git a/src/Docfx.Dotnet/DotnetApiCatalog.cs b/src/Docfx.Dotnet/DotnetApiCatalog.cs index 948cb23cf8c..e94920ee2ea 100644 --- a/src/Docfx.Dotnet/DotnetApiCatalog.cs +++ b/src/Docfx.Dotnet/DotnetApiCatalog.cs @@ -57,8 +57,6 @@ internal static async Task Exec(MetadataJsonConfig config, DotnetApiOptions opti { var stopwatch = Stopwatch.StartNew(); - EnsureMSBuildLocator(); - try { string originalGlobalNamespaceId = VisitorHelper.GlobalNamespaceId; @@ -116,26 +114,6 @@ void WriteYaml(string outputFolder, string id, Build.ApiPage.ApiPage apiPage) } } - private static void EnsureMSBuildLocator() - { -#if NET6_0 - try - { - if (!Microsoft.Build.Locator.MSBuildLocator.IsRegistered) - { - var vs = Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults() ?? throw new Docfx.Exceptions.ExtractMetadataException( - $"Cannot find a supported .NET Core SDK. Install .NET Core SDK {Environment.Version.Major}.{Environment.Version.Minor}.x to build .NET API docs."); - - Logger.LogInfo($"Using {vs.Name} {vs.Version}"); - } - } - catch (Exception e) - { - throw new Docfx.Exceptions.ExtractMetadataException(e.Message, e); - } -#endif - } - private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig configModel, string configDirectory, string outputDirectory) { var projects = configModel.Src; diff --git a/src/docfx/docfx.csproj b/src/docfx/docfx.csproj index 64677f8f063..0ea31d91aab 100644 --- a/src/docfx/docfx.csproj +++ b/src/docfx/docfx.csproj @@ -19,7 +19,7 @@ --> - + $(TargetFrameworks.Split(";")[0]) diff --git a/test/docfx.Snapshot.Tests/SamplesTest.SeedMarkdown/CatLibrary.CatException-1.verified.md b/test/docfx.Snapshot.Tests/SamplesTest.SeedMarkdown/CatLibrary.CatException-1.verified.md index 4831a85a189..6c0a8a74e25 100644 --- a/test/docfx.Snapshot.Tests/SamplesTest.SeedMarkdown/CatLibrary.CatException-1.verified.md +++ b/test/docfx.Snapshot.Tests/SamplesTest.SeedMarkdown/CatLibrary.CatException-1.verified.md @@ -24,7 +24,6 @@ public class CatException : Exception, ISerializable #### Inherited Members [Exception.GetBaseException\(\)](https://learn.microsoft.com/dotnet/api/system.exception.getbaseexception), -[Exception.GetObjectData\(SerializationInfo, StreamingContext\)](https://learn.microsoft.com/dotnet/api/system.exception.getobjectdata), [Exception.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.exception.gettype), [Exception.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.exception.tostring), [Exception.Data](https://learn.microsoft.com/dotnet/api/system.exception.data), diff --git a/test/docfx.Tests/Assets/multi-frameworks-test.csproj.sample.1 b/test/docfx.Tests/Assets/multi-frameworks-test.csproj.sample.1 index f7aca45d3c0..a8c7f4b4265 100644 --- a/test/docfx.Tests/Assets/multi-frameworks-test.csproj.sample.1 +++ b/test/docfx.Tests/Assets/multi-frameworks-test.csproj.sample.1 @@ -1,10 +1,10 @@  - net6.0;netstandard2.0 + net8.0;netstandard2.0 true - \ No newline at end of file + diff --git a/test/docfx.Tests/Assets/ref.csproj.sample.1 b/test/docfx.Tests/Assets/ref.csproj.sample.1 index 1b5656b92f9..de34d27f8d4 100644 --- a/test/docfx.Tests/Assets/ref.csproj.sample.1 +++ b/test/docfx.Tests/Assets/ref.csproj.sample.1 @@ -1,5 +1,5 @@  - net6.0 + net8.0 - \ No newline at end of file + diff --git a/test/docfx.Tests/Assets/template/plugins/plugins.csproj b/test/docfx.Tests/Assets/template/plugins/plugins.csproj index 1714e2a73bb..a95ef2ec35b 100644 --- a/test/docfx.Tests/Assets/template/plugins/plugins.csproj +++ b/test/docfx.Tests/Assets/template/plugins/plugins.csproj @@ -1,7 +1,7 @@ - + - net6.0 + net8.0 enable enable false diff --git a/test/docfx.Tests/Assets/test.csproj.sample.1 b/test/docfx.Tests/Assets/test.csproj.sample.1 index fb237e64e04..03511f974ed 100644 --- a/test/docfx.Tests/Assets/test.csproj.sample.1 +++ b/test/docfx.Tests/Assets/test.csproj.sample.1 @@ -1,6 +1,6 @@  - net6.0 + net8.0 true @@ -8,4 +8,4 @@ ClassLibrary1 - \ No newline at end of file + diff --git a/test/docfx.Tests/Assets/test.vbproj.sample.1 b/test/docfx.Tests/Assets/test.vbproj.sample.1 index 05d1cf1730f..57aa05d91c7 100644 --- a/test/docfx.Tests/Assets/test.vbproj.sample.1 +++ b/test/docfx.Tests/Assets/test.vbproj.sample.1 @@ -1,6 +1,6 @@  - net6.0 + net8.0 testVBproj1 test.sample.1 On diff --git a/test/docfx.Tests/MetadataCommandTest.cs b/test/docfx.Tests/MetadataCommandTest.cs index f83da132da0..e01761fb414 100644 --- a/test/docfx.Tests/MetadataCommandTest.cs +++ b/test/docfx.Tests/MetadataCommandTest.cs @@ -69,7 +69,7 @@ await DotnetApiCatalog.Exec( { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true }, - Properties = new() { ["TargetFramework"] = "net6.0" }, + Properties = new() { ["TargetFramework"] = "net8.0" }, }), new(), Directory.GetCurrentDirectory());