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;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests.EndToEnd
|
|
|
|
|
{
|
|
|
|
|
public class GivenDotNetUsesMSBuild : TestBase
|
|
|
|
|
{
|
2016-10-14 07:06:35 +00:00
|
|
|
|
public static void Main()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-10 14:21:43 +00:00
|
|
|
|
[Fact]
|
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
|
|
|
|
|
2016-09-02 20:11:33 +00:00
|
|
|
|
new NewCommand()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-10-14 07:06:35 +00:00
|
|
|
|
.Execute("")
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2016-09-27 22:38:59 +00:00
|
|
|
|
new Restore3Command()
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-10-14 07:06:35 +00:00
|
|
|
|
.Execute("/p:SkipInvalidConfigurations=true")
|
2016-09-02 20:11:33 +00:00
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2016-09-02 20:11:33 +00:00
|
|
|
|
new Build3Command()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
2016-07-21 20:04:05 +00:00
|
|
|
|
|
2016-09-27 23:29:56 +00:00
|
|
|
|
//TODO: https://github.com/dotnet/sdk/issues/187 - remove framework from below.
|
2016-09-02 20:11:33 +00:00
|
|
|
|
new Run3Command()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
2016-09-27 22:38:59 +00:00
|
|
|
|
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
2016-09-02 20:11:33 +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);
|
|
|
|
|
|
|
|
|
|
new Clean3Command()
|
|
|
|
|
.WithWorkingDirectory(projectDirectory)
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
var testAppName = "MSBuildTestApp";
|
|
|
|
|
var testInstance = TestAssetsManager
|
|
|
|
|
.CreateTestInstance(testAppName);
|
|
|
|
|
|
|
|
|
|
var testProjectDirectory = testInstance.TestRoot;
|
|
|
|
|
|
|
|
|
|
new Restore3Command()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(testInstance.TestRoot)
|
|
|
|
|
.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
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItCanRunAToolThatInvokesADependencyToolInACSProj()
|
|
|
|
|
{
|
|
|
|
|
var repoDirectoriesProvider = new RepoDirectoriesProvider();
|
|
|
|
|
var testAppName = "MSBuildTestAppWithToolInDependencies";
|
|
|
|
|
var testInstance = TestAssetsManager
|
|
|
|
|
.CreateTestInstance(testAppName);
|
2016-10-14 19:45:04 +00:00
|
|
|
|
|
|
|
|
|
var configuration = "Debug";
|
2016-10-11 00:13:46 +00:00
|
|
|
|
|
|
|
|
|
var testProjectDirectory = testInstance.TestRoot;
|
|
|
|
|
|
|
|
|
|
new Restore3Command()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
|
|
|
.Execute($"-s {repoDirectoriesProvider.TestPackages}")
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
new Build3Command()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-10-14 19:45:04 +00:00
|
|
|
|
.Execute($"-c {configuration}")
|
2016-10-11 00:13:46 +00:00
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-10-14 17:23:50 +00:00
|
|
|
|
.ExecuteWithCapturedOutput(
|
|
|
|
|
$"-v dependency-tool-invoker -c {configuration} -f netcoreapp1.0 portable")
|
2016-10-11 00:13:46 +00:00
|
|
|
|
.Should()
|
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining("Hello Portable World!");;
|
|
|
|
|
}
|
2016-07-21 20:04:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|