statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.64k stars 234 forks source link

With upgrade to latest version, Statiq.Web.targets excludes my extension code #994

Closed jermdavis closed 1 year ago

jermdavis commented 1 year ago

Not sure if this is an issue in Statiq, or if I should be using different naming convention, but:

I have a console app project with a couple of c# extensions to Statiq.Web in a folder named "Extensions". Nothing fancy - extra pipeline code to generate images from post titles, and format code snippets nicely. Up until recently that had worked fine, and my custom pipeline code all ran without issue.

Last week I updated to the latest nuget package for Statiq.Web and I noticed today that my extensions were no longer running. When I look at the solution in Visual Studio, I notice that my code files are no longer being compiled:

image

I can't mark these as compiled code any more - trying to mark their build action as "C# Compiler" gets this dialog:

image

The error message is:

An error has occurred while saving the edited properties listed below:
    Build Action
One or more values are invalid. Cannot add 'extensions\Enlighter\CustomMarkdownCodeBlockFormatterConfigurator.cs' to the project, because the path is explicitly excluded from the project (C:\Users\jeremy.davis\.nuget\packages\statiq.web\1.0.0-beta.49\buildTransitive\netcoreapp3.1\Statiq.Web.targets (4,5)).

If I open the .targets file specified there, I see that it explicitly excludes anything in the extensions folder:

<Project>
  <ItemGroup>
    <Compile Remove="theme\**" />
    <Compile Remove="extensions\**" />
    <Compile Remove="archetypes\**" />
  </ItemGroup>

  ... snip ...

</Project>

If I remove that second <Compile/> element from the file and rebuild, everything goes back to working. It looks to me that this file got changed in beta 49, based on the release notes?

So, based on all that: Should I not be using the folder / namespace name "Extensions" in my custom code to be compatible with the latest releases? Or is this an unintended side-effect of recent changes?

Not an urgent issue - but just wanted to check it wasn't a bug. (Thanks for all your work on this project though - much appreciated)

daveaglick commented 1 year ago

Yeah, I need to document the conventional folder names better and how to override that. extensions is "reserved" though unused at the moment - the idea is that eventually I'll introduce the ability to create theme-agnostic extensions (I.e. plug-ins) using the same runtime compilation features the themes do.

That's on the roadmap but at the moment as far as I've gotten is excluding the folder from compilation (since extensions will be compiled at runtime). It was actually supposed to be excluded all along but I had a bug with props vs. targets so it wasn't doing what it was supposed to.

Sorry! Is changing the name of your own folder to something else doable?

jermdavis commented 1 year ago

Not a problem - I can certainly change the name of the folder. I'll do that.

Thanks for the information, and for the quick response.