Despite reading through the docfx documentation, and numerous Github issues, I am unable to get my docfx project working.
Steps taken:
- Initialise root directory
docfx init -q
- Build from root directory
docfx build
(no errors) - Serve
docfx "/user/docfx_project/docfx.json" --serve
Stacktrace:
Error:Error extracting metadata for /user/docfx_project/src/MyApp/MyApp.csproj,/user/docfx_project/src/MyApp.Tests/MyApp.Tests.csproj: System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.SaveAllMembersFromCacheAsync () [0x00380] in <0779a76130d64c11baa2c8c084cbfe7c>:0
at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.ExtractMetadataAsync () [0x000c0] in <0779a76130d64c11baa2c8c084cbfe7c>:0
Environment:
- OSX 10.13.6
- docfx 2.56.2.0
- .NET Core SDK (3.1.401)
- Mono JIT compiler version 6.10.0.104
Project structure:
docfx-project
|
+-- _site
+-- api
+-- apidoc
+-- articles
+-- docfx.json
+-- images
+-- index.md
+-- obj
+-- src
|
+-- MyApp
|
+-- MyApp.csproj
+-- toc.yml
docfx.json:
{
"metadata": [
{
"src": [
{
"files": [
"src/**/**.csproj"
]
}
],
"dest": "api",
"disableGitFeatures": false,
"disableDefaultFilter": false
}
],
"build": {
"content": [
{
"files": [
"api/**.yml",
"api/index.md"
]
},
{
"files": [
"articles/**.md",
"articles/**/toc.yml",
"toc.yml",
"*.md"
]
}
],
"resource": [
{
"files": [
"images/**"
]
}
],
"overwrite": [
{
"files": [
"apidoc/**.md"
],
"exclude": [
"obj/**",
"_site/**"
]
}
],
"dest": "_site",
"globalMetadataFiles": [],
"fileMetadataFiles": [],
"template": [
"default"
],
"postProcessors": [],
"markdownEngineName": "markdig",
"noLangKeyword": false,
"keepFileLink": false,
"cleanupCacheHistory": false,
"disableGitFeatures": false
}
}
Halp.
I have relatively little idea why this works, but what it took on my CI machine was
export VSINSTALLDIR=
- in other words, clearing theVSINSTALLDIR
environment variable before runningdocfx metadata
. I believe that affects the version of msbuild (or some msbuild files, at least) that docfx uses.This is has been a fix for other issues in the past - that one claims to have been fixed a while ago, but the same workaround seems to work for this issue too... at least on my CI machine.