Docfx: DocFX fails when importing targets files in csproj files

Created on 29 Mar 2018  路  7Comments  路  Source: dotnet/docfx

DocFX Version Used: 2.33

Template used: DocFX vsts build step here: https://marketplace.visualstudio.com/items?itemName=chrismason.vsts-docfxtasks

Issue was tracked down to metadata build step. Build machine configuration: VS 2015 using VSTS build agent.

Investigation reveals this issue seemed to appear around version 2.26. Based off the error, it seems likely the the search path for the default targets files is changed to the docfx tool path and not the default MSBuildToolsPath.

Steps to Reproduce:

  1. Attempt to directly generate metadata with the command "docfx metadata test.csproj". test.csproj has a reference at the end to:
  2. DocFX prints out a warning:
    Warning:[MetadataCommand.ExtractMetadata]Workspace failed with: [Failure] Msbuild failed when processing the file 'W:\agent_work\291\s\test.csproj' with message: The imported project "W:\agent_work_tasks\DocFxTask_e0923c33-09f9-43a0-a8af-86b7d0d76b03\0.1.19\tools\docfx.console.2.28.1\tools\Microsoft.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. W:\agent_work\291\s\test.csproj

Expected Behavior:
TOC is generated and build succeeds.

Actual Behavior:
No TOC generated, build fails.

Area-Metadata Area-Metadatvs2019 bug

Most helpful comment

Seeing this when vs 2019 is installed but vs 2017 is not

All 7 comments

Possibly related to https://github.com/Microsoft/MSBuildLocator/issues/18 as we leverage MSBuildLocator to find VS instance however it does not currently support VS2015.
Hi @miketabet To workaround your issue, is it possible that you update to use VS2017 VSTS build agent?

I don't think there's a specific VS 2017 agent, but we'll try a side by side install and see if that works. Thanks for the feedback.

Installing VS 2017 build tools on the build machine seems to have resolved the issue - thanks for the guidance!

I had the very same issue, again with VS2015, and solved it following @miketabet advice and installing VS2017 Build Tools (the Web Applications module in particular seems the one that did the trick in my case, together with the varius .NET Framework SDKs).
I think it would be helpful to add this information to the Getting started page, maybe in a "Using VS2015 or lower" labeled box.

Seeing this when vs 2019 is installed but vs 2017 is not

Got this error after I upgraded to Visual Studio 2019. I opened up the installer and reinstalled VS2017 (selected only the .NET tools) alongside 2019 and the error disappeared.

The following workaround fixes the issue if you have VS2019 only and don't want to install VS2017:

  1. Install VS2017 build tools from here: https://aka.ms/vs/15/release/vs_buildtools.exe. Build tools doesn't include IDE and takes ~100 MB of disk space only.
  2. Go to C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver
  3. Open the file Microsoft.Build.NuGetSdkResolver.xml
  4. Replace its content with this:
<SdkResolver>
  <Path>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll</Path>
</SdkResolver>
Was this page helpful?
0 / 5 - 0 ratings