docfx generation with preprocessor directives (symbols/constants)

375 views Asked by At

I have set up a docfx project to generate documentation from the source code for a c# library project. However, it doesn't seem to work when I have preprocessing directives in, for example:

#if NET48
/// <summary>
/// An example class.
/// </summary>
public class MyClass {

}
#endif

I have added the TargetFramework under the metadata properties in the 'docfx.json' file and also even tried DefineConstants, but neither seem to be working. It generates the documentation when I don't have directives in, but I am targeting both 'net48' and 'netstandard2.0', with preprocessor directives excluding functionality that won't work in .net standard.

Update The TargetFramework appears to be ignored when I use **.cs instead of **.csproj. A 'docfxfix.cs' file just with #define NET48 appears to be a workaround when not using a project file.

When I run docfx from a normal command prompt (i.e. msbuild not in path), I get the error 'A manifest file exists, but the path to the SDK Resolver DLL file could not be found.'. This is even with the latest build tools installed for 2017. If I run after launching a developer command prompt for VS2019 it appears to be OK (though I sometimes need to delete the 'obj' folder and 'api.yml' files).

0

There are 0 answers