5421af4ad6
* upstream/release/3.1.1xx: (422 commits) Update dependencies from https://github.com/dotnet/toolset build 20190911.12 (#4733) Update dependencies from https://github.com/dotnet/toolset build 20190911.11 (#4731) Update dependencies from https://github.com/aspnet/AspNetCore build 20190911.1 (#4729) [release/3.1.1xx] Update dependencies from dotnet/toolset (#4211) Update dependencies from https://github.com/dotnet/arcade build 20190910.3 (#4728) Exclude ASP.NET targeting pack and shared framework from RPM/debs until we have 3.1 versions Add support for targeting .NET Core 3.1 Update latest patch versions Update dependencies from https://github.com/dotnet/arcade build 20190909.10 (#4716) Do not download for 'arm*' Formatting... Download the ASP.NET SharedFramework MSI and the Module V2 MSI Update dependencies from https://github.com/dotnet/arcade build 20190908.2 (#4695) Update dependencies from https://github.com/dotnet/core-setup build 20190908.7 Add release/3.1.xx download to readme (#4618) Update dependencies from https://github.com/dotnet/core-setup build 20190908.3 Update dependencies from https://github.com/dotnet/arcade build 20190907.1 (#4667) Update dependencies from https://github.com/dotnet/core-setup build 20190907.10 Update dependencies from https://github.com/dotnet/arcade build 20190906.10 (#4643) Update dependencies from https://github.com/dotnet/core-setup build 20190907.3 ... Conflicts: README.md eng/Version.Details.xml eng/Versions.props eng/common/native/install-cmake-test.sh global.json src/redist/targets/GenerateBundledVersions.targets src/redist/targets/Versions.targets
137 lines
4.9 KiB
C#
137 lines
4.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Xml.Linq;
|
|
using Microsoft.DotNet.TestFramework;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Xunit;
|
|
|
|
namespace EndToEnd.Tests
|
|
{
|
|
|
|
public class ProjectBuildTests : TestBase
|
|
{
|
|
|
|
[Fact]
|
|
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
|
|
{
|
|
var directory = TestAssets.CreateTestDirectory();
|
|
string projectDirectory = directory.FullName;
|
|
|
|
string newArgs = "console --debug:ephemeral-hive --no-restore";
|
|
new NewCommandShim()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute(newArgs)
|
|
.Should().Pass();
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
var runCommand = new RunCommand()
|
|
.WithWorkingDirectory(projectDirectory);
|
|
|
|
runCommand.ExecuteWithCapturedOutput()
|
|
// Templates are still at 3.0 and will not run on 5.0, revert to commented out assertion when 5.0 templates land
|
|
//.Should().Pass().And.HaveStdOutContaining("Hello World!");
|
|
.Should().Fail().And.HaveStdErrContaining("https://aka.ms/dotnet-download");
|
|
|
|
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(Skip = "Need support for ASP.NET on .NET Core 3.1")]
|
|
public void ItCanRunAnAppUsingTheWebSdk()
|
|
{
|
|
var directory = TestAssets.CreateTestDirectory();
|
|
string projectDirectory = directory.FullName;
|
|
|
|
string newArgs = "console --debug:ephemeral-hive --no-restore";
|
|
new NewCommandShim()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute(newArgs)
|
|
.Should().Pass();
|
|
|
|
string projectPath = Path.Combine(projectDirectory, directory.Name + ".csproj");
|
|
|
|
var project = XDocument.Load(projectPath);
|
|
var ns = project.Root.Name.Namespace;
|
|
|
|
project.Root.Attribute("Sdk").Value = "Microsoft.NET.Sdk.Web";
|
|
|
|
project.Save(projectPath);
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
var runCommand = new RunCommand()
|
|
.WithWorkingDirectory(projectDirectory);
|
|
|
|
runCommand.ExecuteWithCapturedOutput()
|
|
// Templates are still at 3.0 and will not run on 5.0, revert to commented out assertion when 5.0 templates land
|
|
//.Should().Pass().And.HaveStdOutContaining("Hello World!");
|
|
.Should().Fail().And.HaveStdErrContaining("https://aka.ms/dotnet-download");
|
|
|
|
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("console")]
|
|
[InlineData("classlib")]
|
|
[InlineData("mstest")]
|
|
[InlineData("nunit")]
|
|
[InlineData("web")]
|
|
[InlineData("mvc")]
|
|
public void ItCanBuildTemplates(string templateName)
|
|
{
|
|
TestTemplateBuild(templateName);
|
|
}
|
|
|
|
[WindowsOnlyTheory]
|
|
[InlineData("wpf")]
|
|
[InlineData("winforms")]
|
|
public void ItCanBuildDesktopTemplates(string templateName)
|
|
{
|
|
TestTemplateBuild(templateName);
|
|
}
|
|
|
|
private void TestTemplateBuild(string templateName)
|
|
{
|
|
var directory = TestAssets.CreateTestDirectory(identifier: templateName);
|
|
string projectDirectory = directory.FullName;
|
|
|
|
string newArgs = $"{templateName} --debug:ephemeral-hive --no-restore";
|
|
new NewCommandShim()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute(newArgs)
|
|
.Should().Pass();
|
|
|
|
// Work-around for MVC template test until ASP.Net publishes Preview 5 'Microsoft.AspNetCore.Mvc.NewtonsoftJson' to NuGet.org
|
|
string restoreArgs = string.Equals(templateName, "mvc", StringComparison.OrdinalIgnoreCase) ? "/p:RestoreAdditionalProjectSources=https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json" : "";
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute(restoreArgs)
|
|
.Should().Pass();
|
|
|
|
new BuildCommand()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.Execute()
|
|
.Should().Pass();
|
|
}
|
|
}
|
|
}
|