ikvmnet / ikvm-maven

Support for adding dependencies on Maven artifacts to .NET projects, using IKVM.
MIT License
51 stars 5 forks source link

Roslyn error when trying to build API docs using docfx when there is a <MavenReference> #53

Open NightOwl888 opened 8 months ago

NightOwl888 commented 8 months ago

We have a very complex API docs setup. But basically what happens is:

  1. We generate metadata for the types by passing in the .csproj file to the docfx metadata command.
  2. The documentation then generated using docfx build command, which also takes the .csproj file.

The PowerShell script that does this is here: https://github.com/apache/lucenenet/blob/43e0e894b9b40f5b28064a13ef98874a82c15330/websites/apidocs/docs.ps1

During generation of the metadata, we are getting the following error. It only happens on the one project with <MavenReference> in it.

Building api metadata for F:\Projects\lucenenet\websites\apidocs\docfx.analysis-opennlp.json...
  Determining projects to restore...
  All projects are up-to-date for restore.
__________________________________________________
Project "F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\Lucene.Net.Analysis.OpenNLP.csproj" (Compile;CoreCompile target(s)):

ROSLYNCODETASKFACTORYCSHARPCOMPILER : error : Unknown command '/noconfig'.
F:\Users\shad\.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\shad\AppData\Local\Temp\MSBuildTempshad\tmp621cfe1311ac45b38cf0026eaca0c9d5.tmp"
F:\Users\shad\.nuget\packages\ikvm.image\8.7.5\buildTransitive\IKVM.Image.targets(95,9): error MSB4175: The task factory "RoslynCodeTaskFactory" could not be loaded from the assembly "C:\Program Files\dotnet\sdk\7.0.203\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property.
Done building project "Lucene.Net.Analysis.OpenNLP.csproj" -- FAILED.
warning: [Failure] Msbuild failed when processing the file 'F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\Lucene.Net.Analysis.OpenNLP.csproj' with message: ROSLYNCODETASKFACTORYCSHARPCOMPILER: (0, 0): Unknown command '/noconfig'.
warning: [Failure] Msbuild failed when processing the file 'F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\Lucene.Net.Analysis.OpenNLP.csproj' with message: F:\Users\shad\.nuget\packages\ikvm.image\8.7.5\buildTransitive\IKVM.Image.targets: (95, 9): The source file for this compilation can be found at: "C:\Users\shad\AppData\Local\Temp\MSBuildTempshad\tmp621cfe1311ac45b38cf0026eaca0c9d5.tmp"
warning: [Failure] Msbuild failed when processing the file 'F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\Lucene.Net.Analysis.OpenNLP.csproj' with message: F:\Users\shad\.nuget\packages\ikvm.image\8.7.5\buildTransitive\IKVM.Image.targets: (95, 9): The task factory "RoslynCodeTaskFactory" could not be loaded from the assembly "C:\Program Files\dotnet\sdk\7.0.203\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property.
warning: [Warning] Found project reference without a matching metadata reference: F:\Projects\lucenenet\src\dotnet\Lucene.Net.ICU\Lucene.Net.ICU.csproj
warning: [Warning] Found project reference without a matching metadata reference: F:\Projects\lucenenet\src\Lucene.Net\Lucene.Net.csproj
warning: [Warning] Found project reference without a matching metadata reference: F:\Projects\lucenenet\src\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj
warning: [Warning] Found project reference without a matching metadata reference: F:\Projects\lucenenet\src\Lucene.Net.Highlighter\Lucene.Net.Highlighter.csproj
warning: [Warning] Found project reference without a matching metadata reference: F:\Projects\lucenenet\src\Lucene.Net.Memory\Lucene.Net.Memory.csproj
warning: [Warning] Found project reference without a matching metadata reference: F:\Projects\lucenenet\src\Lucene.Net.Queries\Lucene.Net.Queries.csproj
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPChunkerFilter.cs(6,13): error CS0246: The type or namespace name 'J2N' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPChunkerFilter.cs(5,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPChunkerFilterFactory.cs(4,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPChunkerFilterFactory.cs(5,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPChunkerFilterFactory.cs(6,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPLemmatizerFilter.cs(6,13): error CS0246: The type or namespace name 'J2N' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPLemmatizerFilter.cs(5,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPLemmatizerFilterFactory.cs(4,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPLemmatizerFilterFactory.cs(5,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPLemmatizerFilterFactory.cs(6,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPPOSFilter.cs(6,13): error CS0246: The type or namespace name 'J2N' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPPOSFilter.cs(5,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPPOSFilterFactory.cs(4,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPPOSFilterFactory.cs(5,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPPOSFilterFactory.cs(6,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPSentenceBreakIterator.cs(2,7): error CS0246: The type or namespace name 'ICU4N' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPSentenceBreakIterator.cs(3,7): error CS0246: The type or namespace name 'ICU4N' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPSentenceBreakIterator.cs(6,7): error CS0246: The type or namespace name 'opennlp' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPSentenceBreakIterator.cs(7,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error: F:\Projects\lucenenet\src\Lucene.Net.Analysis.OpenNLP\OpenNLPSentenceBreakIterator.cs(8,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
warning: No .NET API detected for .

Build failed.

    10 warning(s)
    20 error(s)

Here are the contents from the C:\Users\shad\AppData\Local\Temp\MSBuildTempshad\tmp621cfe1311ac45b38cf0026eaca0c9d5.tmp, in case they are relevant.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace InlineCode {
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;

    public class _ExpandIkvmImageItems : Microsoft.Build.Utilities.Task {

        private string[] _TargetFrameworks;

        public virtual string[] TargetFrameworks {
            get {
                return _TargetFrameworks;
            }
            set {
                _TargetFrameworks = value;
            }
        }

        private string[] _RuntimeIdentifiers;

        public virtual string[] RuntimeIdentifiers {
            get {
                return _RuntimeIdentifiers;
            }
            set {
                _RuntimeIdentifiers = value;
            }
        }

        private Microsoft.Build.Framework.ITaskItem[] _Items;

        public virtual Microsoft.Build.Framework.ITaskItem[] Items {
            get {
                return _Items;
            }
            set {
                _Items = value;
            }
        }

        private bool _Success = true;

        public virtual bool Success {
            get {
                return _Success;
            }
            set {
                _Success = value;
            }
        }

        public override bool Execute() {

                var l = new List<ITaskItem>();

                foreach (var tfm in TargetFrameworks)
                {
                    foreach (var rid in RuntimeIdentifiers)
                    {
                        foreach (var item in Items)
                        {
                            var itemTfm = item.GetMetadata("TargetFramework");
                            if (string.IsNullOrEmpty(itemTfm))
                                continue;

                            var itemRid = item.GetMetadata("RuntimeIdentifier");
                            if (string.IsNullOrEmpty(itemRid))
                                continue;

                            if ((itemTfm == "any" || itemTfm == tfm) && (itemRid == "any" || itemRid == rid))
                            {
                                var i = new TaskItem(item);
                                i.SetMetadata("TargetFramework", tfm);
                                i.SetMetadata("RuntimeIdentifier", rid);
                                l.Add(i);
                            }
                        }
                    }
                }

                Items = l.ToArray();

            return Success;
        }
    }
}

Here is the link to the approach we are using: https://dotnet.github.io/docfx/docs/dotnet-api-docs.html#generate-from-projects-or-solutions

It uses MSBuildWorkspace to perform the build. We are using the target framework net6.0. I am not sure what that means in terms of compatibility with IKVM, but before going down the road of exploring one of the other doc generation methods, I was hoping to get some insight as to why this error occurs.

wasabii commented 8 months ago

Honestly, I don't really know what to do with this. It's a third party code base trying to parse the project files? Seems to be trying to run an inline task with a bad compiler version? Dunno.