@@ -414,7 +414,7 @@ public static bool StartAndVerifyProcessesAreRunning(List<ProcessStartOptions> p
414
414
return true ;
415
415
}
416
416
417
- static void RestartProcesses ( Dictionary < string , Process > processes , List < ProcessStartOptions > processDataEntries )
417
+ private static void RestartProcesses ( Dictionary < string , Process > processes , List < ProcessStartOptions > processDataEntries )
418
418
{
419
419
//attempt to restart failed processes
420
420
foreach ( KeyValuePair < string , Process > processEntry in processes )
@@ -434,6 +434,12 @@ static void RestartProcesses(Dictionary<string, Process> processes, List<Process
434
434
}
435
435
}
436
436
}
437
+
438
+ /// <summary>
439
+ /// Returns a string representation of the running processes
440
+ /// </summary>
441
+ /// <param name="processes">Dict of running processes</param>
442
+ /// <returns>A string of all processes from the give dict</returns>
437
443
public static string GetRunningProcessAsString ( Dictionary < string , Process > ? processes )
438
444
{
439
445
StringBuilder runningProcesses = new StringBuilder ( ) ;
@@ -469,8 +475,11 @@ private static void SwapFiles(string path1, string path2)
469
475
Console . WriteLine ( "File contents swapped successfully." ) ;
470
476
}
471
477
472
-
473
- private static void RebuildSolution ( string solutionPath )
478
+ /// <summary>
479
+ /// Builds the solution at the given path.
480
+ /// </summary>
481
+ /// <param name="solutionPath">Absolute path to the sln file to be built</param>
482
+ private static void BuildSolution ( string solutionPath )
474
483
{
475
484
ProcessStartInfo startInfo = new ProcessStartInfo
476
485
{
@@ -479,7 +488,7 @@ private static void RebuildSolution(string solutionPath)
479
488
RedirectStandardOutput = true ,
480
489
RedirectStandardError = true ,
481
490
UseShellExecute = false ,
482
- CreateNoWindow = false
491
+ CreateNoWindow = true
483
492
} ;
484
493
485
494
using ( Process process = new Process ( ) )
@@ -497,22 +506,29 @@ private static void RebuildSolution(string solutionPath)
497
506
Console . WriteLine ( "Solution rebuild initiated." ) ;
498
507
}
499
508
509
+ /// <summary>
510
+ /// Replaces existing appsettings.json file with a test appsettings file, builds the solution, and then swaps the files back.
511
+ /// </summary>
512
+ /// <param name="testAssemblyLocation">Absolute path to the current test's working directory</param>
513
+ /// <param name="sampleRelPath">Relative path to the sample app to build starting at the repo's root, does not include appsettings filename</param>
514
+ /// <param name="testAppsettingsRelPath">Relative path to the test appsettings file starting at the repo's root, includes appsettings filename</param>
515
+ /// <param name="solutionFileName">Filename for the sln file to build</param>
500
516
public static void BuildSampleWithTestAppsettings (
501
517
string testAssemblyLocation ,
502
- string appLocation ,
503
- string testAppsettingsPathFromRepoRoot ,
518
+ string sampleRelPath ,
519
+ string testAppsettingsRelPath ,
504
520
string solutionFileName
505
521
)
506
522
{
507
- string appsettingsDirectory = GetAppsettingsDirectory ( testAssemblyLocation , appLocation ) ;
508
- string appsettingsPath = Path . Combine ( appsettingsDirectory , TestConstants . AppSetttingsDotJson ) ;
509
- string testAppsettingsPath = GetAppsettingsDirectory ( testAssemblyLocation , testAppsettingsPathFromRepoRoot ) ;
523
+ string appsettingsDirectory = GetAppsettingsDirectory ( testAssemblyLocation , sampleRelPath ) ;
524
+ string appsettingsAbsPath = Path . Combine ( appsettingsDirectory , TestConstants . AppSetttingsDotJson ) ;
525
+ string testAppsettingsAbsPath = GetAppsettingsDirectory ( testAssemblyLocation , testAppsettingsRelPath ) ;
510
526
511
- SwapFiles ( appsettingsPath , testAppsettingsPath ) ;
527
+ SwapFiles ( appsettingsAbsPath , testAppsettingsAbsPath ) ;
512
528
513
- try { RebuildSolution ( appsettingsDirectory + solutionFileName ) ; }
529
+ try { BuildSolution ( appsettingsDirectory + solutionFileName ) ; }
514
530
catch ( Exception ) { throw ; }
515
- finally { SwapFiles ( appsettingsPath , testAppsettingsPath ) ; }
531
+ finally { SwapFiles ( appsettingsAbsPath , testAppsettingsAbsPath ) ; }
516
532
}
517
533
}
518
534
0 commit comments