diff --git a/src/Aspire.Hosting/ApplicationModel/ExecutableResource.cs b/src/Aspire.Hosting/ApplicationModel/ExecutableResource.cs
index 5a3a7297553..8d7748e14e1 100644
--- a/src/Aspire.Hosting/ApplicationModel/ExecutableResource.cs
+++ b/src/Aspire.Hosting/ApplicationModel/ExecutableResource.cs
@@ -11,7 +11,7 @@ namespace Aspire.Hosting.ApplicationModel;
///
/// The name of the resource.
/// The command to execute.
-/// The working directory of the executable.
+/// The working directory of the executable. Can be empty.
public class ExecutableResource(string name, string command, string workingDirectory)
: Resource(name), IResourceWithEnvironment, IResourceWithArgs, IResourceWithEndpoints, IResourceWithWaitSupport
{
@@ -23,7 +23,7 @@ public class ExecutableResource(string name, string command, string workingDirec
///
/// Gets the working directory for the executable resource.
///
- public string WorkingDirectory { get; } = ThrowIfNullOrEmpty(workingDirectory);
+ public string WorkingDirectory { get; } = workingDirectory ?? throw new ArgumentNullException(nameof(workingDirectory));
private static string ThrowIfNullOrEmpty([NotNull] string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
{
diff --git a/tests/Aspire.Hosting.Tests/ExecutableResourceTests.cs b/tests/Aspire.Hosting.Tests/ExecutableResourceTests.cs
index 6cfb9936feb..409e2f49349 100644
--- a/tests/Aspire.Hosting.Tests/ExecutableResourceTests.cs
+++ b/tests/Aspire.Hosting.Tests/ExecutableResourceTests.cs
@@ -82,6 +82,25 @@ public async Task AddExecutableWithArgs()
Assert.Equal(expectedManifest, manifest.ToString());
}
+ [Fact]
+ public void ExecutableResourceNullCommand()
+ => Assert.Throws("command", () => new ExecutableResource("name", command: null!, workingDirectory: "."));
+
+ [Fact]
+ public void ExecutableResourceEmptyCommand()
+ => Assert.Throws("command", () => new ExecutableResource("name", command: "", workingDirectory: "."));
+
+ [Fact]
+ public void ExecutableResourceNullWorkingDirectory()
+ => Assert.Throws("workingDirectory", () => new ExecutableResource("name", command: "cmd", workingDirectory: null!));
+
+ [Fact]
+ public void ExecutableResourceEmptyWorkingDirectory()
+ {
+ var er = new ExecutableResource("name", command: "cmd", workingDirectory: "");
+ Assert.Empty(er.WorkingDirectory);
+ }
+
private sealed class TestResource(string name, string connectionString) : Resource(name), IResourceWithConnectionString
{
public ReferenceExpression ConnectionStringExpression =>