2016-07-21 15:04:05 -05:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
2016-10-14 10:23:50 -07:00
|
|
|
|
using System;
|
2016-10-04 19:29:07 +02:00
|
|
|
|
using System.IO;
|
2016-07-21 15:04:05 -05:00
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2017-01-31 17:31:37 -08:00
|
|
|
|
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
|
|
|
|
|
2016-07-21 15:04:05 -05:00
|
|
|
|
namespace Microsoft.DotNet.Tests.EndToEnd
|
|
|
|
|
{
|
|
|
|
|
public class GivenDotNetUsesMSBuild : TestBase
|
|
|
|
|
{
|
2016-08-10 09:21:43 -05:00
|
|
|
|
[Fact]
|
2016-10-04 19:29:07 +02:00
|
|
|
|
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
|
2016-07-21 15:04:05 -05:00
|
|
|
|
{
|
2016-09-02 15:11:33 -05:00
|
|
|
|
using (DisposableDirectory directory = Temp.CreateDirectory())
|
2016-07-21 15:04:05 -05:00
|
|
|
|
{
|
2016-09-02 15:11:33 -05:00
|
|
|
|
string projectDirectory = directory.Path;
|
2016-07-21 15:04:05 -05:00
|
|
|
|
|
2017-04-10 20:00:17 -07:00
|
|
|
|
string newArgs = "console -f netcoreapp2.0 --debug:ephemeral-hive --no-restore";
|
2017-01-31 17:31:37 -08:00
|
|
|
|
new NewCommandShim()
|
2016-09-02 15:11:33 -05:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2017-01-31 17:31:37 -08:00
|
|
|
|
.Execute(newArgs)
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Should().Pass();
|
2016-07-21 15:04:05 -05:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
new RestoreCommand()
|
2016-09-02 15:11:33 -05:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-10-14 00:06:35 -07:00
|
|
|
|
.Execute("/p:SkipInvalidConfigurations=true")
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Should().Pass();
|
2016-07-21 15:04:05 -05:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
new BuildCommand()
|
2016-09-02 15:11:33 -05:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute()
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Should().Pass();
|
2016-07-21 15:04:05 -05:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
new RunCommand()
|
2016-09-02 15:11:33 -05:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-10-26 00:04:40 -05:00
|
|
|
|
.ExecuteWithCapturedOutput()
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Should().Pass()
|
|
|
|
|
.And.HaveStdOutContaining("Hello World!");
|
2016-10-04 19:29:07 +02:00
|
|
|
|
|
|
|
|
|
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
|
|
|
|
|
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
new CleanCommand()
|
2016-10-04 19:29:07 +02:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute()
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Should().Pass();
|
2016-10-04 19:29:07 +02:00
|
|
|
|
|
|
|
|
|
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
|
2016-07-21 15:04:05 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-03 21:40:24 -07:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItCanRunToolsInACSProj()
|
|
|
|
|
{
|
2016-10-27 18:46:43 -07:00
|
|
|
|
var testInstance = TestAssets.Get("MSBuildTestApp")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithRestoreFiles();
|
|
|
|
|
|
|
|
|
|
var testProjectDirectory = testInstance.Root;
|
2016-10-03 21:40:24 -07:00
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.WithWorkingDirectory(testInstance.Root)
|
2016-10-03 21:40:24 -07:00
|
|
|
|
.ExecuteWithCapturedOutput("portable")
|
|
|
|
|
.Should()
|
2016-10-05 11:51:59 -07:00
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining("Hello Portable World!");;
|
2016-10-03 21:40:24 -07:00
|
|
|
|
}
|
2016-10-10 17:13:46 -07:00
|
|
|
|
|
2016-11-22 13:56:13 -08:00
|
|
|
|
[Fact]
|
2016-11-23 10:19:00 -08:00
|
|
|
|
public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresADifferentRuntime()
|
2016-11-22 13:56:13 -08:00
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssets.Get("MSBuildTestApp")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithRestoreFiles();
|
|
|
|
|
|
|
|
|
|
var testProjectDirectory = testInstance.Root;
|
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(testInstance.Root)
|
|
|
|
|
.ExecuteWithCapturedOutput("prefercliruntime")
|
2016-11-23 10:19:00 -08:00
|
|
|
|
.Should().Pass()
|
|
|
|
|
.And.HaveStdOutContaining("Hello I prefer the cli runtime World!");;
|
2016-11-22 13:56:13 -08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 11:20:37 -07:00
|
|
|
|
[Fact]
|
2016-10-10 17:13:46 -07:00
|
|
|
|
public void ItCanRunAToolThatInvokesADependencyToolInACSProj()
|
|
|
|
|
{
|
|
|
|
|
var repoDirectoriesProvider = new RepoDirectoriesProvider();
|
2016-10-14 12:45:04 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
var testInstance = TestAssets.Get("TestAppWithProjDepTool")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithRestoreFiles();
|
2016-10-10 17:13:46 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
var configuration = "Debug";
|
2016-10-10 17:13:46 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
var testProjectDirectory = testInstance.Root;
|
2016-10-10 17:13:46 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
new BuildCommand()
|
2016-10-10 17:13:46 -07:00
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Execute($"-c {configuration} ")
|
2016-10-10 17:13:46 -07:00
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
2017-04-07 16:36:23 -07:00
|
|
|
|
new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
2016-10-10 17:13:46 -07:00
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-10-14 10:23:50 -07:00
|
|
|
|
.ExecuteWithCapturedOutput(
|
2017-03-02 12:46:21 -08:00
|
|
|
|
$"-d dependency-tool-invoker -c {configuration} -f netcoreapp2.0 portable")
|
2016-10-27 18:46:43 -07:00
|
|
|
|
.Should().Pass()
|
|
|
|
|
.And.HaveStdOutContaining("Hello Portable World!");;
|
2016-10-10 17:13:46 -07:00
|
|
|
|
}
|
2016-07-21 15:04:05 -05:00
|
|
|
|
}
|
|
|
|
|
}
|