Skip to content

Commit

Permalink
feat: add .NET 9 support (And drop .NET 6 support)
Browse files Browse the repository at this point in the history
  • Loading branch information
filzrev committed Sep 28, 2024
1 parent 4d5949a commit 9378daa
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
- run: npm install
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DOCFX_PREVIEW_BUILD)' == 'true'">net8.0;net9.0</TargetFrameworks>
<LangVersion>Preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
16 changes: 1 addition & 15 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,7 @@
<PackageVersion Include="YamlDotNet" Version="15.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<!-- "17.3.2" is the latest compatible version for .NET 6 -->
<PackageVersion Include="Microsoft.Build" Version="[17.3.2]" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="[4.8.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="[4.8.0]" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dotnet-api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ If your project targets multiple target frameworks, docfx internally builds each
}],
"dest": "api",
"properties": {
"TargetFramework": "net6.0"
"TargetFramework": "net8.0"
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion samples/seed/dotnet/solution/CatLibrary/CatLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions src/Docfx.Dotnet/Docfx.Dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
<ProjectReference Include="..\Docfx.Plugins\Docfx.Plugins.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Formats.Asn1" />
<PackageReference Include="HtmlAgilityPack" />
Expand Down
22 changes: 0 additions & 22 deletions src/Docfx.Dotnet/DotnetApiCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ internal static async Task Exec(MetadataJsonConfig config, DotnetApiOptions opti
{
var stopwatch = Stopwatch.StartNew();

EnsureMSBuildLocator();

try
{
string originalGlobalNamespaceId = VisitorHelper.GlobalNamespaceId;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/docfx/docfx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-->
<Target Name="RewriteDocfxTemplateFiles" AfterTargets="PackTool">
<PropertyGroup>
<!-- Select first element of TargetFrameworks as template source (e.g. `net6.0` is selected when TargetFrameworks `net6.0;net7.0;net8.0`) -->
<!-- Select first element of TargetFrameworks as template source (e.g. `net8.0` is selected when TargetFrameworks `net8.0;9.0`) -->
<DocfxTemplateSourceTargetFramework>$(TargetFrameworks.Split(";")[0])</DocfxTemplateSourceTargetFramework>
</PropertyGroup>
<!-- If TargetFramework is selected version. Rewrite template files PackagePath.-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class CatException<T> : 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),
Expand Down
4 changes: 2 additions & 2 deletions test/docfx.Tests/Assets/multi-frameworks-test.csproj.sample.1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions test/docfx.Tests/Assets/ref.csproj.sample.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions test/docfx.Tests/Assets/template/plugins/plugins.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
4 changes: 2 additions & 2 deletions test/docfx.Tests/Assets/test.csproj.sample.1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="ref.csproj">
<Name>ClassLibrary1</Name>
</ProjectReference>
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion test/docfx.Tests/Assets/test.vbproj.sample.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<RootNamespace>testVBproj1</RootNamespace>
<AssemblyName>test.sample.1</AssemblyName>
<OptionExplicit>On</OptionExplicit>
Expand Down
2 changes: 1 addition & 1 deletion test/docfx.Tests/MetadataCommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 9378daa

Please sign in to comment.