Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Metadata Not Generated GenerateManagedReferenceYamlFiles #9271

Closed
mwmatlock-eprod opened this issue Oct 4, 2023 · 1 comment
Closed
Labels
bug A bug to fix dotnet Generate .NET API reference docs

Comments

@mwmatlock-eprod
Copy link

mwmatlock-eprod commented Oct 4, 2023

Describe the bug
When using Docfx.Dotnet and Docfx.App to generate metadata within a c# build process, metadata is not generated. We get a Could not load file or assembly 'NuGet.Frameworks', then all of the usings fail - System, System.Web, etc.

Works fine from a command line manually run, and works fine from a cake build using dotnet tool.

To Reproduce
Steps to reproduce the behavior:

  1. Execute await DotnetApiCatalog.GenerateManagedReferenceYamlFiles(<path-to-docfx.json>);
  2. Every csproj fails to build with Could not load file or assembly 'NuGet.Frameworks' message

Expected behavior
Metadata to build from c# the same as dotnet tool run docfx metadata docfx.json does.

Context (please complete the following information):

  • OS: Windows

  • DocFx.Dotnet version: 2.71.0

  • DocFx.App version: 2.71.0

  • .NET version: .NET 7, .NET 6 doesn't matter which (tried with both)

  • docfx.json config

{
  "metadata": [
    {
      "dest": "api",
      "disableGitFeatures": false,
      "disableDefaultFilter": false,
      "namespaceLayout": "nested",
      "properties": {
        "TargetFramework": "netstandard2.1"
      },
      "src": [
        {
          "files": ["**/*.csproj"],
          "exclude": [
            "**/bin/**",
            "**/obj/**",
            "<project>.Web/**"
          ],
          "src": "../src"
        }
      ]
    }
  ],
  "build": {
    "content": [
      {
        "files": ["**/*.{md,yml}", "styles/*.css"],
        "exclude": ["<project>.Web/*.*"]
      }
    ],
    "cleanupCacheHistory": false,
    "dest": "<project>.Web",
    "disableGitFeatures": false,
    "fileMetadataFiles": [],
    "globalMetadata": {
      "_appTitle": "<project> Documentation",
      "_appName": "<project> Documentation",
      "_appFooter": "© 2023",
      "_appLogoPath": "images/<project>-logo_blue_square.png",
      "_appFaviconPath": "images/<project>-logo_blue_square.ico",
      "_disableContribution": false,
      "_lang": "en-us",
      "_noindex": true,
      "_gitUrlPattern": "vso",
      "_gitContribute": {
        "repo": "<project-repo>",
        "branch": "main"
      }
    },
    "globalMetadataFiles": [],
    "keepFileLink": false,
    "markdownEngineName": "markdig",
    "noLangKeyword": false,
    "overwrite": [
      {
        "exclude": ["obj/**", "<project>.Web/**"],
        "files": ["apidoc/**.md"]
      }
    ],
    "postProcessors": [],
    "resource": [
      {
        "files": ["images/**"]
      }
    ],
    "template": [
      "default",
      "modern",
      "<project>/singulinkfx",
      "<project>/<projectTemplate>"
    ]
  }
}
  • Exceptions
    50+ examples of the following, when trying to build for Net7:
warning: [Failure] Msbuild failed when processing the file '<project>.csproj' with message: C:\Program Files\dotnet\sdk\7.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets: (90, 5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.7.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)
File name: 'NuGet.Frameworks, Version=6.7.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 ---> System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.7.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at System.Runtime.Loader.AssemblyLoadContext.<LoadFromPath>g____PInvoke|5_0(IntPtr ptrNativeAssemblyBinder, UInt16* ilPath, UInt16* niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at Microsoft.Build.Shared.MSBuildLoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.<>c.<ExecuteCore>b__141_0(ITaskItem item)
   at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
warning: [Warning] Found project reference without a matching metadata reference: <project>.csproj
  • Exceptions
    50+ examples of the following, when trying to build for Net6:
warning: [Failure] Msbuild failed when processing the file '<project>.csproj' with message: C:\Program Files\dotnet\sdk\6.0.414\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets: (90, 5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.3.3.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)
File name: 'NuGet.Frameworks, Version=6.3.3.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 ---> System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.3.3.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at Microsoft.Build.Shared.MSBuildLoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
warning: [Warning] Found project reference without a matching metadata reference: <project>.csproj
  • .NET info
.NET SDK:
 Version:   7.0.401
 Commit:    eb26aacfec

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.401\

Host:
  Version:      7.0.11
  Architecture: x64
  Commit:       ecb34f85ec

.NET SDKs installed:
  3.1.401 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.414 [C:\Program Files\dotnet\sdk]
  7.0.401 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found
  • .NET --list-sdks
3.1.401 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.414 [C:\Program Files\dotnet\sdk]
7.0.401 [C:\Program Files\dotnet\sdk]
@mwmatlock-eprod mwmatlock-eprod added bug A bug to fix dotnet Generate .NET API reference docs labels Oct 4, 2023
@yufeih
Copy link
Contributor

yufeih commented Oct 5, 2023

Does it work to include <PackageReference Include="NuGet.Frameworks" Version="6.7.0" /> in your csproj?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix dotnet Generate .NET API reference docs
Projects
None yet
Development

No branches or pull requests

2 participants