Whenever I try to build any documentation using docfx, I get the following error in the metadata build step that uses msbuild to analyze the xml comments in the code of the csprojs:
Warning:MetadataCommand.ExtractMetadataWorkspace failed with: [Failure] Msbuild failed when processing the file 'C:\temp\docfxtest\docfx_project\src\src.csproj' with message: Could not load SDK Resolver. A manifest file exists, but the path to the SDK Resolver DLL file could not be found. Manifest file path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver\Microsoft.Build.NuGetSdkResolver.xml'. SDK resolver path: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll C:\temp\docfxtest\docfx_project\src\src.csproj
It seems that msbuild cannot be correctly resolved by docfx. Any idea how I could fix this?
Im using docfx version 2.56.5.0 on Windows and I also have VS Enterprise 2019 (16.8.2) and VS Build Tools 2017 (15.9.29) installed:
UPDATE:
I have now uninstalled the VS 2017 build tools completely and repaired the VS 2019 installation using the installer. I now get a different error when I run docfx. It seems that it can't find msbuild at all anymore.
Warning:MetadataCommand.ExtractMetadataWorkspace failed with: [Failure] Msbuild failed when processing the file 'C:\temp\docfxtest\docfx_project\src\src.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found. C:\temp\docfxtest\docfx_project\src\src.csproj
Running msbuild -t:restore,build also shows that it can't find msbuild
'msbuild' is not recognized as an internal or external command
The targets are isntalled:
And so is the .NET Core workload:



Your Build Tool for VS2017 might have some problems due to some issues. The most issue is this:
Either you lost the dll or the dll is damaged.
Update
1) First, you should check whether you have installed
NuGet targets and build tasksworkload andnet core build toolsworkload. If not, please install it.2) Second, please delete
binandobjfolder of your project and then try again.You should use
msbuild -t:restore,buildto build your project.3) Third, try to Repair from
vs_installerfor your build tool. It will repair the related dll. And then deletebinandobjfolder, use build tool to test your project again.Important:
VS2017 does not support
net core 3.1. You should note that. It supports <=net core 2.1.So if you still want to use Build Tool of VS2017 for your net core project, you should try the the above three steps and then target your project to
net core 2.1.Besides, if you start
msbuildby CMD, I think you should check your environment variable PATH and check whether you have configured themsbuild.exefrom Build Tool of VS2017 on it. Instead, you could addC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe. This way is for VS2019.=================================================
Update 1
The problem is that you have already installed a
docfx toolby choco command line.At the beginning, I always thought that you used docfx.console nuget package on your project and just invoke
docfx.exefromC:\Users\xxx\.nuget\packages\docfx.console\2.56.5\tools\docfx.exeunder command line.Regardless of the installation of
docfx.consolepackage on your project, if you installed docfx tool by choco command and then just invokedocfx.exeon command line, it used the localdocfx.exeunderC:\ProgramData\chocolatey\lib\docfx\tools\docfx.exerather than the nuget package.So the issue is that your local
docfx.exehas some errors due to some issues. You should reinstall thedocfx.exeby choco commandchoco uninstall docfx; choco install docfx.Actually, directly use docfx.console nuget package on your project might be easier. From this link.
It already contains the generation step of the documentation by
docfx.exe(fromC:\Users\xxx\.nuget\packages\docfx.console\2.56.5\tools\docfx.exe) and will execute it automatically rather than rundocfx.exeagain manually.