8000 launchSettings workingDirectory overrides project settings · dotnet/sdk@30b20de · GitHub
[go: up one dir, main page]

Skip to content

Commit 30b20de

Browse files
committed
launchSettings workingDirectory overrides project settings
1 parent 9ce5474 commit 30b20de

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Cli/dotnet/commands/dotnet-run/RunCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public int Execute()
7373
{
7474
targetCommand.SetCommandArgs(launchSettings.CommandLineArgs);
7575
}
76-
if (string.IsNullOrEmpty(targetCommand.CommandWorkingDirectory) && launchSettings.WorkingDirectory != null)
76+
if (launchSettings.WorkingDirectory != null)
7777
{
7878
targetCommand.WorkingDirectory(launchSettings.WorkingDirectory);
7979
}

test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public void ItUsesTheValueOfAppUrlIfTheEnvVarIsNotSet()
562562
}
563563

564564
[Fact]
565-
public void ItUsesTheValueOfWorkingDirectoryIfTheProjectRunWorkingDirectoryIsNotSet()
565+
public void ItUsesTheValueOfWorkingDirectoryIfSet()
566566
{
567567
var testAppName = "AppWithWorkingDirectoryInLaunchSettings";
568568
var testInstance = _testAssetsManager.CopyTestAsset(testAppName)
@@ -583,27 +583,27 @@ public void ItUsesTheValueOfWorkingDirectoryIfTheProjectRunWorkingDirectoryIsNot
583583
}
584584

585585
[Fact]
586-
public void ItPrefersTheValueOfProjectRunWorkingDirectoryIfSet()
586+
public void ItPrefersTheValueOfWorkingDirectoryFromLaunchSettingsOverProjectRunWorkingDirectory()
587587
{
588588
var testAppName = "AppWithWorkingDirectoryInLaunchSettings";
589589
var testInst C336 ance = _testAssetsManager.CopyTestAsset(testAppName)
590590
.WithSource()
591591
.WithProjectChanges(p => {
592592
var ns = p.Root.Name.Namespace;
593593
var propertyGroup = p.Root.Elements(ns + "PropertyGroup").First();
594-
propertyGroup.Add(new XElement(ns + "RunWorkingDirectory", "runSubfolder"));
594+
propertyGroup.Add(new XElement(ns + "RunWorkingDirectory", "expectThisSubfolderIsOverridden"));
595595
});
596596

597597
var testProjectDirectory = testInstance.Path;
598598

599-
Directory.CreateDirectory(Path.Combine(testProjectDirectory, "runSubfolder"));
599+
Directory.CreateDirectory(Path.Combine(testProjectDirectory, "launchSubfolder"));
600600

601601
var cmd = new DotnetCommand(Log, "run")
602602
.WithWorkingDirectory(testProjectDirectory)
603603
.Execute("--launch-profile", "Second");
604604

605605
cmd.Should().Pass()
606-
.And.HaveStdOutContaining("runSubfolder");
606+
.And.HaveStdOutContaining("launchSubfolder");
607607

608608
cmd.StdErr.Should().BeEmpty();
609609
}

0 commit comments

Comments
 (0)
0