New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet-script use local tool #1231
Conversation
… with bundled version
@@ -21,7 +22,8 @@ public void DotnetScript_CSharpDecryptsVariables() | |||
var variables = GetVariables(); | |||
variables.Add(ScriptVariables.UseDotnetScript, bool.TrueString); | |||
File.WriteAllText(scriptFile.FilePath, "System.Console.WriteLine(OctopusParameters[\"mysecrect\"]);"); | |||
var result = ExecuteScript(new DotnetScriptExecutor(), scriptFile.FilePath, variables); | |||
var commandLineRunner = new TestCommandLineRunner(new InMemoryLog(), new CalamariVariables()); | |||
var result = ExecuteScript(new DotnetScriptExecutor(commandLineRunner), scriptFile.FilePath, variables); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried testing this, including a bundled dotnet-script package, extracting that to a path, and adding that path to the environment variables. In the test context this was not retrieving the executable path on the where/which
commands. I sunk a lot of time into this and couldn't work out why this wasn't working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -67,7 +67,8 @@ public async Task InstallTerraform() | |||
|
|||
await DownloadTerraform(fileName, client, tuple.data, destinationDirectoryName); | |||
|
|||
var terraformExecutable = Directory.EnumerateFiles(destinationDirectoryName).FirstOrDefault(); | |||
var terraformExecutable = Directory.EnumerateFiles(destinationDirectoryName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes test issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Initialize-AzureRmContext | ||
} | ||
else { | ||
if($OctopusAzureRMIsDepreciated -like [Boolean]::TrueString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rain-on I've inverted the check here for the sake of the tests. I can't see this changing any other behaviour but just wanted to raise this incase.
This change adds support for using a locally installed version of dotnet-script. Execution uses in order:
where/which
Deprecation warning
Note logs include additional logging for debugging purposes these lines are not included in the final PR.
dotnet-script tool installed on WSL Bash script
WSL container without dotnet-script on path
WSL executing dotnet-script file
dotnet-script tool installed on Windows .cmd on path
dotnet-script tool installed on Windows .exe on path
No dotnet-script tool installed on Windows (bundled)