Describe the bug
When explicitly specifying .NET SDK version by global.json with following settings.
Solution/Project build runs as expected with the specified SDK version.
But C# source file based builds always referencing the latest version of ref assemblies.
(e.g. C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\9.0.0-preview.1.24080.9)
Because ref assemblies directory is resolved by version name of Max().
|
var version = new DirectoryInfo(refDirectory).GetDirectories().Select(d => d.Name).Max(); |
|
var moniker = new DirectoryInfo(Path.Combine(refDirectory, version, "ref")).GetDirectories().Select(d => d.Name).Max(); |
|
var path = Path.Combine(refDirectory, version, "ref", moniker); |
To Reproduce
- Use build environment that install .NET8/.NET9 SDKS.
- Create following
global.json file at docfx root directory.
{
"sdk": {
"version": "8.0.200",
"rollforward" : "disable"
}
}
- Run
docfx metadata command that targeting source file based build.
- Confirm following messages are displayed.
Using .NET Core SDK 8.0.200
Compiling C# files using .NET SDK 9.0.0-preview.1.24080.9 for net9.0
Expected behavior
Ref assemblies folder is resolved by using Environment.Version. (For temporary workaround)
It might be better to use TargetFramework version that is specified by docfx.json metadata properties.
https://dotnet.github.io/docfx/reference/docfx-json-reference.html#properties
And use NETStandard.Library.Ref DLLs when specified target to netstandard2.1.
Context (please complete the following information):
- OS: Windows
- Docfx version: [e.g. 2.75.3]
Additional context
This issue cause problems when adding support to reference external DLL features to
CreateCompilationFromCSharpFiles method.
Currently following version mismatch warnings are occurred.
When adding additional DLL that target .NET 8. And run docfx metadata commands
warning: warning CS1701: Assuming assembly reference 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'R3' matches identity 'System.Runtime, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy
Describe the bug
When explicitly specifying .NET SDK version by
global.jsonwith following settings.Solution/Project build runs as expected with the specified SDK version.
But C# source file based builds always referencing the latest version of ref assemblies.
(e.g.
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\9.0.0-preview.1.24080.9)Because ref assemblies directory is resolved by version name of
Max().docfx/src/Docfx.Dotnet/CompilationHelper.cs
Lines 127 to 129 in 841fcdf
To Reproduce
global.jsonfile at docfx root directory.docfx metadatacommand that targeting source file based build.Expected behavior
Ref assemblies folder is resolved by using
Environment.Version. (For temporary workaround)It might be better to use
TargetFrameworkversion that is specified by docfx.json metadata properties.https://dotnet.github.io/docfx/reference/docfx-json-reference.html#properties
And use
NETStandard.Library.RefDLLs when specified target tonetstandard2.1.Context (please complete the following information):
Additional context
This issue cause problems when adding support to reference external DLL features to
CreateCompilationFromCSharpFiles method.
Currently following version mismatch warnings are occurred.
When adding additional DLL that target
.NET 8. And rundocfx metadatacommands