Skip to content

Commit 4debc9c

Browse files
John Luodougbu
John Luo
authored andcommitted
Update SDK to preview7 (#12682)
- react to SDK changes (Microsoft.NETCore.App.Ref assemblies grouping) - update `dotnet new -u` logic
1 parent e2d57e2 commit 4debc9c

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

global.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "3.0.100-preview6-012264"
3+
"version": "3.0.100-preview7-012821"
44
},
55
"tools": {
6-
"dotnet": "3.0.100-preview6-012264",
6+
"dotnet": "3.0.100-preview7-012821",
77
"runtimes": {
88
"dotnet/x64": [
99
"$(MicrosoftNETCoreAppRuntimeVersion)"

src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
108108
Include="@(ReferencePathWithRefAssemblies)"
109109
Exclude="
110110
@(_SelectedExtensionsRefAssemblies);
111-
@(ReferencePathWithRefAssemblies->WithMetadataValue('NuGetPackageId', 'Microsoft.NETCore.App'));
111+
@(ReferencePathWithRefAssemblies->WithMetadataValue('NuGetPackageId', 'Microsoft.NETCore.App.Ref'));
112112
@(ReferencePathWithRefAssemblies->WithMetadataValue('ReferenceGrouping', 'Microsoft.NETCore.App'));" />
113113

114114
<AspNetCoreReferenceAssemblyPath

src/ProjectTemplates/test/Helpers/TemplatePackageInstaller.cs

+33-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Diagnostics;
56
using System.IO;
67
using System.Linq;
78
using System.Reflection;
@@ -30,10 +31,10 @@ internal static class TemplatePackageInstaller
3031
"Microsoft.DotNet.Web.ProjectTemplates.2.1",
3132
"Microsoft.DotNet.Web.ProjectTemplates.2.2",
3233
"Microsoft.DotNet.Web.ProjectTemplates.3.0",
33-
"Microsoft.DotNet.Web.Spa.ProjectTemplates",
3434
"Microsoft.DotNet.Web.Spa.ProjectTemplates.2.1",
3535
"Microsoft.DotNet.Web.Spa.ProjectTemplates.2.2",
36-
"Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0"
36+
"Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0",
37+
"Microsoft.DotNet.Web.Spa.ProjectTemplates"
3738
};
3839

3940
public static string CustomHivePath { get; } = typeof(TemplatePackageInstaller)
@@ -85,13 +86,38 @@ private static async Task InstallTemplatePackages(ITestOutputHelper output)
8586

8687
Assert.Equal(4, builtPackages.Length);
8788

89+
/*
90+
* The templates are indexed by path, for example:
91+
&USERPROFILE%\.templateengine\dotnetcli\v3.0.100-preview7-012821\packages\nunit3.dotnetnew.template.1.6.1.nupkg
92+
Templates:
93+
NUnit 3 Test Project (nunit) C#
94+
NUnit 3 Test Item (nunit-test) C#
95+
NUnit 3 Test Project (nunit) F#
96+
NUnit 3 Test Item (nunit-test) F#
97+
NUnit 3 Test Project (nunit) VB
98+
NUnit 3 Test Item (nunit-test) VB
99+
Uninstall Command:
100+
dotnet new -u &USERPROFILE%\.templateengine\dotnetcli\v3.0.100-preview7-012821\packages\nunit3.dotnetnew.template.1.6.1.nupkg
101+
102+
* We don't want to construct this path so we'll rely on dotnet new --uninstall --help to construct the uninstall command.
103+
*/
104+
var proc = await RunDotNetNew(output, "--uninstall --help");
105+
var lines = proc.Output.Split(Environment.NewLine);
106+
88107
// Remove any previous or prebundled version of the template packages
89108
foreach (var packageName in _templatePackages)
90109
{
91-
// We don't need this command to succeed, because we'll verify next that
92-
// uninstallation had the desired effect. This command is expected to fail
93-
// in the case where the package wasn't previously installed.
94-
await RunDotNetNew(output, $"--uninstall {packageName}");
110+
// Depending on the ordering, there may be multiple matches:
111+
// Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.3.0.0-preview7.*.nupkg
112+
// Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview7.*.nupkg
113+
// Error on the side of caution and uninstall all of them
114+
foreach (var command in lines.Where(l => l.Contains("dotnet new") && l.Contains(packageName, StringComparison.OrdinalIgnoreCase)))
115+
{
116+
var uninstallCommand = command.TrimStart();
117+
Debug.Assert(uninstallCommand.StartsWith("dotnet new"));
118+
uninstallCommand = uninstallCommand.Substring("dotnet new".Length);
119+
await RunDotNetNew(output, uninstallCommand);
120+
}
95121
}
96122

97123
await VerifyCannotFindTemplateAsync(output, "web");
@@ -132,7 +158,7 @@ private static async Task VerifyCannotFindTemplateAsync(ITestOutputHelper output
132158
{
133159
var proc = await RunDotNetNew(output, $"\"{templateName}\"");
134160

135-
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
161+
if (!proc.Output.Contains("Couldn't find an installed template that matches the input, searching online for one that does..."))
136162
{
137163
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
138164
}

0 commit comments

Comments
 (0)