Location of settings.yml #175
-
I like to keep my web site "sources" (Statiq's RootPath) separate from C# sources (C# project). I have successfully configured RootPath via the bootstrapper factory's ConfigureFileSystem extension method. To my surprise and dismay, however, Statiq does not recognize my I have isolated the cause in method Statiq.App.BootstrapperDefaultExtensions.AddDefaultConfigurationFiles where it uses the result of Is this by design? The rationale escapes me. Shouldn't Statiq be looking in RootPath instead? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The use of the working directory is by design to support the convention of having settings files in the same folder as the project and other .NET application artifacts (this is similar to ASP.NET or other applications that use the So long story short, the convention is to place settings files alongside the .NET project file and the Statiq "root path" is more about where the Statiq Like most things in Statiq, this is easily overridden if you'd like different behavior: await Bootstrapper.Factory
.CreateDefaultWithout(args, DefaultFeatures.Settings)
.AddWeb() // Omit if not using Statiq Web
.ConfigureFileSystem(fs => fs.RootPath = @"[whatever]\new-root")
.BuildConfiguration(builder => builder
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "new-root"))
.AddSettingsFile("settings"))
.RunAsync(); |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @daveaglick! Please bear with me, I've never used ASP.NET (Core or otherwise) so I'm not familiar with its conventions and best practices, and I'm learning as I go. |
Beta Was this translation helpful? Give feedback.
The use of the working directory is by design to support the convention of having settings files in the same folder as the project and other .NET application artifacts (this is similar to ASP.NET or other applications that use the
Microsoft.Extensions.Configuration
libraries. This is further solidified by setting theRunWorkingDirectory
MSBuild prop in theStatiq.App
targets file here: https://github.com/statiqdev/Statiq.Framework/blob/1a8bd58e6f1a4e63f0cae2870db78126bc511928/src/core/Statiq.App/Statiq.App.targets#L3 - that ensures the working directory is set to the same directory as the project file (so we don't get weird working directory behavior).So long story short, the convention …