Update dotnet new to use the new 2.0 templates.
This commit is contained in:
parent
546d62061a
commit
454dd10f8d
10 changed files with 16 additions and 184 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<BundledTemplate Include="Microsoft.DotNet.Common.ItemTemplates" Version="$(TemplateEngineTemplateVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Common.ProjectTemplates" Version="$(TemplateEngineTemplateVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Common.ProjectTemplates.2.0" Version="$(TemplateEngineTemplate2_0Version)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Test.ProjectTemplates" Version="$(TemplateEngineTemplateVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Web.ProjectTemplates" Version="$(TemplateEngineTemplateVersion)" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
<CLI_TestPlatform_Version>15.0.0-preview-20170125-04</CLI_TestPlatform_Version>
|
||||
<TemplateEngineVersion>1.0.0-beta1-20170202-111</TemplateEngineVersion>
|
||||
<TemplateEngineTemplateVersion>1.0.0-beta1-20170131-110</TemplateEngineTemplateVersion>
|
||||
<TemplateEngineTemplate2_0Version>1.0.0-beta1-20170207-114</TemplateEngineTemplate2_0Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -86,25 +86,15 @@
|
|||
Lines="$(NuGetConfigContent)" />
|
||||
|
||||
<DotNetNew ToolPath="$(Stage2Directory)"
|
||||
TemplateType="Mvc"
|
||||
TemplateArgs="-au Individual --debug:ephemeral-hive"
|
||||
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web" />
|
||||
TemplateType="console"
|
||||
TemplateArgs="--debug:ephemeral-hive"
|
||||
WorkingDirectory="$(NuGetPackagesArchiveProject)/Console" />
|
||||
|
||||
<DotNetRestore ToolPath="$(Stage2Directory)"
|
||||
Packages="$(NuGetPackagesArchiveFolder)"
|
||||
SkipInvalidConfigurations="True"
|
||||
WorkingDirectory="$(NuGetPackagesArchiveProject)/Console" />
|
||||
|
||||
<DotNetNew ToolPath="$(Stage2Directory)"
|
||||
TemplateType="Mvc"
|
||||
TemplateArgs="-au Individual -f netcoreapp1.1 --debug:ephemeral-hive"
|
||||
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web1.1" />
|
||||
|
||||
<DotNetRestore ToolPath="$(Stage2Directory)"
|
||||
Packages="$(NuGetPackagesArchiveFolder)"
|
||||
SkipInvalidConfigurations="True"
|
||||
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web1.1" />
|
||||
|
||||
<Delete Files="$(IntermediateArchive);$(IntermediateArchive).zip" />
|
||||
|
||||
<Message Text="Publishing Archiver" />
|
||||
|
|
|
@ -26,8 +26,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
private static string[][] _templatesAndArgs = new string[][]
|
||||
{
|
||||
new string[] { "mvc", "-au Individual -f netcoreapp1.0" },
|
||||
new string[] { "mvc", "-au Individual -f netcoreapp1.1" }
|
||||
new string[] { "console", "" },
|
||||
};
|
||||
|
||||
public override bool Execute()
|
||||
|
@ -67,6 +66,12 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
}
|
||||
|
||||
var frameworkVersion = rootElement.Properties.LastOrDefault(p => p.Name == "RuntimeFrameworkVersion");
|
||||
if (frameworkVersion != null)
|
||||
{
|
||||
dataToHash += $"RuntimeFrameworkVersion={frameworkVersion.Value}";
|
||||
}
|
||||
|
||||
Directory.Delete(targetDir, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ namespace Microsoft.DotNet.Configurer
|
|||
{
|
||||
private static IReadOnlyList<IReadOnlyList<string>> _templatesUsedToPrimeCache = new List<IReadOnlyList<string>>()
|
||||
{
|
||||
new List<string>() { "mvc", "-f", "netcoreapp1.0", "-au", "Individual", "--debug:ephemeral-hive" },
|
||||
new List<string>() { "mvc", "-f", "netcoreapp1.1", "-au", "Individual", "--debug:ephemeral-hive" }
|
||||
new List<string>() { "console", "--debug:ephemeral-hive" },
|
||||
};
|
||||
|
||||
private readonly ICommandFactory _commandFactory;
|
||||
|
|
|
@ -52,7 +52,8 @@ namespace Microsoft.DotNet.Tools.New
|
|||
var preferences = new Dictionary<string, string>
|
||||
{
|
||||
{ "prefs:language", "C#" },
|
||||
{ "dotnet-cli-version", Product.Version }
|
||||
{ "dotnet-cli-version", Product.Version },
|
||||
{ "RuntimeFrameworkVersion", new Muxer().SharedFxVersion },
|
||||
};
|
||||
|
||||
return new DefaultTemplateEngineHost(HostIdentifier, "v" + Product.Version, CultureInfo.CurrentCulture.Name, preferences, builtIns);
|
||||
|
|
|
@ -63,10 +63,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
SetupCommandMock(_dotnetNewCommandMock);
|
||||
|
||||
commandFactoryMock
|
||||
.Setup(c => c.Create("new", new[] { "mvc", "-f", "netcoreapp1.0", "-au", "Individual", "--debug:ephemeral-hive" }, null, Constants.DefaultConfiguration))
|
||||
.Returns(_dotnetNewCommandMock.Object);
|
||||
commandFactoryMock
|
||||
.Setup(c => c.Create("new", new[] { "mvc", "-f", "netcoreapp1.1", "-au", "Individual", "--debug:ephemeral-hive" }, null, Constants.DefaultConfiguration))
|
||||
.Setup(c => c.Create("new", new[] { "console", "--debug:ephemeral-hive" }, null, Constants.DefaultConfiguration))
|
||||
.Returns(_dotnetNewCommandMock.Object);
|
||||
|
||||
_dotnetRestoreCommandMock = new Mock<ICommand>();
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
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;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
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)
|
||||
{
|
||||
var configFile = new FileInfo(Path.Combine(rootPath,"..","..","..","..","NuGet.tempaspnetpatch.config"));
|
||||
File.Copy(configFile.FullName, 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue