11using System ;
2+ using System . Collections . Generic ;
23using System . IO ;
34using System . Text . Json ;
45using System . Diagnostics ;
@@ -14,12 +15,6 @@ public static class OperatingSystem
1415
1516 #region OS
1617
17- /// <summary>
18- /// Test for windows OS
19- /// </summary>
20- private static bool IsWindows ( ) =>
21- RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
22-
2318 /// <summary>
2419 /// Test for linux OS
2520 /// </summary>
@@ -157,26 +152,30 @@ private static int ExecuteProcess(string fileName, string arguments,
157152 /// <param name="workingDirectory">Webserver path</param>
158153 /// <param name="webserverExec">Executable file name</param>
159154 /// <param name="webserverUrl">Target webserver url</param>
160- /// <param name="webserverName">Server name</param>
155+ /// <param name="webserverName">Server name (currently not supported)</param>
156+ /// <param name="environment">Process environment</param>
161157 public static void StartWebserver ( string workingDirectory , string webserverExec ,
162- string webserverUrl , string webserverName )
158+ // ReSharper disable once UnusedParameter.Global
159+ string webserverUrl , string webserverName , Dictionary < string , string > environment = null )
163160 {
164161 Directory . SetCurrentDirectory ( workingDirectory ) ;
165162
166- var fileName = "dotnet.exe" ;
167163 var arguments = $ "{ webserverExec } --urls={ webserverUrl } ";
168- if ( IsWindows ( ) && ! string . IsNullOrWhiteSpace ( webserverName ) )
169- {
170- fileName = "cmd.exe" ;
171- arguments = $ "/C START /MIN \" Payroll Engine - Backend Server\" dotnet { webserverExec } --urls={ webserverUrl } ";
172- }
173- var info = new ProcessStartInfo ( fileName , arguments )
164+ var info = new ProcessStartInfo ( "dotnet.exe" , arguments )
174165 {
175166
176167 WorkingDirectory = workingDirectory ,
177- UseShellExecute = ! IsLinux ( ) ,
168+ UseShellExecute = false ,
169+ //UseShellExecute = !IsLinux(),
178170 WindowStyle = ProcessWindowStyle . Minimized
179171 } ;
172+ if ( environment != null )
173+ {
174+ foreach ( var item in environment )
175+ {
176+ info . Environment . Add ( item ) ;
177+ }
178+ }
180179
181180 using var process = Process . Start ( info ) ;
182181 }
0 commit comments