dotnet / dotnet/docfx

[Bug] Failed to load custom plugin DLL when tested on local build environment

Open
#10,046 0 comments 0 reactions 0 assignees View on GitHub
fundamental
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 11m
Merged PRs (30d)
10

Description

**Describe the bug**
On local docfx build.
docfx plugin DLL fails to load because of `Docfx.Plugins` version mismatch.

**To Reproduce**
Steps to reproduce the behavior:
1. Create custom PostProcessor DLL.
1. Place plugin DLL to `samples\seed\template\plugins`
2. Configure custom `PostProcessor` name at `docfx.json`'s `postProcessors` section.
3. Start `docfx build` inside Visual Studio
4. Confirm following exception occurred.

```
System.Reflection.ReflectionTypeLoadException
HResult=0x80131602
Message=Unable to load one or more of the requested types.
Could not load file or assembly 'Docfx.Plugins, Version=2.76.0.0, Culture=neutral, PublicKeyToken=null'.
Source=System.Private.CoreLib
StackTrace:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at Docfx.DocumentBuilderWrapper.d__2.MoveNext() in C:\Projects\docfx\src\Docfx.App\Helpers\DocumentBuilderWrapper.cs:line 88
```

**Expected behavior**
It can load custom plugin DLL. on local build environment.

**Root cause of problem**
1. When docfx is build on local environment. assembly `Version` is set to `1.0.0`
2. docfx load `Docfx.Plugins, Version=1.0.0` on startup.
3. MEF(`System.Composition`) plugin try to load plugin DLL.
But it fails because it attempt to load newer dependent assembly (`Docfx.Plugins, Version=2.76.0.0`)

**How to fix problems**
It can successfully load plugin DLLs.
When manually assign **newer** version by `Directory.Build.props` (e.g. `2.76.1`)

So I thought either of the following actions will be required to fix versioning problems.
1, Manually update `` tags when docfx version is updated.
2. Introduce [dotnet/Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) for versioning

**Context (please complete the following information):**
- OS: Windows
- Docfx version: [e.g. 2.76.0]

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.