docfx
docfx copied to clipboard
[Bug] "Exception: The server disconnected unexpectedly." when running in Azure Devops
Describe the bug
When running docfx
to build my project documentation in Azure Devops, I get Exception: The server disconnected unexpectedly.
followed by a stack trace (see log below). The exact command run is docfx docs/docfx.json --output 'D:\a\1\a\docs' --warningsAsErrors
.
The docfx.json is the same as it has been previously successful runs. Will post a redacted version if needed.
The crash does not occur when running the same command locally on my machine, and I have not been able to reproduce is locally.
Log
+ docfx docs/docfx.json --output 'D:\a\1\a\docs' --warningsAsErrors
Loading project <REDACTED>
Determining projects to restore...
All projects are up-to-date for restore.
Exception: The server disconnected unexpectedly.
at async Task<object> InvokeCoreAsync(int targetObject, string methodName,
List<object> parameters, Type expectedReturnType, CancellationToken
cancellationToken)
at async Task<T> InvokeAsync<T>(int targetObject, string methodName,
List<object> parameters, CancellationToken cancellationToken)
at async Task<RemoteProjectFile> LoadProjectFileAsync(string projectFilePath,
string languageName, CancellationToken cancellationToken)
at async Task<TResult> DoOperationAndReportProgressAsync<TResult>(
ProjectLoadOperation operation, string projectPath, string targetFramework,
Func<Task<TResult>> doFunc)
at async Task<ImmutableArray<ProjectFileInfo>> LoadProjectFileInfosAsync(
CommandExecutor.cs:144
at async Task<int> Execute(IConfiguration configuration, IEnumerable<string>
args) in CommandExecutor.cs:83
at async Task<int> RunAsync(IEnumerable<string> args) in CommandApp.cs:84
To Reproduce Steps to reproduce the behavior:
- Run
docfx
in Azure Devops on VM Imagewindows-2022
(Version20240403.1.0)
Expected behavior The docs should build succesfully.
Context (please complete the following information):
- OS: Azure Devops VM Image:
windows-2022
(Version 20240403.1.0) - Docfx version: 2.76
Additional context
- UPDATE: Downgrading to version 2.75.3 solves the issue for me.
Exception: The server disconnected unexpectedly.
It seems to be thrown by following lines when calling MSBuildWorkspace::LoadProjectFileAsync
.
https://github.com/dotnet/roslyn/blob/b67df4c5e39ac1a104b2e573542211d4d6b1cd1d/src/Workspaces/Core/MSBuild/Rpc/RpcClient.cs#L87-L89
docfx 2.76.0 using roslyn 4.9.2 packages. and out-of-process code analysis
that are introduced in this version causing problems.
It might be resolved when next roslyn packages (v4.9.10) are released.
Related issue: https://github.com/dotnet/roslyn/issues/72558
Same problem here on a local project, after update from 2.75.3
to 2.76.0
.
Here's the output:
Loading project /Users/jonan/Projects/SomeProject.csproj
Determining projects to restore...
All projects are up-to-date for restore.
Exception: The server disconnected unexpectedly.
at async Task<object> InvokeCoreAsync(int targetObject, string methodName, List<object> parameters, Type
expectedReturnType, CancellationToken cancellationToken)
at async Task<T> InvokeAsync<T>(int targetObject, string methodName, List<object> parameters, CancellationToken
cancellationToken)
at async Task<RemoteProjectFile> LoadProjectFileAsync(string projectFilePath, string languageName, CancellationToken
cancellationToken)
at async Task<TResult> DoOperationAndReportProgressAsync<TResult>(ProjectLoadOperation operation, string projectPath,
string targetFramework, Func<Task<TResult>> doFunc)
at async Task<ImmutableArray<ProjectFileInfo>> LoadProjectFileInfosAsync(string projectPath, DiagnosticReportingOptions
reportingOptions, CancellationToken cancellationToken)
at async Task<ImmutableArray<ProjectInfo>> LoadProjectInfosFromPathAsync(string projectPath, DiagnosticReportingOptions
reportingOptions, CancellationToken cancellationToken)
at async Task<ImmutableArray<ProjectInfo>> LoadAsync(CancellationToken cancellationToken)
at async Task<ImmutableArray<ProjectInfo>> LoadProjectInfoAsync(string projectFilePath, ProjectMap projectMap,
IProgress<ProjectLoadProgress> progress, ILogger msbuildLogger, CancellationToken cancellationToken)
at async Task<ImmutableArray<ProjectInfo>> LoadProjectInfoAsync(string projectFilePath, ProjectMap projectMap,
IProgress<ProjectLoadProgress> progress, ILogger msbuildLogger, CancellationToken cancellationToken)
at async Task<Project> OpenProjectAsync(string projectFilePath, ILogger msbuildLogger, IProgress<ProjectLoadProgress>
progress, CancellationToken cancellationToken)
at void MoveNext() in DotnetApiCatalog.Compile.cs:150
at async (List<ValueTuple<IAssemblySymbol, Compilation>> symbol) Compile(ExtractMetadataConfig config, DotnetApiOptions
options) in DotnetApiCatalog.Compile.cs:78
at async Task <Exec>g__Build|5_0(ExtractMetadataConfig config, DotnetApiOptions options) in DotnetApiCatalog.cs:86
at async Task Exec(MetadataJsonConfig config, DotnetApiOptions options, string configDirectory, string outputDirectory)
in DotnetApiCatalog.cs:72
at void <Execute>b__0() in DefaultCommand.cs:45
at int Run(LogOptions options, Action run) in CommandHelper.cs:48
at int Execute(CommandContext context, Options options) in DefaultCommand.cs:31
at Task<int> Execute(CommandContext context, CommandSettings settings) in CommandOfT.cs:40
at Task<int> Execute(CommandTree leaf, CommandTree tree, CommandContext context, ITypeResolver resolver, IConfiguration
configuration) in CommandExecutor.cs:144
at async Task<int> Execute(IConfiguration configuration, IEnumerable<string> args) in CommandExecutor.cs:83
at async Task<int> RunAsync(IEnumerable<string> args) in CommandApp.cs:84
Is it able to provide reproduceable files?
I've tried to reproduce problems with Azure Pipelines with following settings. But I can't be able to reproduce.
azure-pipelines.yml
trigger:
- main
pool:
vmImage: 'windows-2022'
steps:
- script: |
dotnet tool install docfx -g
pushd docs
docfx metadata
docfx build
popd
workingDirectory: "$(System.DefaultWorkingDirectory)"
Here is the config file:
{
"metadata": [{
"src": [{
"files": ["Core/Core.csproj"],
"src": "../"
}, {
"files": ["Nodes/Nodes.csproj", "Execution/Execution.csproj"],
"src": "../"
}],
"dest": "api",
"filter": "docfx-filter-config.yml",
"disableGitFeatures": true,
"disableDefaultFilter": false
}],
"build": {
"content": [{
"files": ["**.yml", "**.md"],
"exclude": "docfx-filter-config.yml"
}],
"resource": [{
"files": ["images/**"]
}],
"overwrite": [{
"files": ["**.md"],
"exclude": [
"obj/**",
"bin/**",
"_site/**"
]
}],
"dest": "../public",
"_globalMetadata": {
"_appTitle": "MyTest™",
"_enableSearch": true
},
"globalMetadataFiles": [],
"fileMetadataFiles": [],
"template": ["default"],
"postProcessors": [],
"noLangKeyword": false,
"keepFileLink": false,
"cleanupCacheHistory": true,
"disableGitFeatures": true,
"force": true
}
}
With the filter file being:
apiRules:
- include:
uidRegex: ^Company\.Project\.Core.+
- exclude:
uidRegex: _[^.]+$
I hope this would help.
@thejonan Is it able to provide following information additionaly?
- OS information that is used to run docfx command.
- Installed .NET SDK versions (
dotnet --info
command output) - Target frameworks of
*.csproj
As far as I've confirmed your configs.
It seems there is no problems. So it need to investigate .csproj
contents or environment specific problems.
I've created sample project to load project file with roslyn API. (samples.zip)
Please try following steps.
- Run
docfx metadata
command ondocs
directory. And confirm it' successfully completed. - Run
dotnet run
command onsrc
directory. And confirm it's successfully completed. - If above two command successfully completed.
Modfysrc/Program.cs
file to load "Core/Core.csproj" project and rundotnet run
command.
The crash occurs both on my Mac:
.NET SDK:
Version: 7.0.313
Commit: 7b4633fafd
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.4
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.313/
Host:
Version: 7.0.16
Architecture: arm64
Commit: 567edafe61
.NET SDKs installed:
6.0.414 [/usr/local/share/dotnet/sdk]
6.0.415 [/usr/local/share/dotnet/sdk]
6.0.416 [/usr/local/share/dotnet/sdk]
6.0.419 [/usr/local/share/dotnet/sdk]
7.0.308 [/usr/local/share/dotnet/sdk]
7.0.309 [/usr/local/share/dotnet/sdk]
7.0.310 [/usr/local/share/dotnet/sdk]
7.0.313 [/usr/local/share/dotnet/sdk]
, and on a CI pipeline, based on docker's image: mcr.microsoft.com/dotnet/sdk:7.0
(digest: mcr.microsoft.com/dotnet/sdk@sha256:e44ea6d4cd019913b80726896e1127cd3fd6bd0f5c1d2074be02da3e54931127
).
I'm targeting netstandard2.1
in my projects.
running docfx metadata
in your docs
folder results in:
Using .NET Core SDK 7.0.313
Loading project /Users/jonan/Downloads/samples/src/RoslynAnalysis.csproj
Determining projects to restore...
/usr/local/share/dotnet/sdk/7.0.313/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(151,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [/Users/jonan/Downloads/samples/src/RoslynAnalysis.csproj]
error: /Users/jonan/Downloads/samples/src/obj/Release/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs(4,20): error
CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly
reference?)
...
which I guess is understood, given that I don't have net8 installed, but if I change your project's target to net7.0, then the result is:
Using .NET Core SDK 7.0.313
Loading project /Users/jonan/Downloads/samples/src/RoslynAnalysis.csproj
Determining projects to restore...
Restored /Users/jonan/Downloads/samples/src/RoslynAnalysis.csproj (in 6,12 sec).
__________________________________________________
Project "/Users/jonan/Downloads/samples/src/RoslynAnalysis.csproj" (Compile;CoreCompile target(s)):
/usr/local/share/dotnet/sdk/7.0.313/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): warning NETSDK1187: Package Microsoft.CodeAnalysis.Common 4.9.2 has a resource with the locale 'zh-Hans'. This locale has been normalized to the standard format 'zh-HANS' to prevent casing issues in the build. Consider notifying the package author about this casing issue.
...
warning: [Failure] Msbuild failed when processing the file '/Users/jonan/Downloads/samples/src/RoslynAnalysis.csproj' with
message: /usr/local/share/dotnet/sdk/7.0.313/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets:
(266, 5): Package Microsoft.CodeAnalysis.Workspaces.MSBuild 4.9.2 has a resource with the locale 'zh-Hant'. This locale
has been normalized to the standard format 'zh-HANT' to prevent casing issues in the build. Consider notifying the package
author about this casing issue.
Processing RoslynAnalysis
Creating output...
Build succeeded with warning.
14 warning(s)
0 error(s)
Very important aspect, as I've mentioned, is that with version 2.75.3
of the tool everything worked fine.
@thejonan Thanks for provide information and testing sample code. It seems not able to reproduce problems by samples.
Very important aspect, as I've mentioned, is that with version 2.75.3 of the tool everything worked fine.
As noted above. It's expected to be caused by updating Roslyn packages to 4.9.2
.
It change to API analysis operation in separated process.
And that cause The server disconnected unexpectedly.
exception.
So if it is able to detect minimum reproducible code/environment, It helps to resolve problems.
Same problem here.
until this is fixed, the workaround is to simply downgrade, then everything works.
dotnet tool install docfx --version 2.75.0
would've been very helpful to provide this solution in the answers
Bump. Same Problem for me in a Gitlab CI docker build Pipeline. After updating to v2.76.0 . This is definetly a Regression from 2.75.3. There everything was and is still working. Environment: .net6
Exact same exception:
#12 [build 6/6] RUN dotnet tool run docfx docs/docfx.json -o /app/docs
#12 1.781 Loading project /src/source/some.csproj
#12 2.595 Determining projects to restore...
#12 3.340 All projects are up-to-date for restore.
#12 3.927 Exception: The server disconnected unexpectedly.
#12 3.927 at async Task<object> InvokeCoreAsync(int targetObject, string methodName,
#12 3.935 List<object> parameters, Type expectedReturnType, CancellationToken
#12 3.935 cancellationToken)
#12 3.935 at async Task<T> InvokeAsync<T>(int targetObject, string methodName,
#12 3.935 List<object> parameters, CancellationToken cancellationToken)
#12 3.935 at async Task<RemoteProjectFile> LoadProjectFileAsync(string projectFilePath,
#12 3.935 string languageName, CancellationToken cancellationToken)
#12 3.935 at async Task<TResult> DoOperationAndReportProgressAsync<TResult>(
#12 3.935 ProjectLoadOperation operation, string projectPath, string targetFramework,
#12 3.935 Func<Task<TResult>> doFunc)
#12 3.935 at async Task<ImmutableArray<ProjectFileInfo>> LoadProjectFileInfosAsync(
#12 3.935 string projectPath, DiagnosticReportingOptions reportingOptions,
#12 3.935 CancellationToken cancellationToken)
#12 3.935 at async Task<ImmutableArray<ProjectInfo>> LoadProjectInfosFromPathAsync(
#12 3.935 string projectPath, DiagnosticReportingOptions reportingOptions,
#12 3.935 CancellationToken cancellationToken)
Some of the possible causes are when running docfx with .NET 6 or .NET 7.
And run build on .NET 8
SDK is not installed environment.
I've confirmed it's reproduced by using docker-based build on Windows. And using .NET 6 or .NET 7 base image.
In this case, one of the following exceptions will occur.
- Exception: The server disconnected unexpectedly.
- System.IO.IOException: Broken pipe
Broken pipe
IOException is reported as regression at https://github.com/dotnet/roslyn/issues/71784.
And it seems not fixed yet.
Broken pipe
IOException is reported as regression at dotnet/roslyn#71784. And it seems not fixed yet.
Thanks for the investigating and info update. I have downgraded for now and will be looking forward to the fix then :)
Latest version of docfx 2.77.0 uses Roslyn 4.8.0
version when running on .NET 6 runtime.
So it's expected to works same as docfx 2.75.3.
On .NET 8 environment. docfx use latest version of Roslyn. If problems are still continues. Please report issues.