Skip to content

Commit 9c5afa0

Browse files
authored
Merge pull request #1818 from OctopusDeploy/mergebot/from-release-2026.1-to-main-412305fe8
[Auto-merge from release/2026.1 to main] Merge mergebot/from-release-2026.1-to-main-412305fe8 to main
2 parents b59eef2 + 1c6bfb1 commit 9c5afa0

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

source/Calamari.Common/Features/Scripting/DotnetScript/DotnetScriptBootstrapper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@ public static string FindBundledExecutable()
9595
throw new CommandException(string.Format("dotnet-script was not found at '{0}'", executable));
9696
}
9797

98-
public static string FormatCommandArguments(string bootstrapFile, string? scriptParameters)
98+
public static string FormatCommandArguments(string bootstrapFile, string? scriptParameters, string? nugetSource = null)
9999
{
100100
var (scriptCommandArguments, scriptArguments) = RetrieveParameterValues(scriptParameters);
101101
var encryptionKey = Convert.ToBase64String(VariableEncryptor.EncryptionKey);
102+
var source = string.IsNullOrWhiteSpace(nugetSource) ? "https://api.nuget.org/v3/index.json" : nugetSource;
102103
var commandArguments = new StringBuilder();
103-
commandArguments.Append("-s https://api.nuget.org/v3/index.json ");
104+
commandArguments.Append($"-s {source} ");
104105
if (!string.IsNullOrWhiteSpace(scriptCommandArguments)) commandArguments.Append($"{scriptCommandArguments} ");
105106
commandArguments.AppendFormat("\"{0}\" -- {1} \"{2}\"", bootstrapFile, scriptArguments, encryptionKey);
106107
return commandArguments.ToString();

source/Calamari.Common/Features/Scripting/DotnetScript/DotnetScriptExecutor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ protected override IEnumerable<ScriptExecution> PrepareExecution(Script script,
3232

3333
var configurationFile = DotnetScriptBootstrapper.PrepareConfigurationFile(workingDirectory, variables);
3434
var (bootstrapFile, otherTemporaryFiles) = DotnetScriptBootstrapper.PrepareBootstrapFile(script.File, configurationFile, workingDirectory, variables);
35-
var arguments = DotnetScriptBootstrapper.FormatCommandArguments(bootstrapFile, script.Parameters);
35+
var nugetSource = variables.Get("Octopus.Action.Script.CSharp.NuGetSource");
36+
var arguments = DotnetScriptBootstrapper.FormatCommandArguments(bootstrapFile, script.Parameters, nugetSource);
3637
bool.TryParse(variables.Get("Octopus.Action.Script.CSharp.BypassIsolation", "false"), out var bypassDotnetScriptIsolation);
3738

3839
var cli = CreateCommandLineInvocation(executable, arguments, !string.IsNullOrWhiteSpace(localDotnetScriptPath));

source/Calamari.Tests/Fixtures/DotnetScript/DotnetScriptBootstrapperFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,15 @@ public void FormatCommandArgumentsTest([CanBeNull] string scriptParameters, [Can
2121
var formattedCommandArgument = DotnetScriptBootstrapper.FormatCommandArguments(bootstrapFile, scriptParameters);
2222
formattedCommandArgument.Should().Contain($"{commandArguments}\"{bootstrapFile}\" -- {scriptArguments}");
2323
}
24+
25+
[Test]
26+
public void FormatCommandArguments_UsesCustomNuGetSource_WhenProvided()
27+
{
28+
var bootstrapFile = "Bootstrap.csx";
29+
var customSource = "https://my.internal.nuget/v3/index.json";
30+
var result = DotnetScriptBootstrapper.FormatCommandArguments(bootstrapFile, null, customSource);
31+
result.Should().Contain($"-s {customSource} ");
32+
result.Should().NotContain("api.nuget.org");
33+
}
2434
}
2535
}

0 commit comments

Comments
 (0)