@@ -119,25 +119,77 @@ public static void Generate(string rootDir, Quantity[] quantities)
119
119
/// </summary>
120
120
/// <param name="rootDir">The root directory</param>
121
121
/// <param name="quantities">The quantities to update nuspecs</param>
122
- public static void UpdateNanoFrameworkDependencies (
122
+ public static bool UpdateNanoFrameworkDependencies (
123
123
string rootDir ,
124
124
Quantity [ ] quantities )
125
125
{
126
126
// working path
127
127
string path = Path . Combine ( rootDir , "UnitsNet.NanoFramework\\ GeneratedCode" ) ;
128
128
129
129
Log . Information ( "" ) ;
130
- Log . Information ( "Updating .NET nanoFramework references using nuget CLI " ) ;
130
+ Log . Information ( "Restoring .NET nanoFramework projects " ) ;
131
131
132
132
// run nuget CLI
133
133
var nugetCLI = new Process
134
+ {
135
+ StartInfo = new ProcessStartInfo
136
+ {
137
+ FileName = Path . Combine ( rootDir , "Tools/nuget.exe" ) ,
138
+ Arguments = $ "restore { path } \\ UnitsNet.nanoFramework.sln",
139
+ UseShellExecute = false ,
140
+ CreateNoWindow = true ,
141
+ RedirectStandardError = true
142
+ }
143
+ } ;
144
+
145
+ // start nuget CLI and wait for exit
146
+ if ( ! nugetCLI . Start ( ) )
147
+ {
148
+ Log . Information ( "" ) ;
149
+ Log . Information ( "Failed to start nuget CLI to restore .NET nanoFramework projects" ) ;
150
+ Log . Information ( "" ) ;
151
+ }
152
+ else
153
+ {
154
+ // wait for exit, within 2 minutes
155
+ if ( ! nugetCLI . WaitForExit ( ( int ) TimeSpan . FromMinutes ( 2 ) . TotalMilliseconds ) )
156
+ {
157
+ Log . Information ( "" ) ;
158
+ Log . Information ( "Failed to complete execution of nuget CLI to restore .NET nanoFramework projects" ) ;
159
+ Log . Information ( "" ) ;
160
+ }
161
+ else
162
+ {
163
+ if ( nugetCLI . ExitCode == 0 )
164
+ {
165
+ Log . Information ( "Done!" ) ;
166
+ Log . Information ( "" ) ;
167
+ }
168
+ else
169
+ {
170
+ Log . Information ( "" ) ;
171
+ Log . Information ( $ "nuget CLI executed with { nugetCLI . ExitCode } exit code") ;
172
+
173
+ Log . Information ( nugetCLI . StandardError . ReadToEnd ( ) ) ;
174
+
175
+ return false ;
176
+ }
177
+ }
178
+ }
179
+
180
+ Log . Information ( "" ) ;
181
+ Log . Information ( "Updating .NET nanoFramework references using nuget CLI" ) ;
182
+
183
+ // run nuget CLI to perform update
184
+ nugetCLI = new Process
134
185
{
135
186
StartInfo = new ProcessStartInfo
136
187
{
137
188
FileName = Path . Combine ( rootDir , "Tools/nuget.exe" ) ,
138
189
Arguments = $ "update { path } \\ UnitsNet.nanoFramework.sln -PreRelease",
139
190
UseShellExecute = false ,
140
- CreateNoWindow = true
191
+ CreateNoWindow = true ,
192
+ RedirectStandardError = true
141
193
}
142
194
} ;
143
195
@@ -199,11 +251,18 @@ public static void UpdateNanoFrameworkDependencies(
199
251
{
200
252
Log . Information ( "" ) ;
201
253
Log . Information ( $ "nuget CLI executed with { nugetCLI . ExitCode } exit code") ;
254
+
255
+ Log . Information ( nugetCLI . StandardError . ReadToEnd ( ) ) ;
256
+
257
+ return false ;
202
258
}
203
259
}
260
+
204
261
}
205
262
206
263
Log . Information ( "" ) ;
264
+
265
+ return true ;
207
266
}
208
267
209
268
private static NanoFrameworkVersions ParseCurrentNanoFrameworkVersions ( string rootDir )
0 commit comments