dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4k stars 851 forks source link

Error:[MergeCommand]System.NullReferenceException: Object reference not set to an instance of an object. #7106

Open nitanmarcel opened 3 years ago

nitanmarcel commented 3 years ago

Operating System: Windows on github-actions

DocFX Version Used: docfx 2.56.6.0

Template used: https://github.com/steffen-wilke/darkfx, memberpage

Steps to Reproduce:

I'm trying to merge 2 projects into one website. I've searched the repo for the issues but I can't still find my answer to fix this problem.

{
    "metadata": [
        {
            "src": [
              {
                "files": [
                  "source/scripting_v2/**.csproj"
                ],
                "src": ".."
              }
            ],
            "dest": "scripting_v2"
          },
          {
            "src": [
              {
                "files": [
                  "source/scripting_v3/**.csproj"
                ],
                "src": ".."
              }
            ],
            "dest": "scripting_v3"
          }
    ],
      "merge": {
        "content": [
          {
            "files": [
              "scripting_v2/**.yml"
              ]
          },
          {
            "files": [
              "scripting_v3/**.yml"
              ]
          }
        ],
        "fileMetadata": {
          "platform": {
              "scripting_v2/*.yml": [
                  "net48"
              ],
              "scripting_v3/*.yml": [
                  "net48"
              ]
          }
      }
    },
    "build": {
        "content": [
            {
                "files": [
                    "scripting_v2/**.yml",
                    "scripting_v2/index.md"
                ]
            },
            {
                "files": [
                    "scripting_v3/**.yml",
                    "scripting_v3/index.md"
                ]
            },
            {
                "files": [
                    "toc.yml",
                    "*.md"
                ]
            }
        ],
        "resource": [
            {
                "files": [
                    "assets/**",
                    "_site/**"
                ]
            }
        ],
        "dest": "_site",
        "globalMetadata": {
            "_appTitle": "Community Script Hook V .NET",
            "_appFooter": "Unofficial SHV.NET Online Documentation By <a href=\"https://gitlab.com/nitanmarcel/shvdn-doc\">nitanmarcel</a> - <a href=\"~/LICENSE.md\">MIT</a>",
            "_disableContribution": true,
            "_enableSearch": true,
            "_appLogoPath": "-",
            "_appFaviconPath":  "assets/favicon.png"

          },
        "globalMetadataFiles": [],
        "fileMetadataFiles": [],
        "template": [
        "default",
        "template/darkfx",
        "template/memberpage"
        ],
        "postProcessors": ["ExtractSearchIndex"],
        "markdownEngineName": "markdig",
        "noLangKeyword": false,
        "keepFileLink": false,
        "cleanupCacheHistory": false,
        "disableGitFeatures": false

    }
}

Expected Behavior: Website should be generated with 3 paths, /index.html, /scripting_v2/index.html , /scripting_v3/index.html

Actual Behavior: Crashes with error:

[21-02-26 06:37:11.525]Error:[MergeCommand]System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DocAsCode.Build.Engine.HostServiceCreator.LoadModels(IEnumerable`1 files, DocumentBuildParameters parameters, IDocumentProcessor processor)
   at Microsoft.DocAsCode.Build.Engine.HostServiceCreator.CreateHostService(DocumentBuildParameters parameters, TemplateProcessor templateProcessor, IMarkdownService markdownService, IEnumerable`1 metadataValidator, IDocumentProcessor processor, IEnumerable`1 files)
   at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.Build(IDocumentProcessor processor, DocumentBuildParameters parameters, IMarkdownService markdownService)
   at Microsoft.DocAsCode.SubCommands.MetadataMerger.MergePageViewModel(MetadataMergeParameters parameters)
   at Microsoft.DocAsCode.SubCommands.MetadataMerger.Merge(MetadataMergeParameters parameters)
   at Microsoft.DocAsCode.SubCommands.MergeCommand.MergeDocument(String baseDirectory, String outputDirectory)
    9488 Warning(s)
    1 Error(s)
dotMorten commented 3 years ago

There are numerous complaints about this merge command issue, but it has been ignored for years. I believe this issue is also a duplicate of #3067

macrogreg commented 2 years ago

Using merge is described as a preferred workaround for enabling docs for libraries that target multiple frameworks. This issue blocks such usage, but it was not addressed for years. I respect the prioritization decisions of the DocFx team, however, would it be possible to learn whether there is any hope for this issue to be addressed in the foreseeable future?

If not, is there a recommended working workaround for the multitargeting issue that would permit generating docs for libraries targeting multiple frameworks? (See also https://github.com/dotnet/docfx/issues/1254#issuecomment-294080535.) Is DocFx the right choice for such use cases?