First step to ingest template engine (#5065)
* First step to ingest template engine Please do not merge yet @piotrp @seancpeters @livarocc * Localization * Attempt to get a build going Rename program.cs to New3Command.cs Move TableFormatter into its own file Consume template engine packages version 1.0.0-beta1-20161218-24 Temporarily add MyGet templating feed so that package restore will work * Update ExtendedCommandParser Make short form args prefer longer runs of characters in the source parameter before falling back to p:shortname syntax Change scoping for a few methods to get rid of inconsistent visiblity errors * Fix package installation wildcards * Cleanup New3Command, fix review issue, bump version, sorting for template list * Installation, loc fix, help formatting * Use latest TemplateEngine packages * New3 unit tests * Fixed formatting on csproj files * Add the build steps to add templates to the layout * Change tests slightly to make comparisons easier Also fixes the wrong flag getting passed to set language * Fixes for 127, 128, 130, 131 - help display * Sync to latest TemplateEngine version Absorbs new search logic * All tests passing Cleaner New3Command Support for project/item template contexts * Try to make tests more durable * Disable test parallelization for dotnet-new tests * Update web SDK and template engine versions * Remove AI package feed * Simplify CLI interface to Template Engine * Fix host identifier and update to latest packages * Update template engine & Web SDK versions * Fix template engine version * Remove UsingTask and redeclaration of property
This commit is contained in:
parent
5e7b946ad7
commit
decec5f8da
15 changed files with 328 additions and 5 deletions
|
@ -2,12 +2,10 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.New.Tests
|
||||
{
|
||||
|
|
68
test/dotnet-new.Tests/New3/GivenThatIWantANewApp.cs
Normal file
68
test/dotnet-new.Tests/New3/GivenThatIWantANewApp.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// 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 Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.New3.Tests
|
||||
{
|
||||
public class GivenThatIWantANewApp : New3TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void When_dotnet_new_is_invoked_mupliple_times_it_should_fail()
|
||||
{
|
||||
var rootPath = TestAssetsManager.CreateTestDirectory(identifier: "new3").Path;
|
||||
|
||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.Execute($"new3 console");
|
||||
|
||||
DateTime expectedState = Directory.GetLastWriteTime(rootPath);
|
||||
|
||||
var result = new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.ExecuteWithCapturedOutput($"new3 console");
|
||||
|
||||
DateTime actualState = Directory.GetLastWriteTime(rootPath);
|
||||
|
||||
Assert.Equal(expectedState, actualState);
|
||||
|
||||
result.Should().Fail();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RestoreDoesNotUseAnyCliProducedPackagesOnItsTemplates()
|
||||
{
|
||||
string[] cSharpTemplates = new[] { "console", "classlib", "mstest", "xunit", "web", "mvc", "webapi" };
|
||||
|
||||
var rootPath = TestAssetsManager.CreateTestDirectory(identifier: "new3").Path;
|
||||
var packagesDirectory = Path.Combine(rootPath, "packages");
|
||||
|
||||
foreach (string cSharpTemplate in cSharpTemplates)
|
||||
{
|
||||
var projectFolder = Path.Combine(rootPath, cSharpTemplate + "1");
|
||||
Directory.CreateDirectory(projectFolder);
|
||||
CreateAndRestoreNewProject(cSharpTemplate, projectFolder, packagesDirectory);
|
||||
}
|
||||
|
||||
Directory.EnumerateFiles(packagesDirectory, $"*.nupkg", SearchOption.AllDirectories)
|
||||
.Should().NotContain(p => p.Contains("Microsoft.DotNet.Cli.Utils"));
|
||||
}
|
||||
|
||||
private void CreateAndRestoreNewProject(
|
||||
string projectType,
|
||||
string projectFolder,
|
||||
string packagesDirectory)
|
||||
{
|
||||
new TestCommand("dotnet") { WorkingDirectory = projectFolder }
|
||||
.Execute($"new3 {projectType}")
|
||||
.Should().Pass();
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectFolder)
|
||||
.Execute($"--packages {packagesDirectory} /p:SkipInvalidConfigurations=true")
|
||||
.Should().Pass();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.DotNet.New3.Tests
|
||||
{
|
||||
public class GivenThatIWantANewAppWithSpecifiedType : New3TestBase
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("C#", "console", false)]
|
||||
[InlineData("C#", "classlib", false)]
|
||||
[InlineData("C#", "mstest", false)]
|
||||
[InlineData("C#", "xunit", false)]
|
||||
[InlineData("C#", "web", true)]
|
||||
[InlineData("C#", "mvc", true)]
|
||||
[InlineData("C#", "webapi", true)]
|
||||
[InlineData("F#", "console", false)]
|
||||
[InlineData("F#", "classlib", false)]
|
||||
[InlineData("F#", "mstest", false)]
|
||||
[InlineData("F#", "xunit", false)]
|
||||
[InlineData("F#", "mvc", true)]
|
||||
public void TemplateRestoresAndBuildsWithoutWarnings(
|
||||
string language,
|
||||
string projectType,
|
||||
bool useNuGetConfigForAspNet)
|
||||
{
|
||||
string rootPath = TestAssetsManager.CreateTestDirectory(identifier: $"new3_{language}_{projectType}").Path;
|
||||
|
||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.Execute($"new3 {projectType} -lang {language}")
|
||||
.Should().Pass();
|
||||
|
||||
if (useNuGetConfigForAspNet)
|
||||
{
|
||||
File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(rootPath, "NuGet.Config"));
|
||||
}
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.Execute($"restore")
|
||||
.Should().Pass();
|
||||
|
||||
var buildResult = new TestCommand("dotnet")
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput("build")
|
||||
.Should().Pass()
|
||||
.And.NotHaveStdErr();
|
||||
}
|
||||
}
|
||||
}
|
36
test/dotnet-new.Tests/New3/New3TestBase.cs
Normal file
36
test/dotnet-new.Tests/New3/New3TestBase.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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 Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
||||
|
||||
namespace Microsoft.DotNet.New3.Tests
|
||||
{
|
||||
public class New3TestBase : TestBase
|
||||
{
|
||||
private static readonly object InitializationSync = new object();
|
||||
private static bool _isInitialized;
|
||||
|
||||
protected New3TestBase()
|
||||
{
|
||||
if (_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (InitializationSync)
|
||||
{
|
||||
if (_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Force any previously computed configuration to be cleared
|
||||
new TestCommand("dotnet").Execute("new3 --debug:reinit");
|
||||
_isInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue