7
7
using System . IO ;
8
8
using System . Linq ;
9
9
using System . Reflection ;
10
- using System . Runtime . InteropServices ;
11
10
using System . Threading ;
12
11
using System . Threading . Tasks ;
13
12
using Microsoft . AspNetCore . Internal ;
@@ -24,9 +23,6 @@ public class Project
24
23
{
25
24
private const string _urls = "http://127.0.0.1:0;https://127.0.0.1:0" ;
26
25
27
- public static bool IsCIEnvironment => typeof ( Project ) . Assembly . GetCustomAttributes < AssemblyMetadataAttribute > ( )
28
- . Any ( a => a . Key == "ContinuousIntegrationBuild" ) ;
29
-
30
26
public static string ArtifactsLogDir => ( string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "HELIX_WORKITEM_UPLOAD_ROOT" ) ) )
31
27
? GetAssemblyMetadata ( "ArtifactsLogDir" )
32
28
: Environment . GetEnvironmentVariable ( "HELIX_WORKITEM_UPLOAD_ROOT" ) ;
@@ -48,12 +44,6 @@ public class Project
48
44
public string TemplateBuildDir => Path . Combine ( TemplateOutputDir , "bin" , "Debug" , TargetFramework ) ;
49
45
public string TemplatePublishDir => Path . Combine ( TemplateOutputDir , "bin" , "Release" , TargetFramework , "publish" ) ;
50
46
51
- private string TemplateServerDir => Path . Combine ( TemplateOutputDir , $ "{ ProjectName } .Server") ;
52
- private string TemplateClientDir => Path . Combine ( TemplateOutputDir , $ "{ ProjectName } .Client") ;
53
- public string TemplateClientDebugDir => Path . Combine ( TemplateClientDir , "bin" , "Debug" , TargetFramework ) ;
54
- public string TemplateClientReleaseDir => Path . Combine ( TemplateClientDir , "bin" , "Release" , TargetFramework , "publish" ) ;
55
- public string TemplateServerReleaseDir => Path . Combine ( TemplateServerDir , "bin" , "Release" , TargetFramework , "publish" ) ;
56
-
57
47
public ITestOutputHelper Output { get ; set ; }
58
48
public IMessageSink DiagnosticsMessageSink { get ; set ; }
59
49
@@ -164,50 +154,6 @@ internal async Task<ProcessEx> RunDotNetBuildAsync(bool takeNodeLock = false, ID
164
154
}
165
155
}
166
156
167
- internal AspNetProcess StartBuiltServerAsync ( )
168
- {
169
- var environment = new Dictionary < string , string >
170
- {
171
- [ "ASPNETCORE_ENVIRONMENT" ] = "Development"
172
- } ;
173
-
174
- var projectDll = Path . Combine ( TemplateServerDir , $ "{ ProjectName } .Server.dll") ;
175
- return new AspNetProcess ( Output , TemplateServerDir , projectDll , environment , published : false ) ;
176
- }
177
-
178
- internal AspNetProcess StartBuiltClientAsync ( AspNetProcess serverProcess )
179
- {
180
- var environment = new Dictionary < string , string >
181
- {
182
- [ "ASPNETCORE_ENVIRONMENT" ] = "Development"
183
- } ;
184
-
185
- var projectDll = Path . Combine ( TemplateClientDebugDir , $ "{ ProjectName } .Client.dll { serverProcess . ListeningUri . Port } ") ;
186
- return new AspNetProcess ( Output , TemplateOutputDir , projectDll , environment , hasListeningUri : false ) ;
187
- }
188
-
189
- internal AspNetProcess StartPublishedServerAsync ( )
190
- {
191
- var environment = new Dictionary < string , string >
192
- {
193
- [ "ASPNETCORE_URLS" ] = _urls ,
194
- } ;
195
-
196
- var projectDll = $ "{ ProjectName } .Server.dll";
197
- return new AspNetProcess ( Output , TemplateServerReleaseDir , projectDll , environment ) ;
198
- }
199
-
200
- internal AspNetProcess StartPublishedClientAsync ( )
201
- {
202
- var environment = new Dictionary < string , string >
203
- {
204
- [ "ASPNETCORE_URLS" ] = _urls ,
205
- } ;
206
-
207
- var projectDll = $ "{ ProjectName } .Client.dll";
208
- return new AspNetProcess ( Output , TemplateClientReleaseDir , projectDll , environment ) ;
209
- }
210
-
211
157
internal AspNetProcess StartBuiltProjectAsync ( bool hasListeningUri = true , ILogger logger = null )
212
158
{
213
159
var environment = new Dictionary < string , string >
@@ -239,73 +185,6 @@ internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true)
239
185
return new AspNetProcess ( Output , TemplatePublishDir , projectDll , environment , hasListeningUri : hasListeningUri ) ;
240
186
}
241
187
242
- internal async Task < ProcessEx > RestoreWithRetryAsync ( ITestOutputHelper output , string workingDirectory )
243
- {
244
- // "npm restore" sometimes fails randomly in AppVeyor with errors like:
245
- // EPERM: operation not permitted, scandir <path>...
246
- // This appears to be a general NPM reliability issue on Windows which has
247
- // been reported many times (e.g., https://github.com/npm/npm/issues/18380)
248
- // So, allow multiple attempts at the restore.
249
- const int maxAttempts = 3 ;
250
- var attemptNumber = 0 ;
251
- ProcessEx restoreResult ;
252
- do
253
- {
254
- restoreResult = await RestoreAsync ( output , workingDirectory ) ;
255
- if ( restoreResult . HasExited && restoreResult . ExitCode == 0 )
256
- {
257
- return restoreResult ;
258
- }
259
- else
260
- {
261
- // TODO: We should filter for EPEM here to avoid masking other errors silently.
262
- output . WriteLine (
263
- $ "NPM restore in { workingDirectory } failed on attempt { attemptNumber } of { maxAttempts } . " +
264
- $ "Error was: { restoreResult . GetFormattedOutput ( ) } ") ;
265
-
266
- // Clean up the possibly-incomplete node_modules dir before retrying
267
- CleanNodeModulesFolder ( workingDirectory , output ) ;
268
- }
269
- attemptNumber ++ ;
270
- } while ( attemptNumber < maxAttempts ) ;
271
-
272
- output . WriteLine ( $ "Giving up attempting NPM restore in { workingDirectory } after { attemptNumber } attempts.") ;
273
- return restoreResult ;
274
-
275
- void CleanNodeModulesFolder ( string workingDirectory , ITestOutputHelper output )
276
- {
277
- var nodeModulesDir = Path . Combine ( workingDirectory , "node_modules" ) ;
278
- try
279
- {
280
- if ( Directory . Exists ( nodeModulesDir ) )
281
- {
282
- Directory . Delete ( nodeModulesDir , recursive : true ) ;
283
- }
284
- }
285
- catch
286
- {
287
- output . WriteLine ( $ "Failed to clean up node_modules folder at { nodeModulesDir } .") ;
288
- }
289
- }
290
- }
291
-
292
- private async Task < ProcessEx > RestoreAsync ( ITestOutputHelper output , string workingDirectory )
293
- {
294
- // It's not safe to run multiple NPM installs in parallel
295
- // https://github.com/npm/npm/issues/2500
296
- await NodeLock . WaitAsync ( ) ;
297
- try
298
- {
299
- output . WriteLine ( $ "Restoring NPM packages in '{ workingDirectory } ' using npm...") ;
300
- var result = ProcessEx . RunViaShell ( output , workingDirectory , "npm install" ) ;
301
- return result ;
302
- }
303
- finally
304
- {
305
- NodeLock . Release ( ) ;
306
- }
307
- }
308
-
309
188
internal async Task < ProcessEx > RunDotNetEfCreateMigrationAsync ( string migrationName )
310
189
{
311
190
var args = $ "--verbose --no-build migrations add { migrationName } ";
@@ -335,35 +214,6 @@ internal async Task<ProcessEx> RunDotNetEfCreateMigrationAsync(string migrationN
335
214
}
336
215
}
337
216
338
- internal async Task < ProcessEx > RunDotNetEfUpdateDatabaseAsync ( )
339
- {
340
- var args = "--verbose --no-build database update" ;
341
-
342
- // Only run one instance of 'dotnet new' at once, as a workaround for
343
- // https://github.com/aspnet/templating/issues/63
344
- await DotNetNewLock . WaitAsync ( ) ;
345
- try
346
- {
347
- var command = DotNetMuxer . MuxerPathOrDefault ( ) ;
348
- if ( string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "DotNetEfFullPath" ) ) )
349
- {
350
- args = $ "\" { DotNetEfFullPath } \" " + args ;
351
- }
352
- else
353
- {
354
- command = "dotnet-ef" ;
355
- }
356
-
357
- var result = ProcessEx . Run ( Output , TemplateOutputDir , command , args ) ;
358
- await result . Exited ;
359
- return result ;
360
- }
361
- finally
362
- {
363
- DotNetNewLock . Release ( ) ;
364
- }
365
- }
366
-
367
217
// If this fails, you should generate new migrations via migrations/updateMigrations.cmd
368
218
public void AssertEmptyMigration ( string migration )
369
219
{
0 commit comments