Skip to content

Commit 0e6c1a8

Browse files
adamintAdam Ratzman
andauthored
Only add double-dash to args if there are previous app-host-added args (microsoft#7769)
* Only add double-dash to args if there are previous app-host-added args * Update tests * test to see if CI azure service bus somehow needs the double dash * Revert "test to see if CI azure service bus somehow needs the double dash" This reverts commit d128b27. * move -- logic into BuildLaunchArgs * remove nested if --------- Co-authored-by: Adam Ratzman <adamratzman@microsoft.com>
1 parent 9a86337 commit 0e6c1a8

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/Aspire.Hosting/Dcp/DcpExecutor.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,12 @@ private async Task CreateExecutableAsync(AppResource er, ILogger resourceLogger,
10241024
var annotationOnly = spec.ExecutionType == ExecutionType.IDE;
10251025

10261026
var launchProfileArgs = GetLaunchProfileArgs(project.GetEffectiveLaunchProfile()?.LaunchProfile);
1027+
if (launchProfileArgs.Count > 0 && appHostArgs.Count > 0)
1028+
{
1029+
// If there are app host args, add a double-dash to separate them from the launch args.
1030+
launchProfileArgs.Insert(0, "--");
1031+
}
1032+
10271033
launchArgs.AddRange(launchProfileArgs.Select(a => (a, isSensitive: false, annotationOnly)));
10281034
}
10291035
}
@@ -1036,17 +1042,12 @@ private async Task CreateExecutableAsync(AppResource er, ILogger resourceLogger,
10361042

10371043
private static List<string> GetLaunchProfileArgs(LaunchProfile? launchProfile)
10381044
{
1039-
var args = new List<string>();
10401045
if (launchProfile is not null && !string.IsNullOrWhiteSpace(launchProfile.CommandLineArgs))
10411046
{
1042-
var cmdArgs = CommandLineArgsParser.Parse(launchProfile.CommandLineArgs);
1043-
if (cmdArgs.Count > 0)
1044-
{
1045-
args.Add("--");
1046-
args.AddRange(cmdArgs);
1047-
}
1047+
return CommandLineArgsParser.Parse(launchProfile.CommandLineArgs);
10481048
}
1049-
return args;
1049+
1050+
return [];
10501051
}
10511052

10521053
private void PrepareContainers()

tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public async Task ResourceStarted_ProjectHasReplicas_EventRaisedOnce()
106106
}
107107

108108
[Theory]
109-
[InlineData(ExecutionType.IDE, false, null, new string[] { "--", "--test1", "--test2" })]
109+
[InlineData(ExecutionType.IDE, false, null, new string[] { "--test1", "--test2" })]
110110
[InlineData(ExecutionType.IDE, true, new string[] { "--withargs-test" }, new string[] { "--withargs-test" })]
111-
[InlineData(ExecutionType.Process, false, new string[] { "--", "--test1", "--test2" }, new string[] { "--", "--test1", "--test2" })]
111+
[InlineData(ExecutionType.Process, false, new string[] { "--test1", "--test2" }, new string[] { "--test1", "--test2" })]
112112
[InlineData(ExecutionType.Process, true, new string[] { "--", "--test1", "--test2", "--withargs-test" }, new string[] { "--", "--test1", "--test2", "--withargs-test" })]
113113
public async Task CreateExecutable_LaunchProfileHasCommandLineArgs_AnnotationsAdded(string executionType, bool addAppHostArgs, string[]? expectedArgs, string[]? expectedAnnotations)
114114
{

0 commit comments

Comments
 (0)