(GH-1) Add ability to reset the ScriptHost #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I took an initial stab at this one and ended up going back to my initial idea of having a method that allows the dev to reset the
ScriptHost
.There are two scenarios I'm thinking:
Scenario 1: (Not covered by this PR) The host app is controlled by the Cake dev, and the app is aware that the code being run is a Cake script and knows about Cake.Bridge, so it could potentially use something like
ExecuteScoped
, etc.Scenario 2: (This PR) The host app is not controlled by the Cake dev, and the app is not aware that it's running a Cake script (all it knows is how to run C# code, and because it's referencing Cake.Bridge, everything magically works).
The goal in both scenarios is the same: Run a Cake script multiple times in the same process. Example of a Cake Script that would work after this PR:
build.cake:
We expect that the host app defines a constant
MYCAKEHOST
which tells us that CakeBridge is loaded and therefore we can call this method, otherwise running the.cake
script normally viadotnet cake
and other runners would just ignore this instruction.Let me know what you think.
This seemed the cleanest way to call into
Cake.Bridge
whilst still being able to run the same code via Cake, and without changing the original Cake script code too much.Closes #1