fsprojects / FSharp.Formatting

F# tools for generating documentation (Markdown processor and F# code formatter)
https://fsprojects.github.io/FSharp.Formatting/
Other
464 stars 155 forks source link

Directory.Build.props is ignored if there are no projects or solutions #865

Closed nhirschey closed 10 months ago

nhirschey commented 10 months ago

It is useful to build a blog-style site using this tool, with configuration handled by Directory.Build.props. This is not possible with the default theme because Directory.Build.props is ignored when there is no project or solution. The generated site thus has broken links for FsDocsLicenseLink, FsDocsReleaseNotes, and RespositoryLink. The command line tool also says the values aren't set even when they are:

For instance with this in directory build props, I get the below error:

  <PropertyGroup>
    <FsDocsLicenseLink>https://github.com/nhirschey/Teaching/blob/main/LICENSE.md</FsDocsLicenseLink>
    <FsDocsReleaseNotesLink>https://github.com/nhirschey/Teaching/blob/main/CHANGELOG.md</FsDocsReleaseNotesLink>
    <RepositoryUrl>https://github.com/nhirschey/Teaching</RepositoryUrl>
  </PropertyGroup>
> dotnet fsdocs watch --noapidocs --ignoreprojects --clean
project files are ignored, no API docs will be generated
cracking projects...
please set '<FsDocsLicenseLink>' in 'Directory.Build.props'
please set '<FsDocsReleaseNotesLink>' in 'Directory.Build.props'
please set '<Version>' in 'Directory.Build.props'
please set '<RepositoryUrl>' in 'Directory.Build.props'
using extra content from C:\Users\Nicholas Hirschey\.nuget\packages\fsdocs-tool\19.1.1\extras
Building docs first time...
nojaf commented 10 months ago

Yes, this is expected. The way a Directory.Build.props file works is that it adds everything it contains to all the child *proj files in that directory. Only actual projects are being cracked, and so these properties won't flow through as globals if there is nothing to crack.

We could probably try and find a Directory.Build.props and process it as XML if there were no projects.

nojaf commented 10 months ago

There should be a fix for this in https://www.nuget.org/packages/fsdocs-tool/20.0.0-alpha-007.

nhirschey commented 10 months ago

Works great. Thank you! With this and other improvements I can now use the default theme on my teaching site.