GithubHelp home page GithubHelp logo

Comments (3)

daveaglick avatar daveaglick commented on May 18, 2024

Interesting! Did you just add an empty appsettings.json file, or did it contain anything? It looks as though it failed in the deployment pipeline while trying to get a particular value (though it's hard to tell what value). I'm going to move this issue over to Statiq Web since that's where the deployment pipeline lives and continue investigating.

from statiq.web.

daveaglick avatar daveaglick commented on May 18, 2024

Quick question - where are "NetlifySiteId" and "NetlifyAccessToken" defined? I see them being used to configure the Netlify deployment, but where are those values coming from? Were they defined anywhere before you added the appsettings.json file?

from statiq.web.

daveaglick avatar daveaglick commented on May 18, 2024

Ah, I see what's going on here. Basically, the DeployToNetlify() extension method is intended to specify the actual value of the NetlifySiteId and NetlifyAccessToken settings (whether that's directly or via something like a delegate). However, to allow more complicated logic it does take a Config<string>. Here's the code of that extension, which might make this a little clearer:

public static TBootstrapper DeployToNetlify<TBootstrapper>(
    this TBootstrapper bootstrapper,
    Config<string> siteId,
    Config<string> accessToken)
    where TBootstrapper : IBootstrapper =>
    bootstrapper
        .AddSettingsIfNonExisting(new Dictionary<string, object>
        {
            { WebKeys.NetlifySiteId, siteId },
            { WebKeys.NetlifyAccessToken, accessToken }
        });

See how it's just calling AddSettingsIfNonExisting()? When those settings aren't defined elsewhere, the Program.cs code above ends up adding them as Config.FromSetting<string>("NetlifySiteId"), etc. So what's happening is that the Netlify deployment module looks for the setting NetlifySiteId, finds it, and then evaluates the Config.FromSetting<string>("NetlifySiteId"), which looks for the setting NetlifySiteId, finds it, etc. on and on. By adding an appsettings.json file with those values, the AddSettingsIfNonExisting() sees that they're already defined and doesn't redefine them.

The "solution" here is to either specify the value of these settings directly in the Program.cs file, or specify them elsewhere like an appsettings.json file or an environment variable. In other words, you don't need to call DeployToNetlify() in your Program.cs at all if those settings are defined somewhere else - Statiq will find them and trigger the deployment if they're available. Think of the DeployToNetlify() extension not as a "turn it on" switch but as a "configure it" helper if that makes sense.

I'll make a note in the documentation to clarify this for all the deployment pipelines, and I also made a small improvement to how this sort of recursive key expansion is reported so it's clearer. Here's what your scenario (without the appsettings.json file) would output going forward:

image

from statiq.web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.