Fix dotnet run double dash passing arguments
When run “dotnet run -- foo”, foo should be the argument passed to the subject app. After replacing the original parser, dotnet-run did not utilize the “unparsedtoken” of the parsed result. To append unparsedtoken to RunCommand’s argument is not straight forward. RunCommand has an “immutable constructor”, which is a good thing, so I made update RunCommand’s argument following the immutable pattern -- create a new object with the original field but only change the arguments. I also made these filed private set.
This commit is contained in:
parent
6f57f27621
commit
83f3a3ec86
7 changed files with 115 additions and 21 deletions
|
@ -181,5 +181,24 @@ namespace Microsoft.DotNet.Cli.Run.Tests
|
|||
.Should().Fail()
|
||||
.And.HaveStdErrContaining("--framework");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItCanPassArgumentsToSubjectAppByDoubleDash()
|
||||
{
|
||||
const string testAppName = "MSBuildTestApp";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("-- foo bar baz")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And.HaveStdOutContaining("echo args:foo;bar;baz");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue