@@ -224,6 +224,7 @@ public sealed class DotNetPackageBuildProcess
224
224
private readonly BuildProcess _buildProcess ;
225
225
private string ? _apiKey , _branch ;
226
226
private bool _stable , _noPush ;
227
+
227
228
private DotNetPackageBuildProcess ( DotNetBuildProcessOptions options )
228
229
{
229
230
_branch = options . BranchFunc ( ) ;
@@ -237,15 +238,17 @@ private DotNetPackageBuildProcess(DotNetBuildProcessOptions options)
237
238
// args
238
239
Console . WriteLine ( @"Executing command line:" ) ;
239
240
Console . WriteLine ( $@ " { Environment . CommandLine } ") ;
241
+ Console . WriteLine ( $ "Branch: { _branch } ")
240
242
} )
241
243
. WithTaskExecuting ( task => Console . WriteLine ( $@ "===== Task { task . Name } { task . Description } executing ======") )
242
244
. WithTaskExecuted ( task => Console . WriteLine ( $@ "===== Task { task . Name } { task . Description } executed ======") )
243
245
. WithTask ( "build" , b =>
244
246
{
245
- b . WithDescription ( "dotnet build" ) . WithExecution ( ( ) =>
246
- CommandExecutor . ExecuteCommandAndOutput ( $ "dotnet build { options . SolutionPath } ")
247
- . EnsureSuccessExitCode ( )
248
- ) ;
247
+ b . WithDescription ( "dotnet build" )
248
+ . WithExecution ( ( ) =>
249
+ CommandExecutor . ExecuteCommandAndOutput ( $ "dotnet build { options . SolutionPath } ")
250
+ . EnsureSuccessExitCode ( )
251
+ ) ;
249
252
} )
250
253
. WithTask ( "test" , b =>
251
254
{
@@ -266,7 +269,7 @@ private DotNetPackageBuildProcess(DotNetBuildProcessOptions options)
266
269
. WithDependency ( "test" )
267
270
. WithExecution ( ( ) =>
268
271
{
269
- if ( options . SrcProjects is not { Length : > 0 } )
272
+ if ( options . SrcProjects is not { Length : > 0 } )
270
273
return ;
271
274
272
275
if ( _stable )
@@ -275,8 +278,7 @@ private DotNetPackageBuildProcess(DotNetBuildProcessOptions options)
275
278
{
276
279
CommandExecutor . ExecuteCommandAndOutput (
277
280
$ "dotnet pack { project } -o { options . ArtifactsPath } "
278
- )
279
- . EnsureSuccessExitCode ( ) ;
281
+ ) . EnsureSuccessExitCode ( ) ;
280
282
}
281
283
}
282
284
else
@@ -295,11 +297,23 @@ private DotNetPackageBuildProcess(DotNetBuildProcessOptions options)
295
297
Console . WriteLine ( @"Skip push there's noPush specified" ) ;
296
298
return ;
297
299
}
298
-
299
- if ( ! _stable && _branch != "preview" && ( ! options . AllowLocalPush && _branch is " local") )
300
+
301
+ if ( _branch == " local")
300
302
{
301
- Console . WriteLine ( $@ "Skip push since branch [{ _branch } ] not supported to push packages") ;
302
- return ;
303
+ if ( ! options . AllowLocalPush )
304
+ {
305
+ Console . WriteLine ( $@ "Skip push since local branch is not allowed to push packages") ;
306
+ return ;
307
+ }
308
+ }
309
+ else
310
+ {
311
+ // check preview branch
312
+ if ( ! _stable && _branch is "preview" )
313
+ {
314
+ Console . WriteLine ( $@ "Skip push since branch [{ _branch } ] not supported to push packages") ;
315
+ return ;
316
+ }
303
317
}
304
318
305
319
if ( string . IsNullOrEmpty ( _apiKey ) )
@@ -341,6 +355,11 @@ public async Task ExecuteAsync(string[] args, CancellationToken cancellation = d
341
355
_stable = _branch is "main" or "master" ||
342
356
_branch ? . StartsWith ( "release/" , StringComparison . OrdinalIgnoreCase ) == true ;
343
357
}
358
+ else
359
+ {
360
+ // only specify `stable` locally
361
+ _stable = _branch == "local" ;
362
+ }
344
363
var target = CommandLineParser . Val ( args , "target" , "Default" ) ;
345
364
await _buildProcess . ExecuteAsync ( target , cancellation ) ;
346
365
}
0 commit comments