dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.06k stars 862 forks source link

Error: [Failure] Msbuild failed when processing the file '[FilePath]' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found. #4880

Closed 9ee1 closed 1 year ago

9ee1 commented 5 years ago

Operation System: (Windows or Linux or MacOS) Windows, Windows 10 X64

DocFX Version Used: docfx 2.43.2.0, Visual Studio 2019 Community Edition, Visual Studio Build Tools 2019, .NET Core 2.1.x to 2.2.x SDKs. This is a .NET Standard 2.0 project.

Template used: (default or statictoc or contain custom template) default

Steps to Reproduce:

  1. Run docfx metadata from the command line

Expected Behavior: Metadata is generated. This is a .NET Standard 2.0 project.

Actual Behavior: No metadata is generated. Error is [Failure] Msbuild failed when processing the file '[FilePath]' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found.

I have seen other tickets, most notably #1752, but it still not clear what the solution is. I have tried all the "hacks" there to no avail. Do we still need Visual Studio Build Tools 2017? If so from where? I tried going to https://visualstudio.microsoft.com/vs/older-downloads/ and I login as instructed but it says no downloads are available for my account. Do I really need to buy a subscription to get this to work? Furthermore, at https://visualstudio.microsoft.com/vs/older-downloads/, Visual Studio Build Tools 2017 is not even listed.

Please refer to https://github.com/dotnet/docfx/issues/1752#issuecomment-341879582. That comment is 2 years old and there still has been no clear guidance on what the problem is and how to solve it.

Also, https://github.com/dotnet/docfx/issues/1907#issuecomment-318240898 suggests installing the full Visual Studio 2017 but that comment is also 2 years old. What if our account doesn't allow us to download Visual Studio 2017 anymore?

I realize this problem is probably just as frustrating for you as it is for the community, so I appreciate your patience.

C:\Users\dev\Documents\Gee.External.Browsing\docfx_project>docfx metadata
[19-07-15 10:43:09.471]Info:Config file docfx.json found, start generating metadata...
[19-07-15 10:43:09.669]Info:[ExtractMetadata]Using msbuild C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin as inner compiler.
[19-07-15 10:43:09.860]Info:[ExtractMetadata]Loading projects...
[19-07-15 10:43:10.699]Warning:[ExtractMetadata](C:/Users/dev/Documents/Gee.External.Browsing/Gee.External.Browsing/Gee.External.Browsing.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\dev\Documents\Gee.External.Browsing\Gee.External.Browsing\Gee.External.Browsing.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found.  C:\Users\dev\Documents\Gee.External.Browsing\Gee.External.Browsing\Gee.External.Browsing.csproj
[19-07-15 10:43:10.771]Warning:[ExtractMetadata]Project 'C:\Users\dev\Documents\Gee.External.Browsing\Gee.External.Browsing\Gee.External.Browsing.csproj' does not contain any documents.
[19-07-15 10:43:10.782]Info:[ExtractMetadata]Generating metadata for each project...
[19-07-15 10:43:11.138]Warning:[ExtractMetadata]No metadata is generated for Gee.External.Browsing.
[19-07-15 10:43:11.143]Info:Completed in 1493.3083 milliseconds

Build succeeded with warning.
[19-07-15 10:43:11.149]Warning:[ExtractMetadata](C:/Users/dev/Documents/Gee.External.Browsing/Gee.External.Browsing/Gee.External.Browsing.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\dev\Documents\Gee.External.Browsing\Gee.External.Browsing\Gee.External.Browsing.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found.  C:\Users\dev\Documents\Gee.External.Browsing\Gee.External.Browsing\Gee.External.Browsing.csproj
[19-07-15 10:43:11.149]Warning:[ExtractMetadata]Project 'C:\Users\dev\Documents\Gee.External.Browsing\Gee.External.Browsing\Gee.External.Browsing.csproj' does not contain any documents.
[19-07-15 10:43:11.149]Warning:[ExtractMetadata]No metadata is generated for Gee.External.Browsing.
        3 Warning(s)
        0 Error(s)
eastjie commented 5 years ago

In my system, I have had the same error. After updating my "docfx" version to 2.43.3. It works. My Visual Studio 2019 is Version 16.1.6 Enterprise and .NET Core version is 2.2.104.

On other VM, I have only Visual Studio Build Tools 2019 without Visual Studio IDE. It works. I don't know Community Edition. If both IDE and Build Tools are installed, could be the problem?

ghost commented 5 years ago

Same problem, how can I create docs for a .NET Core project. FYI: my project is a multi-target project.

From my .csproj file.

<TargetFrameworks>netstandard2.0;netcoreapp3.0;net45</TargetFrameworks>
superyyrrzz commented 5 years ago

@kdawg1406 This may help: https://github.com/dotnet/docfx/issues/1254#issuecomment-294080535

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If you still think this issue is relevant, please feel free to ping a maintainer or leave a comment.

edika99 commented 4 years ago

Same problem for me. Target is net472 and netcoreapp3.1 I've set the targetframework on net472 in docfx.json Using Visual Studio Community 2019 16.6.3 and Visual studio Build Tools 2017

1>[20-10-20 09:17:11.198]Warning:[MetadataCommand.ExtractMetadata](D:/Source/Repos/EDK4NetMultiTarget/EDK4NetMultiTarget.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'D:\Source\Repos\EDK4NetMultiTarget\EDK4NetMultiTarget.csproj' with message: l'SDK 'Microsoft.NET.Sdk' specificato non è stato trovato. D:\Source\Repos\EDK4NetMultiTarget\EDK4NetMultiTarget.csproj 1>[20-10-20 09:17:11.198]Warning:[MetadataCommand.ExtractMetadata]Project 'D:\Source\Repos\EDK4NetMultiTarget\EDK4NetMultiTarget.csproj' does not contain any documents. 1>[20-10-20 09:17:11.198]Warning:[MetadataCommand.ExtractMetadata]No metadata is generated for EDK4NetMultiTarget. 1>[20-10-20 09:17:11.198]Warning:[BuildCommand.BuildCore.Build Document.Load.TocDocumentProcessor](articles/toc.yml)Skipping GetFileDetail. Exception found: Microsoft.DocAsCode.Common.Git.GitException, Message: 1>[20-10-20 09:17:11.198]Warning:[BuildCommand.BuildCore.Build Document.Load.TocDocumentProcessor](api/toc.yml)Skipping GetFileDetail. Exception found: Microsoft.DocAsCode.Common.Git.GitException, Message: 1>[20-10-20 09:17:11.198]Warning:[BuildCommand.BuildCore.Build Document.Load.TocDocumentProcessor](toc.yml)Skipping GetFileDetail. Exception found: Microsoft.DocAsCode.Common.Git.GitException, Message: `

cn-ml commented 3 years ago

Same Problem for me: although i only target one version net5.0. I use docfx version 2.56.6:

[21-02-05 05:30:04.198]Info:Config file docfx.json found, start generating metadata...
[21-02-05 05:30:04.360]Info:[MetadataCommand.ExtractMetadata]Using msbuild C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin as inner compiler.
[21-02-05 05:30:04.548]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[21-02-05 05:30:05.759]Warning:[MetadataCommand.ExtractMetadata](C:/Users/<UserName>/source/repos/<ProjectName>/<ProjectName>/<ProjectName>.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\<ProjectName>.csproj' with message: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\<ProjectName>.csproj
[21-02-05 05:30:05.872]Warning:[MetadataCommand.ExtractMetadata]Project 'C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\<ProjectName>.csproj' does not contain any documents.
[21-02-05 05:30:05.905]Info:[MetadataCommand.ExtractMetadata]Cache for C:/Users/<UserName>/source/repos/<ProjectName>/<ProjectName>/<ProjectName>.csproj in C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\obj\xdoc\cache\final\-236949522 is corrupted, rebuild...
[21-02-05 05:30:05.908]Info:[MetadataCommand.ExtractMetadata]Generating metadata for each project...
[21-02-05 05:30:06.113]Info:[MetadataCommand.ExtractMetadata]'C:/Users/<UserName>/source/repos/<ProjectName>/<ProjectName>/<ProjectName>.csproj' keep up-to-date since '2/5/2021 5:14:16 PM', cached intermediate result 'C:/Users/<UserName>/source/repos/<ProjectName>/<ProjectName>/obj/xdoc/cache/obj\b3fb53ss.zfm' is used.
[21-02-05 05:30:06.229]Warning:[MetadataCommand.ExtractMetadata]No metadata is generated for <ProjectName>.
[21-02-05 05:30:06.279]Info:[MetadataCommand]Completed Scope:MetadataCommand in 1939.1716 milliseconds.
[21-02-05 05:30:06.406]Info:[BuildCommand]6 plug-in(s) loaded.
[21-02-05 05:30:06.431]Info:[BuildCommand]No files are found with glob pattern apidoc/**.md, excluding obj/**,_site/**, under directory "C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>"
[21-02-05 05:30:06.435]Info:[BuildCommand]No files are found with glob pattern images/**, excluding <none>, under directory "C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>"
[21-02-05 05:30:06.458]Info:[BuildCommand]Markdown engine is markdig
[21-02-05 05:30:06.617]Info:[BuildCommand.BuildCore.Build Document]Max parallelism is 8.
[21-02-05 05:30:07.353]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.TocDocumentProcessor]Building 3 file(s) in TocDocumentProcessor(BuildTocDocument)...
[21-02-05 05:30:07.355]Info:[BuildCommand.BuildCore.Build Document.CompilePhaseHandlerWithIncremental.ConceptualDocumentProcessor]Building 0 file(s) in ConceptualDocumentProcessor(BuildConceptualDocument=>CountWord=>ValidateConceptualDocumentMetadata)...
[21-02-05 05:30:07.612]Info:[BuildCommand.BuildCore.Build Document.LinkPhaseHandlerWithIncremental.Apply Templates]Applying templates to 3 model(s)...
[21-02-05 05:30:08.070]Info:[BuildCommand.BuildCore.Build Document]XRef map exported.
[21-02-05 05:30:08.225]Info:[BuildCommand.Postprocess]Manifest file saved to manifest.json.
[21-02-05 05:30:08.286]Info:[BuildCommand]Completed building documents in 1873.4641 milliseconds.
[21-02-05 05:30:08.290]Info:[BuildCommand]Completed Scope:BuildCommand in 2008.6394 milliseconds.
[21-02-05 05:30:08.292]Info:Completed in 3955.3164 milliseconds

Build succeeded with warning.
[21-02-05 05:30:08.303]Warning:[MetadataCommand.ExtractMetadata](C:/Users/<UserName>/source/repos/<ProjectName>/<ProjectName>/<ProjectName>.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\<ProjectName>.csproj' with message: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\<ProjectName>.csproj
[21-02-05 05:30:08.306]Warning:[MetadataCommand.ExtractMetadata]Project 'C:\Users\<UserName>\source\repos\<ProjectName>\<ProjectName>\<ProjectName>.csproj' does not contain any documents.
[21-02-05 05:30:08.307]Warning:[MetadataCommand.ExtractMetadata]No metadata is generated for <ProjectName>.
        3 Warning(s)
        0 Error(s)
jamesmcroft commented 3 years ago

Seeing a similar issue except I'm using MSBuild.Sdk.Extras.

My project files use additional target frameworks for Windows, Android, iOS, and macOS, e.g.

<Project Sdk="MSBuild.Sdk.Extras">
  <PropertyGroup>
    <TargetFrameworks>uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0;xamarinmac20</TargetFrameworks>
  </PropertyGroup>
</Project>

Results in

[21-04-05 08:58:46.849]Warning:[MetadataCommand.ExtractMetadata](C:/S/<repo>/src/<project>/<project>.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'C:/S/<repo>/src/<project>/<project>.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:/S/<repo>/src/<project>/<project>.csproj
jamiehankins commented 3 years ago

I've been dealing with this for two days. What fixed it was bumping "Microsoft.Build.Locator" from "1.2.2" to "1.4.1" on Microsoft.DocAsCode.Metadata.ManagedReference.csproj. Hopefully, they will take a PR for it.

zpqrtbnk commented 3 years ago

DocFX 2.58 was just released. Tested, and it indeed fixes the issue. Thanks @jamiehankins !!

Arlodotexe commented 2 years ago

Also getting this error message and have been trying to resolve it off and on for several months now. Only targeting netstandard2.0. Even with a fresh docfx init project, only changed to reference the csproj, I'm seeing this. Running the latest docfx and tried just about every trick and bit of advice on here.

blackjack4494 commented 2 years ago

Unfortunately I was one of those unlucky persons to come across this error as well.


My situation:

No Visual Studio installed (instead I used Build Tools to get msbuild https://visualstudio.microsoft.com/downloads/?q#build-tools-for-visual-studio-2022) No environment variable MSBuildSDKsPath set Dotnet SDK 6.0.201 (installed from here https://dotnet.microsoft.com/en-us/download)


The project I am working on is using netstandard2.1 as Target Framework.

After seeing multiple issues on Github and on other sites including Stackoverflow with various 'solutions' I tried some of them. But they all did not really work.

Ultimately this solution worked (https://stackoverflow.com/a/64679752/1515686):

  1. Run the Visual Studio Installer which came with Build Tools
  2. Select Modify on the installed Build Tools version (for me 2022)
  3. Go to Individual Components and select .Net SDK and hit install image

It worked afterwards. Before that dotnet folder was only residing in C:\Program Files Afterwards a second one got added to C:\Program Files (x86) even though it is apparently not used.

Just wanted to leave this here in case anyone comes across this issue (sadly) as well. Hopefully this will help you.