Can't generate metadata for *.csproj files that reference other projects
Operating System: macOS Big Sur 11.6 (20G165)
DocFX Version Used: 2.59.2.0 (brewed)
Template used: default
Steps to Reproduce:
Attached there's a Unity project with .csproj files generated by [email protected].
-
ASM1.csproj— doesn't reference other projects, works ✅ -
ASM2.csproj— references ASM1, doesn't work ❌
- Download unity-test.zip and unzip.
- Run
docfx metadata --force docfx_project/docfx_ko.json
Expected Behavior:
Metadata gets generated for ASM2.csproj
Actual Behavior:
frarees@MBP18 unity-test % docfx metadata --force docfx_project/docfx_ko.json
[22-06-14 12:00:21.260]Info:[ExtractMetadata]Using mono /Library/Frameworks/Mono.framework/Versions/6.13.0/lib/mono/msbuild/15.0/bin/MSBuild.dll as inner compiler.
[22-06-14 12:00:21.367]Info:[ExtractMetadata]Loading projects...
[22-06-14 12:00:22.761]Warning:[ExtractMetadata](/Users/frarees/Documents/unity-test/ASM2.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file '/Users/frarees/Documents/unity-test/ASM2.csproj' with message: /Library/Frameworks/Mono.framework/Versions/6.13.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets: (1733, 5): The "GetReferenceNearestTargetFrameworkTask" task failed unexpectedly.
System.MissingMethodException: Method not found: NuGet.Frameworks.NuGetFramework NuGet.Frameworks.NuGetFramework.ParseComponents(string,string)
at NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask.Execute () [0x00142] in <284aae14d5034455899563954b017376>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <8a3f180d637a418b9f0224e63aca8555>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002b9] in <8a3f180d637a418b9f0224e63aca8555>:0
[22-06-14 12:00:23.236]Warning:[ExtractMetadata](/Users/frarees/Documents/unity-test/ASM2.csproj)Workspace failed with: [Warning] Found project reference without a matching metadata reference: /Users/frarees/Documents/unity-test/ASM1.csproj
[22-06-14 12:00:23.508]Info:[ExtractMetadata]Generating metadata for each project...
[22-06-14 12:00:24.403]Info:Completed in 3169.0223 milliseconds
Build succeeded with warning.
[22-06-14 12:00:24.406]Warning:[ExtractMetadata](/Users/frarees/Documents/unity-test/ASM2.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file '/Users/frarees/Documents/unity-test/ASM2.csproj' with message: /Library/Frameworks/Mono.framework/Versions/6.13.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets: (1733, 5): The "GetReferenceNearestTargetFrameworkTask" task failed unexpectedly.
System.MissingMethodException: Method not found: NuGet.Frameworks.NuGetFramework NuGet.Frameworks.NuGetFramework.ParseComponents(string,string)
at NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask.Execute () [0x00142] in <284aae14d5034455899563954b017376>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <8a3f180d637a418b9f0224e63aca8555>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002b9] in <8a3f180d637a418b9f0224e63aca8555>:0
[22-06-14 12:00:24.406]Warning:[ExtractMetadata](/Users/frarees/Documents/unity-test/ASM2.csproj)Workspace failed with: [Warning] Found project reference without a matching metadata reference: /Users/frarees/Documents/unity-test/ASM1.csproj
2 Warning(s)
0 Error(s)
The docfx.console/2.59.0 NuGet package does not contain NuGet.Build.Tasks.dll, and contains a NuGet.Frameworks.dll (informational version 5.7.0+b804bf4ba62c0b47c77bbf3e22e196b57cd7a556.b804bf4ba62c0b47c77bbf3e22e196b57cd7a556, assembly version 5.7.0.7) that does not define a NuGet.Frameworks.NuGetFramework.ParseComponents method. Perhaps your brewed DocFX 2.59.2 has the same situation.
.NET SDK 6.0.300 for Windows includes a NuGet.Build.Tasks.dll (informational version 6.2.0-rc.146+b8a61266d9a6780cb7eb9c1942695cf813fdef0a.b8a61266d9a6780cb7eb9c1942695cf813fdef0a, assembly version 6.2.0.146, referencing NuGet.Frameworks 6.2.0.146) in which NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask.Execute does not directly call NuGet.Frameworks.NuGetFramework.ParseComponents, but can call it indirectly via NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask.GetNuGetFramework or NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask.TryParseFramework. NuGet 5.8.0.6783 seems to be the first release that includes those calls.
I guess NuGet.Build.Tasks.dll is loaded from Mono in your scenario, and is newer than the NuGet.Frameworks.dll that you have in DocFX. Would it work if you just replaced the NuGet DLLs in DocFX with the newer DLLs from Mono? Although I suppose it would be better to rebuild DocFX referencing the newer NuGet packages.
Thanks for the tip.
I've tried this:
Copy NuGet* files on /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin into /usr/local/Cellar/docfx/2.59.2/libexec.
It removed the warnings about NuGet, however, I still get:
frarees@MBP18 unity-test % docfx metadata --force docfx_project/docfx_ko.json
[22-06-14 11:08:07.879]Info:[ExtractMetadata]Using mono /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0/bin/MSBuild.dll as inner compiler.
[22-06-14 11:08:07.999]Info:[ExtractMetadata]Loading projects...
[22-06-14 11:08:09.991]Warning:[ExtractMetadata](/Users/frarees/Documents/unity-test/ASM2.csproj)Workspace failed with: [Warning] Found project reference without a matching metadata reference: /Users/frarees/Documents/unity-test/ASM1.csproj
[22-06-14 11:08:10.246]Info:[ExtractMetadata]Generating metadata for each project...
[22-06-14 11:08:11.358]Info:Completed in 3494.5765 milliseconds
Build succeeded with warning.
[22-06-14 11:08:11.360]Warning:[ExtractMetadata](/Users/frarees/Documents/unity-test/ASM2.csproj)Workspace failed with: [Warning] Found project reference without a matching metadata reference: /Users/frarees/Documents/unity-test/ASM1.csproj
1 Warning(s)
0 Error(s)
Similar Q# incompatibility with .NET SDK https://github.com/dotnet/sdk/issues/26065#issuecomment-1159051054