[Feature Request] Support building with preview versions of the .NET SDK
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 890
- Avg merge
- 2h 11m
- Merged PRs (30d)
- 10
Description
**Is your feature request related to a problem? Please describe.**
Testing applications out with the .NET 9 Preview 1 SDK, it's not possible to build sites using docfx that have a `net9.0` target framework.
This appears to be due to the code below, which requires that the SDK used is the same version as the runtime version docfx uses.
https://github.com/dotnet/docfx/blob/bebcd35323da35e253125c5b3cfd12e7a4553696/src/Docfx.Dotnet/CompilationHelper.cs#L135-L159
Even if the .NET 8 SDK is installed, in addition to .NET 9's, and `DOTNET_ROLLFORWARD=Major` is set, docfx will still and try to use the .NET 8 SDK to build for .NET 9, which fails.
```console
Using .NET Core SDK 8.0.200
Loading project
/runner/_work/MyProject/MyProject/src/MyProject/MyProject.csproj
Determining projects to restore...
Error: /usr/share/dotnet/sdk/8.0.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(166,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0. Either target .NET 8.0 or lower, or use a version of the .NET SDK that supports .NET 9.0. Download the .NET SDK from https://aka.ms/dotnet/download [/runner/_work/MyProject/MyProject/src/MyProject/MyProject.csproj::TargetFramework=net9.0]
```
**Describe the solution you'd like**
docfx allows the use of newer .NET SDKs if installed in the execution environment.
**Describe alternatives you've considered**
Wait until November until .NET 9 is released and ignore my failing documentation builds.
**Additional context**
None.
Contributor guide
Assessment
This issue has not been assessed yet.