2016-07-21 20:04:05 +00: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 17:23:50 +00:00
|
|
|
|
using System;
|
2016-10-04 17:29:07 +00:00
|
|
|
|
using System.IO;
|
2016-07-21 20:04:05 +00:00
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2017-02-01 01:31:37 +00:00
|
|
|
|
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
|
|
|
|
|
2016-07-21 20:04:05 +00:00
|
|
|
|
namespace Microsoft.DotNet.Tests.EndToEnd
|
|
|
|
|
{
|
|
|
|
|
public class GivenDotNetUsesMSBuild : TestBase
|
|
|
|
|
{
|
2017-08-19 01:07:57 +00:00
|
|
|
|
[Fact(Skip = "https://github.com/dotnet/cli/issues/7476")]
|
2016-10-04 17:29:07 +00:00
|
|
|
|
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
|
2016-07-21 20:04:05 +00:00
|
|
|
|
{
|
2016-09-02 20:11:33 +00:00
|
|
|
|
using (DisposableDirectory directory = Temp.CreateDirectory())
|
2016-07-21 20:04:05 +00:00
|
|
|
|
{
|
2016-09-02 20:11:33 +00:00
|
|
|
|
string projectDirectory = directory.Path;
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2017-08-18 22:36:01 +00:00
|
|
|
|
string newArgs = "console -f netcoreapp2.1 --debug:ephemeral-hive --no-restore";
|
2017-02-01 01:31:37 +00:00
|
|
|
|
new NewCommandShim()
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2017-02-01 01:31:37 +00:00
|
|
|
|
.Execute(newArgs)
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Should().Pass();
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
new RestoreCommand()
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-10-14 07:06:35 +00:00
|
|
|
|
.Execute("/p:SkipInvalidConfigurations=true")
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Should().Pass();
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
new BuildCommand()
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute()
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Should().Pass();
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
new RunCommand()
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-10-26 05:04:40 +00:00
|
|
|
|
.ExecuteWithCapturedOutput()
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Should().Pass()
|
|
|
|
|
.And.HaveStdOutContaining("Hello World!");
|
2016-10-04 17:29:07 +00:00
|
|
|
|
|
|
|
|
|
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
|
|
|
|
|
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
|
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
new CleanCommand()
|
2016-10-04 17:29:07 +00:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute()
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Should().Pass();
|
2016-10-04 17:29:07 +00:00
|
|
|
|
|
|
|
|
|
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
|
2016-07-21 20:04:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-04 04:40:24 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItCanRunToolsInACSProj()
|
|
|
|
|
{
|
2016-10-28 01:46:43 +00:00
|
|
|
|
var testInstance = TestAssets.Get("MSBuildTestApp")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithRestoreFiles();
|
|
|
|
|
|
|
|
|
|
var testProjectDirectory = testInstance.Root;
|
2016-10-04 04:40:24 +00:00
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.WithWorkingDirectory(testInstance.Root)
|
2016-10-04 04:40:24 +00:00
|
|
|
|
.ExecuteWithCapturedOutput("portable")
|
|
|
|
|
.Should()
|
2016-10-05 18:51:59 +00:00
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining("Hello Portable World!");;
|
2016-10-04 04:40:24 +00:00
|
|
|
|
}
|
2016-10-11 00:13:46 +00:00
|
|
|
|
|
2016-11-22 21:56:13 +00:00
|
|
|
|
[Fact]
|
2016-11-23 18:19:00 +00:00
|
|
|
|
public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresADifferentRuntime()
|
2016-11-22 21:56:13 +00:00
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssets.Get("MSBuildTestApp")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithRestoreFiles();
|
|
|
|
|
|
|
|
|
|
var testProjectDirectory = testInstance.Root;
|
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(testInstance.Root)
|
|
|
|
|
.ExecuteWithCapturedOutput("prefercliruntime")
|
2016-11-23 18:19:00 +00:00
|
|
|
|
.Should().Pass()
|
|
|
|
|
.And.HaveStdOutContaining("Hello I prefer the cli runtime World!");;
|
2016-11-22 21:56:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 18:20:37 +00:00
|
|
|
|
[Fact]
|
2016-10-11 00:13:46 +00:00
|
|
|
|
public void ItCanRunAToolThatInvokesADependencyToolInACSProj()
|
|
|
|
|
{
|
|
|
|
|
var repoDirectoriesProvider = new RepoDirectoriesProvider();
|
2016-10-14 19:45:04 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
var testInstance = TestAssets.Get("TestAppWithProjDepTool")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithRestoreFiles();
|
2016-10-11 00:13:46 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
var configuration = "Debug";
|
2016-10-11 00:13:46 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
var testProjectDirectory = testInstance.Root;
|
2016-10-11 00:13:46 +00:00
|
|
|
|
|
2016-10-28 01:46:43 +00:00
|
|
|
|
new BuildCommand()
|
2016-10-11 00:13:46 +00:00
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Execute($"-c {configuration} ")
|
2016-10-11 00:13:46 +00:00
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
2017-04-07 23:36:23 +00:00
|
|
|
|
new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
|
2016-10-11 00:13:46 +00:00
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-10-14 17:23:50 +00:00
|
|
|
|
.ExecuteWithCapturedOutput(
|
2017-08-18 22:36:01 +00:00
|
|
|
|
$"-d dependency-tool-invoker -c {configuration} -f netcoreapp2.1 portable")
|
2016-10-28 01:46:43 +00:00
|
|
|
|
.Should().Pass()
|
|
|
|
|
.And.HaveStdOutContaining("Hello Portable World!");;
|
2016-10-11 00:13:46 +00:00
|
|
|
|
}
|
2016-07-21 20:04:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|