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

Failing with UWP and Visual Studio 2019 (16.*) #5011

Closed
phraemer opened this issue Aug 21, 2019 · 8 comments
Closed

Failing with UWP and Visual Studio 2019 (16.*) #5011

phraemer opened this issue Aug 21, 2019 · 8 comments
Labels
bug A bug to fix dotnet Generate .NET API reference docs

Comments

@phraemer
Copy link

phraemer commented Aug 21, 2019

Operation System: Windows

DocFX Version Used: 2.44.0.0

Template used: default

Steps to Reproduce:

I made a clean UWP project with Visual Studio and beside it did docfx init -q and made the few changes I believed necessary to point it at the project.

I have a repo of the entire thing here:
https://github.com/phraemer/TestDocfx

Not sure if the TargetFramework should be net46 but previously it has worked with VS 2017 projects and older docfx versions like 2.40 or so.

Expected Behavior:

Generates the site.

Actual Behavior:

Errors out with:

λ docfx .\doc\docfx.json --serve
[19-08-21 01:21:47.893]Info:[MetadataCommand.ExtractMetadata]Environment variable VSINSTALLDIR is set to C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\, it is used as the inner compiler.
[19-08-21 01:21:48.059]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[19-08-21 01:21:48.420]Warning:[MetadataCommand.ExtractMetadata](C:/Users/james/Source/Repos/TestDocfx/TestDocfx/TestDocfx.csproj)Error opening project C:/Users/james/Source/Repos/TestDocfx/TestDocfx/TestDocfx.csproj: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.. Ignored.
[19-08-21 01:21:48.420]Info:[MetadataCommand]Completed Scope:MetadataCommand in 546.8394 milliseconds.
[19-08-21 01:21:48.420]Error:Error extracting metadata for C:/Users/james/Source/Repos/TestDocfx/TestDocfx/TestDocfx.csproj: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<SaveAllMembersFromCacheAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<ExtractMetadataAsync>d__11.MoveNext()
[19-08-21 01:21:48.420]Info:Completed in 551.1683 milliseconds


Build failed.
[19-08-21 01:21:48.436]Warning:[MetadataCommand.ExtractMetadata](C:/Users/james/Source/Repos/TestDocfx/TestDocfx/TestDocfx.csproj)Error opening project C:/Users/james/Source/Repos/TestDocfx/TestDocfx/TestDocfx.csproj: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.. Ignored.
[19-08-21 01:21:48.436]Error:Error extracting metadata for C:/Users/james/Source/Repos/TestDocfx/TestDocfx/TestDocfx.csproj: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<SaveAllMembersFromCacheAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<ExtractMetadataAsync>d__11.MoveNext()
        1 Warning(s)
        1 Error(s)
@jpenniman
Copy link

I have the same issue with:
VS 2019 16.3.5
DocFX 2.46.0

Building metadata for a netstandard2.0 class library.

PS C:\dev\xpike\xpike-extensions\docs> docfx metadata  
[19-10-16 09:31:18.821]Info:Config file docfx.json found, start generating metadata...
[19-10-16 09:31:19.063]Info:[ExtractMetadata]Environment variable VSINSTALLDIR is set to C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\, it is used as the inner compiler.
[19-10-16 09:31:19.360]Info:[ExtractMetadata]Loading projects...
[19-10-16 09:31:19.982]Warning:[ExtractMetadata](C:/dev/xpike/xpike-extensions/src/XPike.Extensions.DependencyInjection/XPike.Extensions.DependencyInjection.csproj)Error opening project C:/dev/xpike/xpike-extensions/src/XPike.Extensions.DependencyInjection/XPike.Extensions.DependencyInjection.csproj: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.. Ignored.
[19-10-16 09:31:19.984]Warning:[ExtractMetadata](C:/dev/xpike/xpike-extensions/src/XPike.Extensions.DependencyInjection.WebApi/XPike.Extensions.DependencyInjection.WebApi.csproj)Error opening project C:/dev/xpike/xpike-extensions/src/XPike.Extensions.DependencyInjection.WebApi/XPike.Extensions.DependencyInjection.WebApi.csproj: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.. Ignored.
[19-10-16 09:31:20.004]Error:Error extracting metadata for C:/dev/xpike/xpike-extensions/src/XPike.Extensions.DependencyInjection/XPike.Extensions.DependencyInjection.csproj,C:/dev/xpike/xpike-extensions/src/XPike.Extensions.DependencyInjection.WebApi/XPike.Extensions.DependencyInjection.WebApi.csproj: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<SaveAllMembersFromCacheAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<ExtractMetadataAsync>d__11.MoveNext()
[19-10-16 09:31:20.023]Info:Completed in 969.6849 milliseconds


Build failed.

docfx.json

{
  "metadata": [
      {
        "src": [
          {
            "src": "../src",
            "exclude": [ "**/bin/**", "**/obj/**" ],
            "files": [
              "**/*.csproj"
            ]
          }
        ],
        "dest": "api",
        "disableGitFeatures": false,
        "disableDefaultFilter": false,
        "properties": {
          "TargetFramework": "netstandard2.0"
        }
      }
    ]
}

@phraemer phraemer changed the title Failing with UWP and Visual Studio 2019 (16.2) Failing with UWP and Visual Studio 2019 (16.*) Oct 17, 2019
@phraemer
Copy link
Author

What can I do or how can I help to get this issue resolved?
I will help anyone as much as they need to fix this.

@superyyrrzz
Copy link
Contributor

Hi @phraemer , I tried building the project and got the warning below:

Warning:[ExtractMetadata](C:/git/TestDocfx/TestDocfx/TestDocfx.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\git\TestDocfx\TestDocfx\TestDocfx.csproj' with message: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\WindowsXaml\v16.3\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Also, tried to find "Microsoft\WindowsXaml\v16.3\Microsoft.Windows.UI.Xaml.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "c:\DocFX\2.48\docfx.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search 
paths.  C:\git\TestDocfx\TestDocfx\TestDocfx.csproj

From error message, I find msbuild was trying to locate Microsoft.Windows.UI.Xaml.CSharp.targets under the wrong folder v16.3. It should be v16.0 on my machine.

Then I modified the project like https://github.com/phraemer/TestDocfx/pull/1 and docfx can generate document successfully.

Note that you should use docfx >= 2.47 to avoid hitting #4782.

@superyyrrzz superyyrrzz added the dotnet Generate .NET API reference docs label Dec 17, 2019
@phraemer
Copy link
Author

Hi @superyyrrzz , thanks for looking into this. It looks like the error is different now since I last tried but your changes get us one step further. Does this mean we need to inform the MSBuild team or the Visual Studio team to fix that? Note that this is a clean project generated by Visual Studio.

After I merged your changes docfx does build a site but does not find anything to document in the project.
Are you seeing warnings like this now too?

C:\Users\James\source\repos\TestDocfx>docfx .\doc\docfx.json --serve
[19-12-17 11:48:38.911]Info:[MetadataCommand.ExtractMetadata]Using msbuild C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin as inner compiler.
[19-12-17 11:48:39.292]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[19-12-17 11:48:41.177]Warning:[MetadataCommand.ExtractMetadata](C:/Users/James/source/repos/TestDocfx/TestDocfx/TestDocfx.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\James\source\repos\TestDocfx\TestDocfx\TestDocfx.csproj' with message: The tools version "15.0" is unrecognized. Available tools versions are "Current", "4.0".  C:\Users\James\source\repos\TestDocfx\TestDocfx\TestDocfx.csproj
[19-12-17 11:48:41.357]Warning:[MetadataCommand.ExtractMetadata]Project 'C:\Users\James\source\repos\TestDocfx\TestDocfx\TestDocfx.csproj' does not contain any documents.

@superyyrrzz
Copy link
Contributor

I created an issue to Visual Studio for this: https://developercommunity.visualstudio.com/content/problem/862455/wrong-import-path-for-microsoftwindowsuixamlcsharp.html

I do not meet your new warnings. What version of Visual Studio are you using?

@phraemer
Copy link
Author

phraemer commented Jan 8, 2020

Hi sorry for the delay replying due to the holidays.

I just tried the repo I provided again with VS 16.4.2 and DocFX 2.48.1.0

The site does build and serve but again no docs produces for the comments and there are warnings:

[20-01-08 03:33:03.625]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[20-01-08 03:33:06.431]Warning:[MetadataCommand.ExtractMetadata](C:/Users/hover/source/repos/TestDocfx/TestDocfx/TestDocfx.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\hover\source\repos\TestDocfx\TestDocfx\TestDocfx.csproj' with message: C:\Users\hover\source\repos\TestDocfx\TestDocfx\TestDocfx.csproj: (0, 0): Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.'
[20-01-08 03:33:06.729]Info:[MetadataCommand.ExtractMetadata]Generating metadata for each project...
[20-01-08 03:33:08.020]Warning:[MetadataCommand.ExtractMetadata]Workspace failed with: [Failure] Could not find file 'C:\Users\hover\source\repos\TestDocfx\TestDocfx\obj\x64\Release\App.g.i.cs'.
[20-01-08 03:33:10.048]Info:[MetadataCommand]Completed Scope:MetadataCommand in 6627.509 milliseconds.
[20-01-08 03:33:10.129]Info:[BuildCommand]6 plug-in(s) loaded.
[20-01-08 03:33:10.146]Info:[BuildCommand]No files are found with glob pattern apidoc/**.md, excluding obj/**,_site/**, under directory "C:\Users\hover\source\repos\TestDocfx\doc"
[20-01-08 03:33:10.147]Info:[BuildCommand]No files are found with glob pattern images/**, excluding <none>, under directory "C:\Users\hover\source\repos\TestDocfx\doc"
[20-01-08 03:33:10.163]Info:[BuildCommand]Markdown engine is markdig
[20-01-08 03:33:10.174]Info:[BuildCommand]Cannot load build info: 'build.info' not found under 'C:\Users\hover\source\repos\TestDocfx\doc\obj\.cache\build'
[20-01-08 03:33:10.197]Info:[BuildCommand.BuildCore.Build Document]Max parallelism is 8.
[20-01-08 03:33:10.672]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.ManagedReferenceDocumentProcessor]Building 2 file(s) in ManagedReferenceDocumentProcessor(BuildManagedReferenceDocument=>ValidateManagedReferenceDocumentMetadata=>ApplyOverwriteDocumentForMref=>FillReferenceInformation)...
[20-01-08 03:33:10.673]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.TocDocumentProcessor]Building 3 file(s) in TocDocumentProcessor(BuildTocDocument)...
[20-01-08 03:33:10.674]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.ConceptualDocumentProcessor]Building 2 file(s) in ConceptualDocumentProcessor(BuildConceptualDocument=>CountWord=>ValidateConceptualDocumentMetadata)...
[20-01-08 03:33:11.373]Warning:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.TocDocumentProcessor.Save](toc.yml#L0)Invalid file link:(~/TestDocfx/index.md).
[20-01-08 03:33:11.374]Warning:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.TocDocumentProcessor.Save](toc.yml#L0)Invalid file link:(~/TestDocfx/index.md).
[20-01-08 03:33:11.383]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateContext]0 external references found in 1 xref maps.
[20-01-08 03:33:11.530]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateHref](toc.yml)Unable to find file "TestDocfx/index.md" for Homepage referenced by TOC file "toc.yml"
[20-01-08 03:33:11.531]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateHref](toc.yml)Unable to find file "TestDocfx/index.md" for Href referenced by TOC file "toc.yml"
[20-01-08 03:33:11.532]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateHref](toc.yml)Unable to find file "TestDocfx/index.md" for TopicHref referenced by TOC file "toc.yml"
[20-01-08 03:33:11.553]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.Apply Templates]Applying templates to 7 model(s)...
[20-01-08 03:33:11.895]Info:[BuildCommand.BuildCore.Build Document]XRef map exported.
[20-01-08 03:33:12.041]Info:[BuildCommand.Postprocess]Manifest file saved to manifest.json.
[20-01-08 03:33:12.128]Info:[BuildCommand]Completed building documents in 1995.7887 milliseconds.
Serving "C:\Users\hover\source\repos\TestDocfx\doc\_site" on http://localhost:8080

The line...

[20-01-08 03:33:08.020]Warning:[MetadataCommand.ExtractMetadata]Workspace failed with: [Failure] Could not find file 'C:\Users\hover\source\repos\TestDocfx\TestDocfx\obj\x64\Release\App.g.i.cs'.

made me suspect it needs building first.

So I built the solution in VS with Debug/x64 and ran docfx .\doc\docfx.json again and that first warning went away. Here's what the output looks like then:

C:\Users\hover\source\repos\TestDocfx>docfx .\doc\docfx.json --serve
[20-01-08 03:41:27.989]Info:[MetadataCommand.ExtractMetadata]Using msbuild C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin as inner compiler.
[20-01-08 03:41:28.175]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[20-01-08 03:41:31.410]Info:[MetadataCommand.ExtractMetadata]Generating metadata for each project...
[20-01-08 03:41:33.970]Info:[MetadataCommand]Completed Scope:MetadataCommand in 5996.6682 milliseconds.
[20-01-08 03:41:34.054]Info:[BuildCommand]6 plug-in(s) loaded.
[20-01-08 03:41:34.071]Info:[BuildCommand]No files are found with glob pattern apidoc/**.md, excluding obj/**,_site/**, under directory "C:\Users\hover\source\repos\TestDocfx\doc"
[20-01-08 03:41:34.073]Info:[BuildCommand]No files are found with glob pattern images/**, excluding <none>, under directory "C:\Users\hover\source\repos\TestDocfx\doc"
[20-01-08 03:41:34.087]Info:[BuildCommand]Markdown engine is markdig
[20-01-08 03:41:34.209]Info:[BuildCommand.BuildCore.Build Document]Max parallelism is 8.
[20-01-08 03:41:34.669]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.ConceptualDocumentProcessor]Building 0 file(s) in ConceptualDocumentProcessor(BuildConceptualDocument=>CountWord=>ValidateConceptualDocumentMetadata)...
[20-01-08 03:41:34.670]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.ManagedReferenceDocumentProcessor]Building 3 file(s) in ManagedReferenceDocumentProcessor(BuildManagedReferenceDocument=>ValidateManagedReferenceDocumentMetadata=>ApplyOverwriteDocumentForMref=>FillReferenceInformation)...
[20-01-08 03:41:34.671]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.TocDocumentProcessor]Building 3 file(s) in TocDocumentProcessor(BuildTocDocument)...
[20-01-08 03:41:35.369]Warning:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.TocDocumentProcessor.Save](toc.yml#L0)Invalid file link:(~/TestDocfx/index.md).
[20-01-08 03:41:35.374]Warning:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.TocDocumentProcessor.Save](toc.yml#L0)Invalid file link:(~/TestDocfx/index.md).
[20-01-08 03:41:35.382]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateContext]0 external references found in 1 xref maps.
[20-01-08 03:41:35.514]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateHref](toc.yml)Unable to find file "TestDocfx/index.md" for Homepage referenced by TOC file "toc.yml"
[20-01-08 03:41:35.515]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateHref](toc.yml)Unable to find file "TestDocfx/index.md" for Href referenced by TOC file "toc.yml"
[20-01-08 03:41:35.515]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.UpdateHref](toc.yml)Unable to find file "TestDocfx/index.md" for TopicHref referenced by TOC file "toc.yml"
[20-01-08 03:41:35.534]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.Apply Templates]Applying templates to 6 model(s)...
[20-01-08 03:41:36.041]Info:[BuildCommand.BuildCore.Build Document]XRef map exported.
[20-01-08 03:41:36.178]Info:[BuildCommand.Postprocess]Manifest file saved to manifest.json.
[20-01-08 03:41:36.237]Info:[BuildCommand]Completed building documents in 2180.1688 milliseconds.
Serving "C:\Users\hover\source\repos\TestDocfx\doc\_site" on http://localhost:8080

Is it a requirement for docfx that the solution or project is built first with VS or msbuild? I would have thought it builds whatever it needs itself. Did I miss something in the documentation?

I would expect to see the summary of the class MainPage in the generated site. Again perhaps I am on the wrong track. Could it be the docfx.json file generated by docfx init -q is not appropriate for a UWP app?

As always any help greatly appreciated and just ask if I can do anything to help.

@superyyrrzz
Copy link
Contributor

Is it a requirement for docfx that the solution or project is built first with VS or msbuild? I would have thought it builds whatever it needs itself. Did I miss something in the documentation?

Docfx runs msbuild internally. Normally you need not build it beforehand. However, I remembered in some case it need, e.g. when there is some unresotred nuget packages.

I would expect to see the summary of the class MainPage in the generated site. Again perhaps I am on the wrong track. Could it be the docfx.json file generated by docfx init -q is not appropriate for a UWP app?

I have not idea about this. You can create another issue for this with more details. I am closing this issue as UWP projects can build now.

@phraemer
Copy link
Author

phraemer commented Jan 9, 2020

Thanks for the fix!

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

3 participants