6
6
#l "tools / versionUtils . cake "
7
7
#l "tools/settingsUtils.cake"
8
8
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.9.0"
9
- #addin "Cake.Incubator"
9
+ #addin "nuget:?package= Cake.Incubator&version=5.0.1 "
10
10
11
11
///////////////////////////////////////////////////////////////////////////////
12
12
// ARGUMENTS
@@ -161,12 +161,13 @@ Task("Build")
161
161
if ( ! string . IsNullOrEmpty ( versionInfo . ToVersionSuffix ( ) ) )
162
162
dotNetCoreBuildSettings . SetVersionSuffix ( versionInfo . ToVersionSuffix ( ) ) ;
163
163
if ( ! string . IsNullOrEmpty ( versionInfo . ToString ( ) ) )
164
- dotNetCoreBuildSettings . SetFileVersion ( versionInfo . ToString ( true ) ) ;
165
-
164
+ dotNetCoreBuildSettings . SetFileVersion ( versionInfo . ToString ( false ) ) ;
165
+
166
166
DotNetCoreBuild ( solution . ToString ( ) , new DotNetCoreBuildSettings
167
167
{
168
168
Configuration = settings . Configuration ,
169
- MSBuildSettings = dotNetCoreBuildSettings
169
+ MSBuildSettings = dotNetCoreBuildSettings ,
170
+ Verbosity = DotNetCoreVerbosity . Minimal
170
171
}
171
172
) ;
172
173
break ;
@@ -193,10 +194,54 @@ Task("UnitTest")
193
194
. WithCriteria ( settings . ExecuteUnitTest )
194
195
. IsDependentOn ( "Build" )
195
196
. Does ( ( ) =>
197
+ {
198
+ switch ( settings . Test . Framework )
199
+ {
200
+ case TestFrameworkTypes . DotNetCore :
201
+ RunTarget ( "UnitTest-DotNetCore" ) ;
202
+
203
+ break ;
204
+ default :
205
+ RunTarget ( "UnitTest-CLI" ) ;
206
+
207
+ break ;
208
+ }
209
+ } ) ;
210
+
211
+ Task ( "UnitTest-DotNetCore" )
212
+ . Description ( "Run dotnetcore based unit tests for the solution." )
213
+ . WithCriteria ( settings . ExecuteUnitTest )
214
+ . Does ( ( ) =>
196
215
{
197
216
// Run all unit tests we can find.
198
217
199
- var assemplyFilePath = string . Format ( "{0}/**/bin/{1}/{2}" , settings . Test . SourcePath , settings . Configuration , settings . Test . AssemblyFileSpec ) ;
218
+ var filePath = string . Format ( "{0}/**/{1}" , settings . Test . SourcePath , settings . Test . FileSpec ) ;
219
+
220
+ Information ( "Unit Test Files: {0}" , filePath ) ;
221
+
222
+ var testProjects = GetFiles ( filePath ) ;
223
+ var testSettings = new DotNetCoreTestSettings ( )
224
+ {
225
+ Configuration = settings . Configuration ,
226
+ NoBuild = true
227
+ } ;
228
+
229
+ foreach ( var p in testProjects )
230
+ {
231
+ Information ( "Executing Tests for {0}" , p ) ;
232
+
233
+ DotNetCoreTest ( p . ToString ( ) , testSettings ) ;
234
+ }
235
+ } ) ;
236
+
237
+ Task ( "UnitTest-CLI" )
238
+ . Description ( "Run unit tests for the solution." )
239
+ . WithCriteria ( settings . ExecuteUnitTest )
240
+ . Does ( ( ) =>
241
+ {
242
+ // Run all unit tests we can find.
243
+
244
+ var assemplyFilePath = string . Format ( "{0}/**/bin/{1}/**/{2}" , settings . Test . SourcePath , settings . Configuration , settings . Test . FileSpec ) ;
200
245
201
246
Information ( "Unit Test Files: {0}" , assemplyFilePath ) ;
202
247
@@ -286,28 +331,35 @@ Task("Nuget-Package-DotNetCore")
286
331
if ( ! string . IsNullOrEmpty ( versionInfo . ToString ( ) ) )
287
332
dotNetCoreBuildSettings . SetFileVersion ( versionInfo . ToString ( true ) ) ;
288
333
289
- var dncps = new DotNetCorePackSettings
290
- {
291
- Configuration = settings . Configuration ,
292
- OutputDirectory = artifactsPath ,
293
- IncludeSymbols = settings . NuGet . IncludeSymbols ,
294
- NoBuild = true ,
295
- NoRestore = true ,
296
- MSBuildSettings = dotNetCoreBuildSettings
297
- } ;
298
-
299
- Information ( "Location of Artifacts: {0}" , artifactsPath ) ;
300
-
301
- foreach ( var solution in solutions )
302
- {
334
+ var opts = new DotNetCorePackSettings
335
+ {
336
+ Configuration = settings . Configuration ,
337
+ OutputDirectory = artifactsPath ,
338
+ NoBuild = true ,
339
+ NoRestore = true ,
340
+ MSBuildSettings = dotNetCoreBuildSettings
341
+ } ;
342
+
343
+ if ( ! string . IsNullOrEmpty ( versionInfo . ToVersionSuffix ( ) ) )
344
+ opts . VersionSuffix = versionInfo . ToVersionSuffix ( ) ;
345
+
346
+ if ( settings . NuGet . IncludeSymbols ) {
347
+ opts . ArgumentCustomization = args => args . Append ( "--include-symbols -p:SymbolPackageFormat=snupkg" ) ;
348
+ }
349
+
350
+ Information ( "Location of Artifacts: {0}" , artifactsPath ) ;
351
+
352
+ foreach ( var solution in solutions )
353
+ {
303
354
Information ( "Building Packages for {0}" , solution ) ;
304
355
305
356
try {
306
- //DotNetCorePack("./src/**/*.csproj", dncps );
307
- DotNetCorePack ( solution . ToString ( ) , dncps ) ;
357
+ //DotNetCorePack("./src/**/*.csproj", opts );
358
+ DotNetCorePack ( solution . ToString ( ) , opts ) ;
308
359
}
309
360
catch ( Exception ex )
310
361
{
362
+ Debug ( ex . Message ) ;
311
363
Information ( "There was a problem with packing some of the projects in {0}" , solution ) ;
312
364
}
313
365
}
@@ -324,6 +376,19 @@ Task("Nuget-Package-CLI")
324
376
CreateDirectory ( artifactsPath ) ;
325
377
326
378
var nuspecFiles = GetFiles ( settings . NuGet . NuSpecFileSpec ) ;
379
+
380
+ var opts = new NuGetPackSettings {
381
+ Version = versionInfo . ToString ( ) ,
382
+ ReleaseNotes = versionInfo . ReleaseNotes ,
383
+ Properties = nugetProps ,
384
+ OutputDirectory = artifactsPath ,
385
+ Symbols = settings . NuGet . IncludeSymbols
386
+ } ;
387
+
388
+ //if (settings.NuGet.IncludeSymbols) {
389
+ // opts.ArgumentCustomization = args => args.Append("-Symbols -SymbolPackageFormat snupkg");
390
+ //}
391
+
327
392
foreach ( var nsf in nuspecFiles )
328
393
{
329
394
Information ( "Packaging {0}" , nsf ) ;
@@ -336,13 +401,7 @@ Task("Nuget-Package-CLI")
336
401
VersionUtils . UpdateNuSpecVersionDependency ( Context , settings , versionInfo , nsf . ToString ( ) ) ;
337
402
}
338
403
339
- NuGetPack ( nsf , new NuGetPackSettings {
340
- Version = versionInfo . ToString ( ) ,
341
- ReleaseNotes = versionInfo . ReleaseNotes ,
342
- Symbols = true ,
343
- Properties = nugetProps ,
344
- OutputDirectory = artifactsPath
345
- } ) ;
404
+ NuGetPack ( nsf , opts ) ;
346
405
}
347
406
} ) ;
348
407
@@ -355,23 +414,31 @@ Task("Nuget-Publish")
355
414
356
415
CreateDirectory ( artifactsPath ) ;
357
416
358
- if ( settings . NuGet . FeedApiKey . ToLower ( ) == "local" )
417
+ switch ( settings . NuGet . FeedApiKey . ToUpper ( ) )
359
418
{
360
- settings . NuGet . FeedUrl = Directory ( settings . NuGet . FeedUrl ) . Path . FullPath ;
361
- //Information("Using Local repository: {0}", settings.NuGet.FeedUrl);
419
+ case "LOCAL" :
420
+ settings . NuGet . FeedUrl = Directory ( settings . NuGet . FeedUrl ) . Path . FullPath ;
421
+ //Information("Using Local repository: {0}", settings.NuGet.FeedUrl);
422
+ break ;
423
+ case "NUGETAPIKEY" :
424
+ if ( ! System . IO . File . Exists ( "nugetapi.key" ) )
425
+ {
426
+ Error ( "Could not load nugetapi.key" ) ;
427
+ return ;
428
+ }
429
+
430
+ settings . NuGet . FeedApiKey = System . IO . File . ReadAllText ( "nugetapi.key" ) ;
431
+ break ;
432
+ case "AzureDevOps" :
433
+ case "VSTS" :
434
+ if ( BuildSystem . IsRunningOnAzurePipelinesHosted )
435
+ {
436
+ //settings.NuGet.FeedApiKey = EnvironmentVariable("SYSTEM_ACCESSTOKEN");
437
+ settings . NuGet . FeedApiKey = "AzureDevOps" ;
438
+ }
439
+ break ;
362
440
}
363
441
364
- if ( settings . NuGet . FeedApiKey == "NUGETAPIKEY" )
365
- {
366
- if ( ! System . IO . File . Exists ( "nugetapi.key" ) )
367
- {
368
- Error ( "Could not load nugetapi.key" ) ;
369
- return ;
370
- }
371
-
372
- settings . NuGet . FeedApiKey = System . IO . File . ReadAllText ( "nugetapi.key" ) ;
373
- }
374
-
375
442
if ( string . IsNullOrEmpty ( settings . NuGet . NuGetConfig ) ) settings . NuGet . NuGetConfig = null ;
376
443
377
444
switch ( settings . NuGet . BuildType )
@@ -401,18 +468,23 @@ Task("Nuget-Publish-DotNetCore")
401
468
402
469
Information ( "\t {0}" , string . Join ( "\n \t " , nupkgFiles . Select ( x => x . GetFilename ( ) . ToString ( ) ) . ToList ( ) ) ) ;
403
470
404
- var dncps = new DotNetCoreNuGetPushSettings
471
+ var opts = new DotNetCoreNuGetPushSettings
405
472
{
406
473
Source = settings . NuGet . FeedUrl ,
407
474
ApiKey = settings . NuGet . FeedApiKey
475
+ // ,Verbosity = DotNetCoreVerbosity.Detailed
408
476
} ;
409
-
477
+
478
+ //if (settings.NuGet.IncludeSymbols) {
479
+ // opts.ArgumentCustomization = args => args.Append("-Symbols -SymbolPackageFormat snupkg");
480
+ //}
481
+
410
482
foreach ( var n in nupkgFiles )
411
483
{
412
- // Information("Pushing Package: {0}", n);
484
+ Information ( "Pushing Package: {0}" , n ) ;
413
485
414
486
try {
415
- DotNetCoreNuGetPush ( n . ToString ( ) , dncps ) ;
487
+ DotNetCoreNuGetPush ( n . ToString ( ) , opts ) ;
416
488
}
417
489
catch ( Exception ex )
418
490
{
@@ -446,24 +518,24 @@ Task("Nuget-Publish-CLI")
446
518
447
519
Information ( "\t {0}" , string . Join ( "\n \t " , nupkgFiles . Select ( x => x . GetFilename ( ) . ToString ( ) ) . ToList ( ) ) ) ;
448
520
449
- if ( BuildSystem . IsRunningOnVSTS )
450
- {
451
- settings . NuGet . FeedApiKey = EnvironmentVariable ( "SYSTEM_ACCESSTOKEN" ) ;
452
- }
521
+ // if (BuildSystem.IsRunningOnAzurePipelinesHosted )
522
+ // {
523
+ // settings.NuGet.FeedApiKey = EnvironmentVariable("SYSTEM_ACCESSTOKEN");
524
+ // }
453
525
454
- var nugetSettings = new NuGetPushSettings {
526
+ var opts = new NuGetPushSettings {
455
527
Source = settings . NuGet . FeedUrl ,
456
528
ApiKey = settings . NuGet . FeedApiKey ,
457
529
Verbosity = NuGetVerbosity . Detailed
458
530
} ;
459
-
531
+
460
532
foreach ( var n in nupkgFiles )
461
533
{
462
534
Information ( "Pushing Package: {0}" , n ) ;
463
535
464
536
try
465
537
{
466
- NuGetPush ( n , nugetSettings ) ;
538
+ NuGetPush ( n , opts ) ;
467
539
}
468
540
catch ( Exception ex )
469
541
{
0 commit comments