@@ -43,11 +43,11 @@ internal static class TemplatePackageInstaller
43
43
"Microsoft.AspNetCore.Blazor.Templates" ,
44
44
} ;
45
45
46
- public static string CustomHivePath { get ; } = ( string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "helix" ) ) )
46
+ public static string CustomHivePath { get ; } = Path . GetFullPath ( ( string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "helix" ) ) )
47
47
? typeof ( TemplatePackageInstaller )
48
48
. Assembly . GetCustomAttributes < AssemblyMetadataAttribute > ( )
49
49
. Single ( s => s . Key == "CustomTemplateHivePath" ) . Value
50
- : Path . Combine ( "Hives" , ".templateEngine" ) ;
50
+ : Path . Combine ( "Hives" , ".templateEngine" ) ) ;
51
51
52
52
public static async Task EnsureTemplatingEngineInitializedAsync ( ITestOutputHelper output )
53
53
{
@@ -78,7 +78,9 @@ public static async Task<ProcessEx> RunDotNetNew(ITestOutputHelper output, strin
78
78
output ,
79
79
AppContext . BaseDirectory ,
80
80
DotNetMuxer . MuxerPathOrDefault ( ) ,
81
- $ "new { arguments } --debug:custom-hive \" { CustomHivePath } \" ") ;
81
+ //--debug:disable-sdk-templates means, don't include C:\Program Files\dotnet\templates, aka. what comes with SDK, so we don't need to uninstall
82
+ //--debug:custom-hive means, don't install templates on CI/developer machine, instead create new temporary instance
83
+ $ "new { arguments } --debug:disable-sdk-templates --debug:custom-hive \" { CustomHivePath } \" ") ;
82
84
83
85
await proc . Exited ;
84
86
@@ -105,23 +107,12 @@ private static async Task InstallTemplatePackages(ITestOutputHelper output)
105
107
106
108
Assert . Equal ( 4 , builtPackages . Length ) ;
107
109
108
- /*
109
- * The templates are indexed by path, for example:
110
- &USERPROFILE%\.templateengine\dotnetcli\v5.0.100-alpha1-013788\packages\nunit3.dotnetnew.template.1.6.1.nupkg
111
- Templates:
112
- NUnit 3 Test Project (nunit) C#
113
- NUnit 3 Test Item (nunit-test) C#
114
- NUnit 3 Test Project (nunit) F#
115
- NUnit 3 Test Item (nunit-test) F#
116
- NUnit 3 Test Project (nunit) VB
117
- NUnit 3 Test Item (nunit-test) VB
118
- Uninstall Command:
119
- dotnet new -u &USERPROFILE%\.templateengine\dotnetcli\v5.0.100-alpha1-013788\packages\nunit3.dotnetnew.template.1.6.1.nupkg
120
-
121
- * We don't want to construct this path so we'll rely on dotnet new --uninstall --help to construct the uninstall command.
122
- */
123
- // Workaround for https://github.com/dotnet/sdk/issues/16906
124
- // await UninstallExistingTemplatesAsync(output);
110
+ await VerifyCannotFindTemplateAsync ( output , "web" ) ;
111
+ await VerifyCannotFindTemplateAsync ( output , "webapp" ) ;
112
+ await VerifyCannotFindTemplateAsync ( output , "mvc" ) ;
113
+ await VerifyCannotFindTemplateAsync ( output , "react" ) ;
114
+ await VerifyCannotFindTemplateAsync ( output , "reactredux" ) ;
115
+ await VerifyCannotFindTemplateAsync ( output , "angular" ) ;
125
116
126
117
foreach ( var packagePath in builtPackages )
127
118
{
@@ -135,35 +126,6 @@ NUnit 3 Test Item (nunit-test) VB
135
126
await VerifyCanFindTemplate ( output , "react" ) ;
136
127
}
137
128
138
- private static async Task UninstallExistingTemplatesAsync ( ITestOutputHelper output )
139
- {
140
- var proc = await RunDotNetNew ( output , "--uninstall --help" ) ;
141
- var lines = proc . Output . Split ( Environment . NewLine ) ;
142
-
143
- // Remove any previous or prebundled version of the template packages
144
- foreach ( var packageName in _templatePackages )
145
- {
146
- // Depending on the ordering, there may be multiple matches:
147
- // Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.3.0.0-preview7.*.nupkg
148
- // Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview7.*.nupkg
149
- // Error on the side of caution and uninstall all of them
150
- foreach ( var command in lines . Where ( l => l . Contains ( "dotnet new" ) && l . Contains ( packageName , StringComparison . OrdinalIgnoreCase ) ) )
151
- {
152
- var uninstallCommand = command . TrimStart ( ) ;
153
- Debug . Assert ( uninstallCommand . StartsWith ( "dotnet new" , StringComparison . Ordinal ) ) ;
154
- uninstallCommand = uninstallCommand . Substring ( "dotnet new" . Length ) ;
155
- await RunDotNetNew ( output , uninstallCommand ) ;
156
- }
157
- }
158
-
159
- await VerifyCannotFindTemplateAsync ( output , "web" ) ;
160
- await VerifyCannotFindTemplateAsync ( output , "webapp" ) ;
161
- await VerifyCannotFindTemplateAsync ( output , "mvc" ) ;
162
- await VerifyCannotFindTemplateAsync ( output , "react" ) ;
163
- await VerifyCannotFindTemplateAsync ( output , "reactredux" ) ;
164
- await VerifyCannotFindTemplateAsync ( output , "angular" ) ;
165
- }
166
-
167
129
private static async Task VerifyCanFindTemplate ( ITestOutputHelper output , string templateName )
168
130
{
169
131
var proc = await RunDotNetNew ( output , $ "" ) ;
0 commit comments