![seancpeters](/assets/img/avatar_default.png)
* 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
97 lines
3.1 KiB
C#
97 lines
3.1 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 FluentAssertions;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Xunit;
|
|
using System.Linq;
|
|
|
|
namespace Microsoft.DotNet.Cli.Build.Tests
|
|
{
|
|
public class GivenDotnetBuildBuildsCsproj : TestBase
|
|
{
|
|
[Fact]
|
|
public void ItBuildsARunnableOutput()
|
|
{
|
|
var testAppName = "MSBuildTestApp";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance(testAppName)
|
|
.WithSourceFiles()
|
|
.WithRestoreFiles();
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(testInstance.Root)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
|
|
|
var outputDll = testInstance.Root.GetDirectory("bin", configuration, "netcoreapp1.0")
|
|
.GetFile($"{testAppName}.dll");
|
|
|
|
var outputRunCommand = new TestCommand("dotnet");
|
|
|
|
outputRunCommand.ExecuteWithCapturedOutput(outputDll.FullName)
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItRunsWhenRestoringToSpecificPackageDir()
|
|
{
|
|
var rootPath = TestAssetsManager.CreateTestDirectory().Path;
|
|
|
|
string dir = "pkgs";
|
|
string args = $"--packages {dir}";
|
|
|
|
string newArgs = $"console -o \"{rootPath}\" --debug:ephemeral-hive";
|
|
new NewCommandShim()
|
|
.WithWorkingDirectory(rootPath)
|
|
.Execute(newArgs)
|
|
.Should()
|
|
.Pass();
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(rootPath)
|
|
.Execute(args)
|
|
.Should()
|
|
.Pass()
|
|
.And.NotHaveStdErr();
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(rootPath)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
var outputDll = Directory.EnumerateFiles(Path.Combine(rootPath, "bin"), "*.dll", SearchOption.AllDirectories).Single();
|
|
|
|
var outputRunCommand = new TestCommand("dotnet");
|
|
|
|
outputRunCommand.ExecuteWithCapturedOutput(outputDll)
|
|
.Should().Pass()
|
|
.And.HaveStdOutContaining("Hello World");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItPrintsBuildSummary()
|
|
{
|
|
var testAppName = "MSBuildTestApp";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance(testAppName)
|
|
.WithSourceFiles()
|
|
.WithRestoreFiles();
|
|
|
|
string expectedBuildSummary = @"Build succeeded.
|
|
0 Warning(s)
|
|
0 Error(s)";
|
|
|
|
var cmd = new BuildCommand()
|
|
.WithWorkingDirectory(testInstance.Root)
|
|
.ExecuteWithCapturedOutput();
|
|
cmd.Should().Pass();
|
|
cmd.StdOut.Should().ContainVisuallySameFragment(expectedBuildSummary);
|
|
}
|
|
}
|
|
}
|