dotnet-installer/test/EndToEnd/GivenDotNetUsesMSBuild.cs
seancpeters 2d93968a88 New3 integration (#5430)
* Partial conversion to new3. 2 tests fail due to browserlink not restoring.

* new cache initialization

* More lzma changes, and removed a razor ref from templates

* Ephemeral hive flag added to tests that need it

* Updated the template engine version to build against. Minor code cleanup

* Config changes to make template versions separate from template engine versions

* Changed dotnet new versioning to use Product.Version

* Fixing Archiver.csproj

* Fixing dotnet new test.

* Fix LZMA Package Source Condition

* Workaround for newline differences.

* fixed tests with changed template parameters. Added a new3 template non-match test
2017-01-31 17:31:37 -08:00

120 lines
4.4 KiB
C#

// 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;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
namespace Microsoft.DotNet.Tests.EndToEnd
{
public class GivenDotNetUsesMSBuild : TestBase
{
[Fact]
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
{
using (DisposableDirectory directory = Temp.CreateDirectory())
{
string projectDirectory = directory.Path;
string newArgs = "console --debug:ephemeral-hive";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.Execute("/p:SkipInvalidConfigurations=true")
.Should().Pass();
new BuildCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
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);
}
}
[Fact]
public void ItCanRunToolsInACSProj()
{
var testInstance = TestAssets.Get("MSBuildTestApp")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
var testProjectDirectory = testInstance.Root;
new DotnetCommand()
.WithWorkingDirectory(testInstance.Root)
.ExecuteWithCapturedOutput("portable")
.Should()
.Pass()
.And
.HaveStdOutContaining("Hello Portable World!");;
}
[Fact]
public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresADifferentRuntime()
{
var testInstance = TestAssets.Get("MSBuildTestApp")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
var testProjectDirectory = testInstance.Root;
new DotnetCommand()
.WithWorkingDirectory(testInstance.Root)
.ExecuteWithCapturedOutput("prefercliruntime")
.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()
.WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput(
$"-d dependency-tool-invoker -c {configuration} -f netcoreapp1.0 portable")
.Should().Pass()
.And.HaveStdOutContaining("Hello Portable World!");;
}
}
}