dotnet-installer/test/EndToEnd/GivenDotNetUsesMSBuild.cs

121 lines
4.5 KiB
C#
Raw Normal View History

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.
using System;
using System.IO;
2016-07-21 20:04:05 +00:00
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
2016-07-21 20:04:05 +00:00
namespace Microsoft.DotNet.Tests.EndToEnd
{
public class GivenDotNetUsesMSBuild : TestBase
{
[Fact(Skip = "https://github.com/dotnet/cli/issues/7476")]
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
2016-07-21 20:04:05 +00:00
{
using (DisposableDirectory directory = Temp.CreateDirectory())
2016-07-21 20:04:05 +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";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
2016-07-21 20:04:05 +00:00
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.Execute("/p:SkipInvalidConfigurations=true")
.Should().Pass();
2016-07-21 20:04:05 +00:00
new BuildCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
2016-07-21 20:04:05 +00:00
new RunCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput()
.Should().Pass()
.And.HaveStdOutContaining("Hello World!");
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
new CleanCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
2016-07-21 20:04:05 +00:00
}
}
[Fact]
public void ItCanRunToolsInACSProj()
{
var testInstance = TestAssets.Get("MSBuildTestApp")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
var testProjectDirectory = testInstance.Root;
new DotnetCommand()
.WithWorkingDirectory(testInstance.Root)
.ExecuteWithCapturedOutput("portable")
.Should()
2016-10-05 18:51:59 +00:00
.Pass()
.And
.HaveStdOutContaining("Hello Portable World!");;
}
[Fact]
2016-11-23 18:19:00 +00:00
public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresADifferentRuntime()
{
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!");;
}
[Fact]
public void ItCanRunAToolThatInvokesADependencyToolInACSProj()
{
var repoDirectoriesProvider = new RepoDirectoriesProvider();
var testInstance = TestAssets.Get("TestAppWithProjDepTool")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
var configuration = "Debug";
var testProjectDirectory = testInstance.Root;
new BuildCommand()
.WithWorkingDirectory(testProjectDirectory)
.Execute($"-c {configuration} ")
.Should()
.Pass();
new DotnetCommand(DotnetUnderTest.WithBackwardsCompatibleRuntimes)
.WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput(
2017-08-18 22:36:01 +00:00
$"-d dependency-tool-invoker -c {configuration} -f netcoreapp2.1 portable")
.Should().Pass()
.And.HaveStdOutContaining("Hello Portable World!");;
}
2016-07-21 20:04:05 +00:00
}
}