Update dotnet new to generate a "2.0" project.

This commit is contained in:
Eric Erhardt 2017-01-27 17:46:55 -06:00
parent 23207df2ae
commit fd65cb03b6
16 changed files with 83 additions and 66 deletions

View file

@ -62,7 +62,8 @@
<Output TaskParameter="VersionBadgeMoniker" PropertyName="VersionBadgeMoniker" /> <Output TaskParameter="VersionBadgeMoniker" PropertyName="VersionBadgeMoniker" />
</GenerateBuildVersionInfo> </GenerateBuildVersionInfo>
<GenerateNuGetPackagesArchiveVersion RepoRoot="$(RepoRoot)"> <GenerateNuGetPackagesArchiveVersion RepoRoot="$(RepoRoot)"
SharedFrameworkVersion="$(CLI_SharedFrameworkVersion)">
<Output TaskParameter="Version" PropertyName="NuGetPackagesArchiveVersion"/> <Output TaskParameter="Version" PropertyName="NuGetPackagesArchiveVersion"/>
</GenerateNuGetPackagesArchiveVersion> </GenerateNuGetPackagesArchiveVersion>

View file

@ -62,8 +62,7 @@
<FilesToClean Include="$(NuGetPackagesArchiveProject)/**/*" /> <FilesToClean Include="$(NuGetPackagesArchiveProject)/**/*" />
<FilesToClean Include="$(NuGetPackagesArchiveFolder)/**/*" /> <FilesToClean Include="$(NuGetPackagesArchiveFolder)/**/*" />
<NuGetPackagesArchiveDirectory Include="$(NuGetPackagesArchiveProject)/Web" /> <NuGetPackagesArchiveDirectory Include="$(NuGetPackagesArchiveProject)/Console" />
<NuGetPackagesArchiveDirectory Include="$(NuGetPackagesArchiveProject)/Web1.1" />
<NuGetPackagesArchiveDirectory Include="$(NuGetPackagesArchiveFolder)" /> <NuGetPackagesArchiveDirectory Include="$(NuGetPackagesArchiveFolder)" />
</ItemGroup> </ItemGroup>
@ -72,22 +71,13 @@
<MakeDir Directories="@(NuGetPackagesArchiveDirectory)"/> <MakeDir Directories="@(NuGetPackagesArchiveDirectory)"/>
<DotNetNew ToolPath="$(Stage2Directory)" <DotNetNew ToolPath="$(Stage2Directory)"
TemplateType="Web" TemplateType="Console"
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web" /> WorkingDirectory="$(NuGetPackagesArchiveProject)/Console" />
<DotNetRestore ToolPath="$(Stage2Directory)" <DotNetRestore ToolPath="$(Stage2Directory)"
Packages="$(NuGetPackagesArchiveFolder)" Packages="$(NuGetPackagesArchiveFolder)"
SkipInvalidConfigurations="True" SkipInvalidConfigurations="True"
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web" /> WorkingDirectory="$(NuGetPackagesArchiveProject)/Console" />
<DotNetNew ToolPath="$(Stage2Directory)"
TemplateType="Web1.1"
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web1.1" />
<DotNetRestore ToolPath="$(Stage2Directory)"
Packages="$(NuGetPackagesArchiveFolder)"
SkipInvalidConfigurations="True"
WorkingDirectory="$(NuGetPackagesArchiveProject)/Web1.1" />
<Delete Files="$(IntermediateArchive);$(IntermediateArchive).zip" /> <Delete Files="$(IntermediateArchive);$(IntermediateArchive).zip" />

View file

@ -21,13 +21,15 @@ namespace Microsoft.DotNet.Cli.Build
[Required] [Required]
public string RepoRoot { get; set; } public string RepoRoot { get; set; }
[Required]
public string SharedFrameworkVersion { get; set; }
[Output] [Output]
public String Version { get; set; } public String Version { get; set; }
private static string[] s_TemplatesToArchive = new string[] private static string[] s_TemplatesToArchive = new string[]
{ {
"CSharp_Web", "CSharp_Console",
"CSharp_Web1.1",
}; };
public override bool Execute() public override bool Execute()
@ -59,6 +61,8 @@ namespace Microsoft.DotNet.Cli.Build
} }
} }
} }
dataToHash += SharedFrameworkVersion;
} }
Log.LogMessage($"NuGet Packages Archive Data To Hash: '{dataToHash}'"); Log.LogMessage($"NuGet Packages Archive Data To Hash: '{dataToHash}'");

View file

@ -12,8 +12,7 @@ namespace Microsoft.DotNet.Configurer
{ {
private static string[] s_TemplatesUsedToPrimeCache = new string[] private static string[] s_TemplatesUsedToPrimeCache = new string[]
{ {
"Web", "Console",
"Web1.1"
}; };
private readonly ICommandFactory _commandFactory; private readonly ICommandFactory _commandFactory;

View file

@ -2,7 +2,8 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>$CurrentSharedFrameworkVersion$</RuntimeFrameworkVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -0,0 +1,5 @@
<configuration>
<packageSources>
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
</configuration>

View file

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
</Project>

View file

@ -1,12 +0,0 @@
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View file

@ -62,10 +62,19 @@ namespace Microsoft.DotNet.Tools.New
if (Path.GetFileNameWithoutExtension(file) == "$projectName$") if (Path.GetFileNameWithoutExtension(file) == "$projectName$")
{ {
string extension = Path.GetExtension(file); string extension = Path.GetExtension(file);
string newFileName = Path.Combine(Path.GetDirectoryName(file), $"{projectName}{extension}");
File.Move( File.Move(file, newFileName);
file,
Path.Combine(Path.GetDirectoryName(file), $"{projectName}{extension}")); // for perf reasons, only projects can have replacement values in them
string originalProjectText = File.ReadAllText(newFileName);
string replacedProjectText = originalProjectText
.Replace("$CurrentSharedFrameworkVersion$", new Muxer().SharedFxVersion);
if (replacedProjectText != originalProjectText)
{
File.WriteAllText(newFileName, replacedProjectText);
}
} }
} }
} }
@ -84,7 +93,6 @@ namespace Microsoft.DotNet.Tools.New
Templates = new[] Templates = new[]
{ {
new { Name = "Console" }, new { Name = "Console" },
new { Name = "Console1.1" },
new { Name = "Web" }, new { Name = "Web" },
new { Name = "Web1.1" }, new { Name = "Web1.1" },
new { Name = "Lib" }, new { Name = "Lib" },

View file

@ -62,10 +62,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_dotnetNewCommandMock = new Mock<ICommand>(); _dotnetNewCommandMock = new Mock<ICommand>();
SetupCommandMock(_dotnetNewCommandMock); SetupCommandMock(_dotnetNewCommandMock);
commandFactoryMock commandFactoryMock
.Setup(c => c.Create("new", new[] { "-t", "Web" }, null, Constants.DefaultConfiguration)) .Setup(c => c.Create("new", new[] { "-t", "Console" }, null, Constants.DefaultConfiguration))
.Returns(_dotnetNewCommandMock.Object);
commandFactoryMock
.Setup(c => c.Create("new", new[] { "-t", "Web1.1" }, null, Constants.DefaultConfiguration))
.Returns(_dotnetNewCommandMock.Object); .Returns(_dotnetNewCommandMock.Object);
_dotnetRestoreCommandMock = new Mock<ICommand>(); _dotnetRestoreCommandMock = new Mock<ICommand>();
@ -127,25 +124,25 @@ namespace Microsoft.DotNet.Configurer.UnitTests
[Fact] [Fact]
public void It_runs_dotnet_new_using_the_temporary_folder() public void It_runs_dotnet_new_using_the_temporary_folder()
{ {
_dotnetNewCommandMock.Verify(c => c.WorkingDirectory(TEMPORARY_FOLDER_PATH), Times.Exactly(2)); _dotnetNewCommandMock.Verify(c => c.WorkingDirectory(TEMPORARY_FOLDER_PATH), Times.Exactly(1));
} }
[Fact] [Fact]
public void It_runs_dotnet_new_capturing_stdout() public void It_runs_dotnet_new_capturing_stdout()
{ {
_dotnetNewCommandMock.Verify(c => c.CaptureStdOut(), Times.Exactly(2)); _dotnetNewCommandMock.Verify(c => c.CaptureStdOut(), Times.Exactly(1));
} }
[Fact] [Fact]
public void It_runs_dotnet_new_capturing_stderr() public void It_runs_dotnet_new_capturing_stderr()
{ {
_dotnetNewCommandMock.Verify(c => c.CaptureStdErr(), Times.Exactly(2)); _dotnetNewCommandMock.Verify(c => c.CaptureStdErr(), Times.Exactly(1));
} }
[Fact] [Fact]
public void It_actually_runs_dotnet_new() public void It_actually_runs_dotnet_new()
{ {
_dotnetNewCommandMock.Verify(c => c.Execute(), Times.Exactly(2)); _dotnetNewCommandMock.Verify(c => c.Execute(), Times.Exactly(1));
} }
[Fact] [Fact]
@ -157,7 +154,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
new [] {"-s", $"{PACKAGES_ARCHIVE_PATH}"}, new [] {"-s", $"{PACKAGES_ARCHIVE_PATH}"},
null, null,
Constants.DefaultConfiguration), Constants.DefaultConfiguration),
Times.Exactly(2)); Times.Exactly(1));
} }
[Fact] [Fact]
@ -187,25 +184,25 @@ namespace Microsoft.DotNet.Configurer.UnitTests
[Fact] [Fact]
public void It_runs_dotnet_restore_using_the_temporary_folder() public void It_runs_dotnet_restore_using_the_temporary_folder()
{ {
_dotnetRestoreCommandMock.Verify(c => c.WorkingDirectory(TEMPORARY_FOLDER_PATH), Times.Exactly(2)); _dotnetRestoreCommandMock.Verify(c => c.WorkingDirectory(TEMPORARY_FOLDER_PATH), Times.Exactly(1));
} }
[Fact] [Fact]
public void It_runs_dotnet_restore_capturing_stdout() public void It_runs_dotnet_restore_capturing_stdout()
{ {
_dotnetRestoreCommandMock.Verify(c => c.CaptureStdOut(), Times.Exactly(2)); _dotnetRestoreCommandMock.Verify(c => c.CaptureStdOut(), Times.Exactly(1));
} }
[Fact] [Fact]
public void It_runs_dotnet_restore_capturing_stderr() public void It_runs_dotnet_restore_capturing_stderr()
{ {
_dotnetRestoreCommandMock.Verify(c => c.CaptureStdErr(), Times.Exactly(2)); _dotnetRestoreCommandMock.Verify(c => c.CaptureStdErr(), Times.Exactly(1));
} }
[Fact] [Fact]
public void It_actually_runs_dotnet_restore() public void It_actually_runs_dotnet_restore()
{ {
_dotnetRestoreCommandMock.Verify(c => c.Execute(), Times.Exactly(2)); _dotnetRestoreCommandMock.Verify(c => c.Execute(), Times.Exactly(1));
} }
[Fact] [Fact]

View file

@ -156,6 +156,25 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<DirectoryInfoAssertions>(this); return new AndConstraint<DirectoryInfoAssertions>(this);
} }
public AndConstraint<DirectoryInfoAssertions> NotHaveDirectory(string unexpectedDir)
{
var dir = _dirInfo.EnumerateDirectories(unexpectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault();
Execute.Assertion.ForCondition(dir == null)
.FailWith("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName);
return new AndConstraint<DirectoryInfoAssertions>(new DirectoryInfoAssertions(dir));
}
public AndConstraint<DirectoryInfoAssertions> NotHaveDirectories(IEnumerable<string> unexpectedDirs)
{
foreach (var unexpectedDir in unexpectedDirs)
{
NotHaveDirectory(unexpectedDir);
}
return new AndConstraint<DirectoryInfoAssertions>(this);
}
public AndConstraint<DirectoryInfoAssertions> OnlyHaveFiles(IEnumerable<string> expectedFiles) public AndConstraint<DirectoryInfoAssertions> OnlyHaveFiles(IEnumerable<string> expectedFiles)
{ {
var actualFiles = _dirInfo.EnumerateFiles("*", SearchOption.TopDirectoryOnly).Select(f => f.Name); var actualFiles = _dirInfo.EnumerateFiles("*", SearchOption.TopDirectoryOnly).Select(f => f.Name);

View file

@ -110,11 +110,10 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
.ExecuteWithCapturedOutput() .ExecuteWithCapturedOutput()
.Should().Pass(); .Should().Pass();
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug"; var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
var outputProgram = rootDir var outputProgram = rootDir
.GetDirectory("bin", configuration, "netcoreapp1.0", "publish", $"{rootDir.Name}.dll") .GetDirectory("bin", configuration, "netcoreapp2.0", "publish", $"{rootDir.Name}.dll")
.FullName; .FullName;
new TestCommand(outputProgram) new TestCommand(outputProgram)

View file

@ -91,6 +91,13 @@ A command is running to initially populate your local package cache, to improve
List<string> expectedDirectories = new List<string>() List<string> expectedDirectories = new List<string>()
{ {
"microsoft.netcore.app", "microsoft.netcore.app",
"microsoft.netcore.platforms",
"netstandard.library",
};
// https://github.com/dotnet/cli/issues/5505 - add the "2.0" asp.net packages into the offline cache
List<string> unexpectedDirectories = new List<string>()
{
"microsoft.aspnetcore.diagnostics", "microsoft.aspnetcore.diagnostics",
"microsoft.aspnetcore.mvc", "microsoft.aspnetcore.mvc",
"microsoft.aspnetcore.routing", "microsoft.aspnetcore.routing",
@ -111,12 +118,8 @@ A command is running to initially populate your local package cache, to improve
.HaveDirectories(expectedDirectories); .HaveDirectories(expectedDirectories);
_nugetCacheFolder _nugetCacheFolder
.GetDirectory("system.runtime") .Should()
.Should().HaveDirectories(new string[] { "4.1.0", "4.3.0" }); .NotHaveDirectories(unexpectedDirectories);
_nugetCacheFolder
.GetDirectory("microsoft.aspnetcore.mvc")
.Should().HaveDirectories(new string[] { "1.0.2", "1.1.0" });
} }
private string GetDotnetVersion() private string GetDotnetVersion()

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64;osx.10.10-x64;rhel.7-x64</RuntimeIdentifiers> <RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="**\*.cs" /> <Compile Include="**\*.cs" />

View file

@ -0,0 +1,11 @@
<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>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64;osx.10.10-x64;rhel.7-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="$(CLI_CoreCLRVersion)" />
</ItemGroup>
</Project>