@@ -60,7 +60,7 @@ await notificationService.PublishUpdateAsync(resource, state => state with
60
60
61
61
logger . LogInformation ( "Installing {PackageManager} packages in {WorkingDirectory}" , packageManager , resource . WorkingDirectory ) ;
62
62
63
- var packageInstaller = new Process
63
+ var packageInstaller = ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? => new Process
64
64
{
65
65
StartInfo = new ProcessStartInfo
66
66
{
@@ -69,51 +69,64 @@ await notificationService.PublishUpdateAsync(resource, state => state with
69
69
WorkingDirectory = resource . WorkingDirectory ,
70
70
RedirectStandardOutput = true ,
71
71
RedirectStandardError = true ,
72
- UseShellExecute = false ,
73
- CreateNoWindow = true
72
+ CreateNoWindow = true ,
73
+ UseShellExecute = true ,
74
74
}
75
- } ;
76
-
77
- packageInstaller . OutputDataReceived += async ( sender , args ) =>
78
- {
79
- if ( ! string . IsNullOrWhiteSpace ( args . Data ) )
75
+ : new Process
80
76
{
81
- await notificationService . PublishUpdateAsync ( resource , state => state with
77
+ StartInfo = new ProcessStartInfo
82
78
{
83
- State = new ( args . Data , KnownResourceStates . Starting )
84
- } ) . ConfigureAwait ( false ) ;
85
-
86
- logger . LogInformation ( "{Data}" , args . Data ) ;
79
+ FileName = "cmd" ,
80
+ Arguments = $ "/c { packageManager } install",
81
+ WorkingDirectory = resource . WorkingDirectory ,
82
+ RedirectStandardOutput = true ,
83
+ RedirectStandardError = true ,
84
+ CreateNoWindow = true ,
85
+ UseShellExecute = false ,
86
+ }
87
87
}
88
88
} ;
89
89
90
- packageInstaller . ErrorDataReceived += async ( sender , args ) =>
90
+ packageInstaller . OutputDataReceived += async ( sender , args ) =>
91
91
{
92
92
if ( ! string . IsNullOrWhiteSpace ( args . Data ) )
93
93
{
94
94
await notificationService . PublishUpdateAsync ( resource , state => state with
95
95
{
96
- State = new ( args . Data , KnownResourceStates . FailedToStart )
96
+ State = new ( args . Data , KnownResourceStates . Starting )
97
97
} ) . ConfigureAwait ( false ) ;
98
98
99
- logger . LogError ( "{Data}" , args . Data ) ;
99
+ logger . LogInformation ( "{Data}" , args . Data ) ;
100
100
}
101
101
} ;
102
102
103
- packageInstaller . Start ( ) ;
104
- packageInstaller . BeginOutputReadLine ( ) ;
105
- packageInstaller . BeginErrorReadLine ( ) ;
103
+ packageInstaller . ErrorDataReceived += async ( sender , args ) =>
104
+ {
105
+ if ( ! string . IsNullOrWhiteSpace ( args . Data ) )
106
+ {
107
+ await notificationService . PublishUpdateAsync ( resource , state => state with
108
+ {
109
+ State = new ( args . Data , KnownResourceStates . FailedToStart )
110
+ } ) . ConfigureAwait ( false ) ;
111
+
112
+ logger . LogError ( "{Data}" , args . Data ) ;
113
+ }
114
+ } ;
106
115
107
- packageInstaller . WaitForExit ( ) ;
116
+ packageInstaller . Start ( ) ;
117
+ packageInstaller . BeginOutputReadLine ( ) ;
118
+ packageInstaller . BeginErrorReadLine ( ) ;
108
119
109
- if ( packageInstaller . ExitCode != 0 )
110
- {
111
- await notificationService . PublishUpdateAsync ( resource , state => state with
112
- {
113
- State = new ( $ "{ packageManager } exited with { packageInstaller . ExitCode } ", KnownResourceStates . FailedToStart )
114
- } ) . ConfigureAwait ( false ) ;
120
+ packageInstaller . WaitForExit ( ) ;
115
121
116
- throw new InvalidOperationException ( $ "{ packageManager } install failed with exit code { packageInstaller . ExitCode } ") ;
117
- }
122
+ if ( packageInstaller . ExitCode != 0 )
123
+ {
124
+ await notificationService . PublishUpdateAsync ( resource , state => state with
125
+ {
126
+ State = new ( $ "{ packageManager } exited with { packageInstaller . ExitCode } ", KnownResourceStates . FailedToStart )
127
+ } ) . ConfigureAwait ( false ) ;
128
+
129
+ throw new InvalidOperationException ( $ "{ packageManager } install failed with exit code { packageInstaller . ExitCode } ") ;
130
+ }
118
131
}
119
132
}
0 commit comments