You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some strong preferences on how I like the structure of a project to look like, and so I have attempted to force the statiq engine to work in that way - in this case, I wanted the source code for the website to be in the root, instead of the input directory, and I wanted the C# project in a subdirectory, while keeping the temporary/cache files kept in that directory.
I have been able to make this work with the following code:
NormalizedPath root = new NormalizedPath(Directory.GetCurrentDirectory()).Parent;
return await Bootstrapper
.Factory
.CreateWeb(args)
.BuildConfiguration(builder => builder.SetBasePath(root.ToString()))
.ConfigureEngine(x =>
{
x.FileSystem.RootPath = root;
x.FileSystem.OutputPath = x.FileSystem.RootPath / "_output";
x.FileSystem.CachePath = x.FileSystem.RootPath / "_cache";
x.FileSystem.TempPath = x.FileSystem.RootPath / "_temp";
x.FileSystem.InputPaths.Clear();
x.FileSystem.InputPaths.Add(x.FileSystem.RootPath);
x.FileSystem.InputPaths.Add(x.FileSystem.RootPath / "static");
})
.AddSettingIfNonExisting(WebKeys.InputFiles, "**/{!_,}*")
.AddSettingIfNonExisting(
WebKeys.ExcludedPaths,
new[]
{
new NormalizedPath(".git"),
new NormalizedPath("statiq-site"), // This contains the cs and csproj files
new NormalizedPath("static"),
new NormalizedPath(".gitignore"),
})
.RunAsync();
I have found two issues with this approach:
First, it appears that the ExcludedPaths need to be relative paths to the InputPaths. That can be a bit of a problem, or not make that much sense, when there's more than one input path, as is the case here.
On the other hand, the ExcludedPaths will not be used by the generation engine, but they are still watched by the preview server, which seems to become a problem because the application object files are inside this directory, and so when a change happens in any file, the preview server modifies temporary data and object files, triggering a new rebuild, and entering an infinite rebuild loop. For now I have been been using the server without watching the directories, and manually calling Execute when I need to rebuild. I think this could be avoided by having the excluded paths also be considered by the preview server.
Finally, I have also found an unrelated issue with the preview server: when running it, if there is some compilation error while generating a cshtml file, the error keeps appearing in the generation logs after it has been fixed and the preview server has regenerated the site.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have some strong preferences on how I like the structure of a project to look like, and so I have attempted to force the statiq engine to work in that way - in this case, I wanted the source code for the website to be in the root, instead of the input directory, and I wanted the C# project in a subdirectory, while keeping the temporary/cache files kept in that directory.
I have been able to make this work with the following code:
I have found two issues with this approach:
First, it appears that the ExcludedPaths need to be relative paths to the InputPaths. That can be a bit of a problem, or not make that much sense, when there's more than one input path, as is the case here.
On the other hand, the ExcludedPaths will not be used by the generation engine, but they are still watched by the preview server, which seems to become a problem because the application object files are inside this directory, and so when a change happens in any file, the preview server modifies temporary data and object files, triggering a new rebuild, and entering an infinite rebuild loop. For now I have been been using the server without watching the directories, and manually calling
Executewhen I need to rebuild. I think this could be avoided by having the excluded paths also be considered by the preview server.Finally, I have also found an unrelated issue with the preview server: when running it, if there is some compilation error while generating a cshtml file, the error keeps appearing in the generation logs after it has been fixed and the preview server has regenerated the site.
Beta Was this translation helpful? Give feedback.
All reactions