docfx: Not working with .NET core .csproj files with Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props not found error
I have made a sample repository for reproducing the problem available at https://github.com/dlech/docfx_project.
I am using DocFX v2.18.4 installed from the chocolatey package on Windows 10 with VS 2017 Preview (15.3 preview 2).
This is basically the default docfx init with a C# project added to the src/ directory (dotnet new classlib -o src/) using dotnet2.0 preview tooling.
When running docfx, I get the unhelpful warning (see #1686):
[17-06-09 03:41:02.022]Warning:No metadata is generated for Core.
Running more than once results in an extra warning:
[17-06-09 04:19:08.622]Warning:Cache for C:/Users/david/Documents/GitHub/Dandy.Core/Dandy.Core.sln in C:\Users\david\Documents\GitHub\Dandy.Core\obj\xdoc\cache\final\-262745601 is corrupted
[17-06-09 04:19:08.622]Warning:No metadata is generated for Core.
After cherry-picking #1738, I get the additional message:
[17-06-09 04:23:49.102]Warning:Workspace failed with: [Failure] Msbuild failed when processing the file 'C:\Users\david\Documents\GitHub\Dandy.Core\src\Core.csproj' with message: The imported project "C:\users\david\Documents\GitHub\docfx\src\docfx\bin\Debug\net46\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\Users\david\Documents\GitHub\Dandy.Core\src\Core.csproj
So, it appears that DocFX is now expecting to find the .NET SDK in a folder relative to the docfx.exe.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 12
- Comments: 34 (11 by maintainers)
These two environment variables appear to resolve this issue - at least I get no more warnings in the output.
Hi @dealdiane , according to Microsoft/msbuild#1697 . there is a gap between msbuild tool and .NET core SDK build, so you have to install Visual Studio 2017 (not Build Tools but the full VS) on your build server as current workaround…
Based on your guys comments and a bit of digging around. I created a Power Shell script to get Visual Studio’s install path, use a specified .Net core SDK, and then set up environment variables before invoking docfx for a .Net Core solution.
It’s a little hacky, but it works.
Edit: This has been tested on AppVeyor and works really well. Here is my build script that’s invoked from
appveyor.yml:https://github.com/NZSmartie/CoAP.Net/blob/docs/docs/build.ps1
Could we get a summary of the appropriate hack to be using here? I’ve followed a couple of tips above, but they aren’t actually working (as others have already replied).
Unless I’m missing something, this is a pretty fundamental scenario that isn’t working. I’m not trying to do anything unusual, I just have a bog standard netstandard2.0 library that I added to a blank “
docfx init” project…@rschili Is it an option for you to point docfx at your compiled binaries? To avoid touching any environment variables as above I settled with that solution - as part of the build, I get docfx to generate metadata for the debug binaries in
bin. A bit more concise than looking at source files.So, there is a pretty good understanding now, what the issue is, but there is no good workaround, yet. Just like @jskeet I cannot put dll.config files into Program Files on a build machine, I do not have access to that folder. Visual Studio is also not installed on those machines, just the NET Core SDK.
Currently I am avoiding the issue by not including the csproj as metadata, but all *.cs files instead. Which is a very limited solution.
Is there an idea of how a non-workaround solution would look like?
Hi @alanedwardes, if it is netcore project, workaround https://github.com/dotnet/docfx/issues/1752#issuecomment-308909959 should work, no need to install VS.
Hi, has there been any progress on this issue? I’d like to avoid having to install Visual Studio on the build slave.
Hi @jskeet I doubt the issue is related to https://docs.microsoft.com/en-us/visualstudio/msbuild/what-s-new-in-msbuild-15-0 that
toolsversionis no longer in registry key. Try the following workaroundset MSBUILD_EXE_PATH=C:\Program Files\dotnet\sdk\2.0.0\MSBuild.dllMSBuild.dlland rename it toMSBuild.dll.config, this is themsbuild.exe.configfile I copied from a machine with VS2017 installed in which definesmsbuildToolsetsMSBuild.dll.config.txtIt works in my clean machine with only netcore 2.0 installed, please have a try
I should note that I don’t have any problem with the new *.csproj file format if I have VS2017 installed on the same machine. It only appears to be a problem when on a machine with just the .NET Core tools installed.