apache / lucenenet

Apache Lucene.NET
https://lucenenet.apache.org/
Apache License 2.0
2.19k stars 630 forks source link

Docs: DocFx Build Failure for API Docs #911

Open NightOwl888 opened 6 months ago

NightOwl888 commented 6 months ago

Is there an existing issue for this?

Describe the bug

The API documentation is failing to build. The website is generated with no URLs being resolved.

Expected Behavior

The documentation will build and all links will be resolvable.

Steps To Reproduce

  1. Clone the repository locally
  2. Run the powershell command ./websites/apidocs/docs.ps1 -ServeDocs -LuceneNetVersion 4.8.0-beta00016 -BaseUrl http://localhost:8080

See the API Docs build instructions.

Exceptions (if any)

Building api metadata for D:\a\lucenenet\lucenenet\main-repo\websites\apidocs\docfx.codecs.json...
[24-02-01 10:39:03.573]Warning:[ExtractMetadata](D:/a/lucenenet/lucenenet/main-repo/src/Lucene.Net.Codecs/Lucene.Net.Codecs.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'D:\a\lucenenet\lucenenet\main-repo\src\Lucene.Net.Codecs\Lucene.Net.Codecs.csproj' with message: Method not found: 'System.ReadOnlySpan`1<Char> Microsoft.IO.Path.GetFileName(System.ReadOnlySpan`1<Char>)'.
[24-02-01 10:39:04.042]Warning:[ExtractMetadata]Project 'D:\a\lucenenet\lucenenet\main-repo\src\Lucene.Net.Codecs\Lucene.Net.Codecs.csproj' does not contain any documents.
[24-02-01 10:39:04.417]Warning:[ExtractMetadata]No metadata is generated for Lucene.Net.Codecs.

Lucene.NET Version

Lucene.NET 4.8.0-beta00016

.NET Version

No response

Operating System

Windows 10 x64

Anything else?

I did a search and discovered the following issue that appears to be the same problem:

https://github.com/dotnet/docfx/issues/8097

The solution was to upgrade to 2.59.4. I attempted that next, and then got hit with the error that System.Memory had multiple versions referenced and could not load it similar to this comment.

In this case, we recently added a dependency on the System.Memory 4.5.5 NuGet package. Unfortunately, it seems that docfx has its own reference so it cannot resolve this, even if changing the assembly binding redirects.

Upgrade docfx to .NET Core?

Since it seems we have unresolvable conflicts, I attempted to upgrade to version 2.75.2 (which is now on .NET Core). It seems there have been some architecture changes, so I ran into the following issues:

A few things to note:

Shazwazza commented 6 months ago

oh my :(

NightOwl888 commented 5 months ago

@Shazwazza - Yeah, I think we will need to download the docfx source and run it in the debugger to determine how to fix the load issues with the plugins and also fix the MavenReference problem. For MavenReference I think we may need to switch to using the DLL/XML output instead of using the .csproj file, since it appears docfx doesn't actually run MSBuild.

filzrev commented 5 months ago

Lucene.Net.Analysis.OpenNLP now fails to build metatdata when executed from docfx.

On my environment. It can successfully execute docfx metadata docfx.analysis-opennlp.json command with following changes.

1. Remove MSBuild TargetFramework property from docfx.analysis-opennlp.json

It seems this settings override target framework(net6) that specified at Lucene.Net.Analysis.OpenNLP.csproj. https://github.com/apache/lucenenet/blob/43e0e894b9b40f5b28064a13ef98874a82c15330/websites/apidocs/docfx.analysis-opennlp.json#L17-L19

2. Build with .NET 8 SDK v8.0.200 I've confirmed following error is not occurred when build with .NET 8 preview SDK 8.0.200.

> ROSLYNCODETASKFACTORYCSHARPCOMPILER : error : Unknown command '/noconfig'.
C:\Users\sample\.nuget\packages\ikvm.image\8.7.5\buildTransitive\IKVM.Image.targets(95,9): error : The source file for this compilation can be found at: "C:\Users\sample\AppData\Local\Temp\MSBuildTempsample\tmpe1e76f87dcd94e66b4bcf0ec3cccbc5b.tmp"

Minimum reproducible .csproj for this issue

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="IKVM.Maven.Sdk" Version="1.6.8" />
    <PackageReference Include="IKVM.Image" Version="8.7.5" />
  </ItemGroup>
</Project>
paulirwin commented 4 months ago

When I try to run the docs.ps1 script on macOS arm64, I get the following error after the "Building api metadata for..." lines:

Building api metadata for /{path_to}/lucene.net/websites/apidocs/docfx.demo.json...
Building site output for /{path_to}/lucene.net/websites/apidocs/docfx.codecs.json...
Get-Content: /{path_to}/lucene.net/websites/apidocs/docs.ps1:222
Line |
 222 |          $xrefMap = Get-Content $xrefFile -Raw
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path '/{path_to}/lucene.net/websites/apidocs/_site/api/codecs/xrefmap.yml' because it does
     | not exist.