Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public void It_builds_a_runnable_apphost_by_default(string targetFramework)
"HelloWorld.runtimeconfig.json",
});

Command.Create(Path.Combine(outputDirectory.FullName, hostExecutable), new string[] { })
.EnvironmentVariable(

new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, hostExecutable))
.WithEnvironmentVariable(
Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)",
Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath))
.CaptureStdOut()
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,25 @@ internal static void TestSatelliteResources(
"en/AllResourcesInSatellite.resources.dll"
};

Command command;
TestCommand command;
if (targetFramework == "net46")
{
outputFiles.Add("AllResourcesInSatellite.exe");
outputFiles.Add("AllResourcesInSatellite.exe.config");
command = Command.Create(Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.exe"), Array.Empty<string>());
command = new RunExeCommand(log, Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.exe"));
}
else
{
outputFiles.Add("AllResourcesInSatellite.dll");
outputFiles.Add("AllResourcesInSatellite.deps.json");
outputFiles.Add("AllResourcesInSatellite.runtimeconfig.json");
outputFiles.Add("AllResourcesInSatellite.runtimeconfig.dev.json");
command = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.dll") });
command = new DotnetCommand(log, Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.dll"));
}

outputDirectory.Should().OnlyHaveFiles(outputFiles);

command
.CaptureStdOut()
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ public void It_handles_native_dependencies_and_platform_target(
.Pass();

var exe = Path.Combine(buildCommand.GetOutputDirectory("net46").FullName, "DesktopMinusRid.exe");
var runCommand = Command.Create(exe, Array.Empty<string>());
var runCommand = new RunExeCommand(Log, exe);
runCommand
.CaptureStdOut()
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -189,9 +188,8 @@ public void It_appends_rid_to_outdir_correctly(string identifier, string rid, bo
{
var exe = Path.Combine(directory.FullName, "DesktopMinusRid.exe");

var runCommand = Command.Create(exe, Array.Empty<string>());
var runCommand = new RunExeCommand(Log, exe);
runCommand
.CaptureStdOut()
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ public static void Main()

string outputFolder = buildCommand.GetOutputDirectory(project.TargetFrameworks, runtimeIdentifier: runtimeIdentifier ?? "").FullName;

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputFolder, project.Name + ".dll") })
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(outputFolder, project.Name + ".dll"))
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public void It_builds_a_runnable_output(string targetFramework, bool dependencie
$"apphost{Constants.ExeSuffix}",
});

Command.Create(selfContainedExecutableFullPath, new string[] { })
.CaptureStdOut()
new RunExeCommand(Log, selfContainedExecutableFullPath)
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -149,8 +148,7 @@ public void It_succeeds_when_RuntimeIdentifier_and_PlatformTarget_mismatch_but_P

string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable);

Command.Create(selfContainedExecutableFullPath, new string[] { })
.CaptureStdOut()
new RunExeCommand(Log, selfContainedExecutableFullPath)
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public void It_builds_a_RID_specific_runnable_output()

string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable);

Command.Create(selfContainedExecutableFullPath, new string[] { })
.CaptureStdOut()
.CaptureStdErr()
new RunExeCommand(Log, selfContainedExecutableFullPath)
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -118,8 +116,7 @@ public void It_builds_a_framework_dependent_RID_specific_runnable_output()
"LibraryWithRids.pdb",
});

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "App.dll") })
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "App.dll"))
.Execute()
.Should().Pass()
.And.HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' 3.13.0 '{runtimeIdentifier}' Hello World");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ void VerifyAppBuilds(TestAsset testAsset)
"TestLibrary.pdb",
});

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "TestApp.dll") })
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll"))
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -121,8 +120,7 @@ public void It_generates_satellite_assemblies()

var outputDir = buildCommand.GetOutputDirectory("netcoreapp2.0");

var commandResult = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDir.FullName, "TestApp.dll") })
.CaptureStdOut()
var commandResult = new DotnetCommand(Log, Path.Combine(outputDir.FullName, "TestApp.dll"))
.Execute();

commandResult.Should().Pass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ void VerifyAppBuilds(TestAsset testAsset)
"AuxLibrary.pdb",
});

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "TestApp.dll") })
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll"))
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public void It_builds_the_project_successfully_when_RAR_finds_all_references()
"5.pdb",
});

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] {Path.Combine(outputDirectory.FullName, "1.dll")})
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "1.dll"))
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -91,8 +90,7 @@ public void It_builds_the_project_successfully_when_RAR_does_not_find_all_refere
"2.pdb",
});

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] {Path.Combine(outputDirectory.FullName, "1.dll")})
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "1.dll"))
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void VerifyProjectsBuild(TestAsset testAsset, params string[] buildArgs)
var buildCommand = new BuildCommand(Log, appProjectDirectory);
var outputDirectory = buildCommand.GetOutputDirectory("net451", runtimeIdentifier: "win7-x86");

Command.Create(Path.Combine(outputDirectory.FullName, "EntityFrameworkApp.exe"), Enumerable.Empty<string>())
.CaptureStdOut()
new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, "EntityFrameworkApp.exe"))
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello from a direct reference.");
Expand Down Expand Up @@ -210,8 +209,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World from en satellite assembly for a direct reference.");
Expand Down Expand Up @@ -299,8 +297,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello from a reference of an indirect reference.");
Expand Down Expand Up @@ -441,8 +438,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World from en satellite assembly for a reference of an indirect reference.");
Expand Down Expand Up @@ -531,8 +527,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello from an indirect reference.");
Expand Down Expand Up @@ -674,8 +669,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World from en satellite assembly for an indirect reference.");
Expand Down Expand Up @@ -782,8 +776,7 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello from a reference of an indirect reference.");
Expand Down Expand Up @@ -943,9 +936,8 @@ public static void Main()
var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier);
string applicationPath = RestoreAndBuild(referencerAsset, referencerProject);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath })
.CaptureStdOut()
.Execute()
new DotnetCommand(Log, applicationPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World from en satellite assembly for a reference of an indirect reference.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ public static Type [] GetTypes()

var exePath = Path.Combine(buildCommand.GetOutputDirectory(testProject.TargetFrameworks).FullName, testProject.Name + ".exe");

Command.Create(exePath, Array.Empty<string>())
.CaptureStdOut()
new RunExeCommand(Log, exePath)
.Execute()
.Should()
.Pass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,9 @@ public static void Main()
// to force the .NET Core 2.0 app to run on that version
string rollForwardVersion = GetRollForwardNetCoreAppVersion();

var runAppCommand = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath,
new string[] { "exec", "--fx-version", rollForwardVersion, exePath });
var runAppCommand = new DotnetCommand(Log, "exec", "--fx-version", rollForwardVersion, exePath );

var runAppResult = runAppCommand
.CaptureStdOut()
.CaptureStdErr()
.Execute();

runAppResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ public void It_publishes_with_or_without_apphost(string useAppHost, string targe
// Run the apphost if one was generated
if (useAppHost != "false")
{
Command.Create(Path.Combine(publishDirectory.FullName, appHostName), Enumerable.Empty<string>())
.EnvironmentVariable(
new RunExeCommand(Log, Path.Combine(publishDirectory.FullName, appHostName))
.WithEnvironmentVariable(
Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)",
Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath))
.CaptureStdOut()
.CaptureStdErr()
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public void It_publishes_portable_apps_to_the_publish_folder_and_the_app_should_
outputDirectory.Should().HaveFiles(filesPublished);
publishDirectory.Should().HaveFiles(filesPublished);

Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(publishDirectory.FullName, "HelloWorld.dll") })
.CaptureStdOut()
new DotnetCommand(Log, Path.Combine(publishDirectory.FullName, "HelloWorld.dll"))
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -117,8 +116,7 @@ public void It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_s
publishDirectory.Should().NotHaveFiles(filesNotPublished);

string selfContainedExecutableFullPath = Path.Combine(publishDirectory.FullName, selfContainedExecutable);
Command.Create(selfContainedExecutableFullPath, new string[] { })
.CaptureStdOut()
new RunExeCommand(Log, selfContainedExecutableFullPath)
.Execute()
.Should()
.Pass()
Expand Down Expand Up @@ -341,7 +339,7 @@ public static void Main()
.And
.OnlyHavePackagesWithPathProperties();

ICommand runCommand;
TestCommand runCommand;

if (selfContained)
{
Expand Down Expand Up @@ -372,7 +370,7 @@ public static void Main()
.And
.OnlyHaveNativeAssembliesWhichAreInFolder(rid, publishDirectory.FullName, testProject.Name);

runCommand = Command.Create(selfContainedExecutableFullPath, new string[] { });
runCommand = new RunExeCommand(Log, selfContainedExecutableFullPath);
}
else
{
Expand All @@ -389,11 +387,10 @@ public static void Main()
dependencyContext.Should()
.OnlyHaveRuntimeAssemblies(rid ?? "", testProject.Name);

runCommand = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(publishDirectory.FullName, $"{testProject.Name}.dll") });
runCommand = new DotnetCommand(Log, Path.Combine(publishDirectory.FullName, $"{testProject.Name}.dll"));
}

runCommand
.CaptureStdOut()
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public void It_publishes_projects_with_simple_dependencies()

string appPath = publishCommand.GetPublishedAppPath("SimpleDependencies");

Command runAppCommand = Command.Create(
TestContext.Current.ToolsetUnderTest.DotNetHostPath,
new[] { appPath, "one", "two" });
TestCommand runAppCommand = new DotnetCommand(Log, appPath, "one", "two" );

string expectedOutput =
@"{
Expand All @@ -63,7 +61,6 @@ public void It_publishes_projects_with_simple_dependencies()
}";

runAppCommand
.CaptureStdOut()
.Execute()
.Should()
.Pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public void It_should_publish_self_contained_for_2x()
$"apphost{Constants.ExeSuffix}",
});

Command.Create(Path.Combine(output.FullName, $"{testProject.Name}{Constants.ExeSuffix}"), new string[] {})
.CaptureStdOut()
new RunExeCommand(Log, Path.Combine(output.FullName, $"{testProject.Name}{Constants.ExeSuffix}"))
.Execute()
.Should()
.Pass()
Expand Down
Loading