@@ -7,7 +7,12 @@ $psake.use_exit_on_error = $true
7
7
properties {
8
8
$config = ' Debug' ;
9
9
$nugetExe = " ..\Tools\NuGet\NuGet.exe" ;
10
- $projectName = " GitHubReleaseManager" ;
10
+ $projectName = " GitHubReleaseManager" ;
11
+ $openCoverExe = " ..\Source\packages\OpenCover.4.5.3723\OpenCover.Console.exe" ;
12
+ $nunitConsoleExe = " ..\Source\packages\NUnit.Runners.2.6.4\tools\nunit-console.exe" ;
13
+ $reportGeneratorExe = " ..\Source\packages\ReportGenerator.2.1.3.0\ReportGenerator.exe" ;
14
+ $coverallsExe = " ..\Source\packages\coveralls.io.1.2.2\tools\coveralls.net.exe" ;
15
+ $publishCoverityExe = " ..\Source\packages\PublishCoverity.0.9.0\PublishCoverity.exe" ;
11
16
}
12
17
13
18
$private = " This is a private task not meant for external use!" ;
@@ -227,7 +232,9 @@ Task -Name __EchoAppVeyorEnvironmentVariables -Description $private -Action {
227
232
testEnvironmentVariable " APPVEYOR_REPO_COMMIT" $env: APPVEYOR_REPO_COMMIT ;
228
233
testEnvironmentVariable " APPVEYOR_REPO_COMMIT_AUTHOR" $env: APPVEYOR_REPO_COMMIT_AUTHOR ;
229
234
testEnvironmentVariable " APPVEYOR_REPO_COMMIT_TIMESTAMP" $env: APPVEYOR_REPO_COMMIT_TIMESTAMP ;
230
- testEnvironmentVariable " APPVEYOR_SCHEDULED_BUILD" $env: APPVEYOR_SCHEDULED_BUILD ;
235
+ testEnvironmentVariable " APPVEYOR_SCHEDULED_BUILD" $env: APPVEYOR_SCHEDULED_BUILD ;
236
+ testEnvironmentVariable " APPVEYOR_FORCED_BUILD" $env: APPVEYOR_FORCED_BUILD ;
237
+ testEnvironmentVariable " APPVEYOR_RE_BUILD" $env: APPVEYOR_RE_BUILD ;
231
238
testEnvironmentVariable " PLATFORM" $env: PLATFORM ;
232
239
testEnvironmentVariable " CONFIGURATION" $env: CONFIGURATION ;
233
240
}
@@ -249,10 +256,15 @@ Task -Name __InstallChocolatey -Description $private -Action {
249
256
if (isChocolateyInstalled) {
250
257
Write-Output " Chocolatey already installed" ;
251
258
Write-Output " Updating to latest Chocolatey..."
252
- $choco = Join-Path $script :chocolateyDir - ChildPath " choco.exe" ;
259
+
260
+ if (Test-Path - Path (Join-Path - Path $script :chocolateyDir - ChildPath " choco.exe" )) {
261
+ $script :chocolateyCommand = Join-Path $script :chocolateyDir - ChildPath " choco.exe"
262
+ } else {
263
+ $script :chocolateyCommand = Join-Path (Join-Path $script :chocolateyDir " chocolateyInstall" ) - ChildPath " chocolatey.cmd" ;
264
+ }
253
265
254
266
exec {
255
- Invoke-Expression " $choco upgrade chocolatey" ;
267
+ Invoke-Expression " $script :chocolateyCommand upgrade chocolatey -y " ;
256
268
}
257
269
258
270
Write-Output " Latest Chocolatey installed."
@@ -281,14 +293,13 @@ Task -Name __InstallChocolatey -Description $private -Action {
281
293
Task - Name __InstallReSharperCommandLineTools - Depends __InstallChocolatey - Description $private - Action {
282
294
$chocolateyBinDir = Join-Path $script :chocolateyDir - ChildPath " bin" ;
283
295
$inspectCodeExe = Join-Path $chocolateyBinDir - ChildPath " inspectcode.exe" ;
284
- $choco = Join-Path $script :chocolateyDir - ChildPath " choco.exe" ;
285
296
286
297
try {
287
298
Write-Output " Running Install Command Line Tools..."
288
299
289
300
if (-not (Test-Path $inspectCodeExe )) {
290
301
exec {
291
- Invoke-Expression " $choco install resharper-clt -y" ;
302
+ Invoke-Expression " $script :chocolateyCommand install resharper-clt -y" ;
292
303
}
293
304
} else {
294
305
Write-Output " resharper-clt already installed" ;
@@ -303,13 +314,11 @@ Task -Name __InstallReSharperCommandLineTools -Depends __InstallChocolatey -Desc
303
314
}
304
315
305
316
Task - Name __UpdateReSharperCommandLineTools - Description $private - Action {
306
- $choco = Join-Path $script :chocolateyDir - ChildPath " choco.exe" ;
307
-
308
317
try {
309
318
Write-Output " Running Upgrade Command Line Tools..."
310
319
311
320
exec {
312
- Invoke-Expression " $choco upgrade resharper-clt" ;
321
+ Invoke-Expression " $script :chocolateyCommand upgrade resharper-clt -y " ;
313
322
}
314
323
315
324
Write-Output (" ************ Upgrade Command Line Tools Successful ************" )
@@ -324,13 +333,14 @@ Task -Name __InstallPSBuild -Description $private -Action {
324
333
try {
325
334
Write-Output " Running Install PSBuild..."
326
335
327
- exec {
328
- if (-not (test-CommandExists Invoke-MSBuild )) {
329
- Write-Output " PSBuild is not already installed" ;
336
+ exec {
337
+ # This test works locally, but not on AppVeyor
338
+ # if (-not (test-CommandExists Invoke-MSBuild)) {
339
+ # Write-Output "PSBuild is not already installed";
330
340
(new-object Net.WebClient).DownloadString(" https://raw.github.com/ligershark/psbuild/master/src/GetPSBuild.ps1" ) | Invoke-Expression ;
331
- } else {
332
- Write-Output " PSBuild is already installed" ;
333
- }
341
+ # } else {
342
+ # Write-Output "PSBuild is already installed";
343
+ # }
334
344
}
335
345
336
346
Write-Output (" ************ Install PSBuild Successful ************" )
@@ -344,14 +354,13 @@ Task -Name __InstallPSBuild -Description $private -Action {
344
354
Task - Name __InstallGitVersion - Depends __InstallChocolatey - Description $private - Action {
345
355
$chocolateyBinDir = Join-Path $script :chocolateyDir - ChildPath " bin" ;
346
356
$gitVersionExe = Join-Path $chocolateyBinDir - ChildPath " GitVersion.exe" ;
347
- $choco = Join-Path $script :chocolateyDir - ChildPath " choco.exe" ;
348
357
349
358
try {
350
359
Write-Output " Running Install GitVersion.Portable..."
351
360
352
361
if (-not (Test-Path $gitVersionExe )) {
353
362
exec {
354
- Invoke-Expression " $choco install GitVersion.Portable -pre -y" ;
363
+ Invoke-Expression " $script :chocolateyCommand install GitVersion.Portable -pre -y" ;
355
364
}
356
365
} else {
357
366
Write-Output " GitVersion.Portable already installed" ;
@@ -366,13 +375,11 @@ Task -Name __InstallGitVersion -Depends __InstallChocolatey -Description $privat
366
375
}
367
376
368
377
Task - Name __UpdateGitVersion - Description $private - Action {
369
- $choco = Join-Path $script :chocolateyDir - ChildPath " choco.exe" ;
370
-
371
378
try {
372
379
Write-Output " Running Upgrade GitVersion.Portable..."
373
380
374
381
exec {
375
- Invoke-Expression " $choco upgrade GitVersion.Portable" ;
382
+ Invoke-Expression " $script :chocolateyCommand upgrade GitVersion.Portable -y " ;
376
383
}
377
384
378
385
Write-Output (" ************ Upgrade GitVersion.Portable Successful ************" )
@@ -393,7 +400,7 @@ Task -Name DeployDevelopSolutionToMyGet -Depends InspectCodeForProblems, DeployD
393
400
394
401
Task - Name DeployMasterSolutionToMyGet - Depends InspectCodeForProblems, DeployMasterPackageToMyGet - Description " Complete build, including creation of Chocolatey Package and Deployment to MyGet.org"
395
402
396
- Task - Name DeploySolutionToChocolatey - Depends InspectCodeForProblems, DeployPackageToChocolatey - Description " Complete build, including creation of Chocolatey Package and Deployment to Chocolatey.org."
403
+ Task - Name DeploySolutionToChocolatey - Depends InspectCodeForProblems, DeployPackageToChocolateyAndNuget - Description " Complete build, including creation of Chocolatey Package and Deployment to Chocolatey.org."
397
404
398
405
# build tasks
399
406
@@ -448,7 +455,10 @@ Task -Name RunInspectCode -Depends __InstallReSharperCommandLineTools -Descripti
448
455
if (Test-Path $inspectCodeXmlFile ) {
449
456
applyXslTransform $inspectCodeXmlFile $inspectCodeXslFile $inspectCodeHtmlFile ;
450
457
$inspectCodeXmlFile | analyseInspectCodeResults;
451
- }
458
+ }
459
+
460
+ # Reset the inspectcode.config file
461
+ git checkout $inspectCodeConfigFile ;
452
462
}
453
463
}
454
464
@@ -472,7 +482,10 @@ Task -Name RunDupFinder -Depends __InstallReSharperCommandLineTools -Description
472
482
if (Test-Path $dupFinderXmlFile ) {
473
483
applyXslTransform $dupFinderXmlFile $dupFinderXslFile $dupFinderHtmlFile ;
474
484
$dupFinderXmlFile | analyseDupFinderResults;
475
- }
485
+ }
486
+
487
+ # Reset the dupfinder.config file
488
+ git checkout $dupFinderConfigFile ;
476
489
}
477
490
}
478
491
@@ -521,8 +534,24 @@ Task -Name BuildSolution -Depends __RemoveBuildArtifactsDirectory, __VerifyConfi
521
534
try {
522
535
Write-Output " Running BuildSolution..."
523
536
524
- exec {
525
- Invoke-MSBuild " $sourceDirectory \GitHubReleaseManager.sln" - NoLogo - Configuration $config - Targets Build - DetailedSummary - VisualStudioVersion 12.0 - Properties (@ {' Platform' = ' Any CPU' })
537
+ exec {
538
+ if ($env: APPVEYOR_SCHEDULED_BUILD -ne " True" ) {
539
+ Invoke-MSBuild " $sourceDirectory \GitHubReleaseManager.sln" - NoLogo - Configuration $config - Targets Build - DetailedSummary - VisualStudioVersion 12.0 - Properties (@ {' Platform' = ' Any CPU' })
540
+ } else {
541
+ $buildCmd = " C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" ;
542
+ $buildArgs = @ (
543
+ " $sourceDirectory \GitHubReleaseManager.sln"
544
+ " /l:C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" ,
545
+ " /m" ,
546
+ " /p:Configuration=$config " ,
547
+ " /p:Platform=Any CPU" );
548
+
549
+ & cov- build -- dir $buildArtifactsDirectory \cov- int $buildCmd $buildArgs ;
550
+
551
+ & $publishCoverityExe compress - o $buildArtifactsDirectory \coverity.zip - i $buildArtifactsDirectory \cov- int;
552
+
553
+ & $publishCoverityExe publish - z $buildArtifactsDirectory \coverity.zip - r GitHubReleaseManager - t $env: CoverityProjectToken - e $env: CoverityEmailDistribution - d " AppVeyor scheduled build." -- codeVersion $script :version ;
554
+ }
526
555
527
556
$styleCopResultsFiles = Get-ChildItem $buildArtifactsDirectory - Filter " StyleCop*.xml"
528
557
foreach ($styleCopResultsFile in $styleCopResultsFiles ) {
@@ -541,9 +570,9 @@ Task -Name BuildSolution -Depends __RemoveBuildArtifactsDirectory, __VerifyConfi
541
570
}
542
571
543
572
if (isAppVeyor) {
544
- $expectedMsiFile = Join-Path - Path $buildArtifactsDirectory - ChildPath " GitHubReleaseManager.exe"
545
- if (Test-Path $expectedMsiFile ) {
546
- Push-AppveyorArtifact $expectedMsiFile ;
573
+ $expectedExeFile = Join-Path - Path $buildArtifactsDirectory - ChildPath " GitHubReleaseManager.Cli .exe"
574
+ if (Test-Path $expectedExeFile ) {
575
+ Push-AppveyorArtifact $expectedExeFile ;
547
576
}
548
577
}
549
578
}
@@ -555,8 +584,37 @@ Task -Name BuildSolution -Depends __RemoveBuildArtifactsDirectory, __VerifyConfi
555
584
Write-Output (" ************ BuildSolution Failed ************" )
556
585
}
557
586
}
558
-
559
- Task - Name RebuildSolution - Depends CleanSolution, __CreateBuildArtifactsDirectory, BuildSolution - Description " Rebuilds the main solution for the package"
587
+
588
+ Task - Name RunCodeCoverage - Description " Use OpenCover, NUnit and Coveralls to analyze all code files and produce a report" - Action {
589
+ $buildArtifactsDirectory = get-buildArtifactsDirectory ;
590
+
591
+ try {
592
+ Write-Output " Running RunCodeCoverage..." ;
593
+
594
+ exec {
595
+ Write-Output " Running OpenCover..." ;
596
+ & $openCoverExe - target:$nunitConsoleExe - targetargs:`" $buildArtifactsDirectory \GitHubReleaseManager.Tests.dll / noshadow / nologo`" - filter:`" + [GitHubReleaseManager ]GitHubReleaseManager* `" - excludebyattribute:`" System.CodeDom.Compiler.GeneratedCodeAttribute`" - register:user - output:`" $buildArtifactsDirectory \coverage.xml`" ;
597
+ Write-Output " OpenCover Complete" ;
598
+
599
+ Write-Output " Running ReportGenerator..." ;
600
+ & $reportGeneratorExe - reports:$buildArtifactsDirectory \coverage.xml - targetdir:$buildArtifactsDirectory \_CodeCoverageReport;
601
+ Write-Output " ReportGenerator Complete" ;
602
+
603
+ if (isAppVeyor) {
604
+ Write-Output " Running Coveralls..." ;
605
+ & $coverallsExe -- opencover $buildArtifactsDirectory \coverage.xml
606
+ Write-Output " Coveralls Complete" ;
607
+ }
608
+ }
609
+
610
+ Write-Output (" ************ RunCodeCoverage Successful ************" );
611
+ } catch {
612
+ Write-Error $_
613
+ Write-Output (" ************ RunCodeCoverage Failed ************" )
614
+ }
615
+ }
616
+
617
+ Task - Name RebuildSolution - Depends CleanSolution, __CreateBuildArtifactsDirectory, BuildSolution, RunCodeCoverage - Description " Rebuilds the main solution for the package"
560
618
561
619
# clean tasks
562
620
@@ -588,14 +646,16 @@ Task -Name PackageChocolatey -Description "Packs the module and example package"
588
646
Write-Output " Running PackageChocolatey..."
589
647
590
648
exec {
591
- .$nugetExe pack " $sourceDirectory \..\Packaging\nuget\GitHubReleaseManager.Cli .nuspec" - OutputDirectory " $buildArtifactsDirectory " - NoPackageAnalysis - version $script :version
649
+ .$nugetExe pack " $sourceDirectory \..\Packaging\nuget\GitHubReleaseManager.Portable .nuspec" - OutputDirectory " $buildArtifactsDirectory " - NoPackageAnalysis - version $script :version
592
650
.$nugetExe pack " $sourceDirectory \..\Packaging\nuget\GitHubReleaseManager.nuspec" - OutputDirectory " $buildArtifactsDirectory " - NoPackageAnalysis - version $script :version
593
651
594
- if (isAppVeyor) {
595
- $expectedNupkgFile = Join-Path - Path $buildArtifactsDirectory - ChildPath " GitHubReleaseManager*.nupkg"
596
- if (Test-Path $expectedNupkgFile ) {
597
- Push-AppveyorArtifact ($expectedNupkgFile | Resolve-Path ).Path;
598
- }
652
+ if (isAppVeyor) {
653
+ Get-ChildItem $buildArtifactsDirectory - Filter * .nupkg | Foreach-Object {
654
+ $nugetPath = ($_ | Resolve-Path ).Path;
655
+ $convertedPath = Convert-Path $nugetPath ;
656
+
657
+ Push-AppveyorArtifact (Convert-Path $convertedPath );
658
+ }
599
659
}
600
660
}
601
661
@@ -613,8 +673,13 @@ Task -Name DeployDevelopPackageToMyGet -Description "Takes the packaged Chocolat
613
673
try {
614
674
Write-Output " Deploying to MyGet..."
615
675
616
- exec {
617
- & $nugetExe push " $buildArtifactsDirectory \*.nupkg" $env: MyGetDevelopApiKey - source $env: MyGetDevelopFeedUrl
676
+ exec {
677
+ Get-ChildItem $buildArtifactsDirectory - Filter * .nupkg | Foreach-Object {
678
+ $nugetPath = ($_ | Resolve-Path ).Path;
679
+ $convertedPath = Convert-Path $nugetPath ;
680
+
681
+ & $nugetExe push $convertedPath $env: MyGetDevelopApiKey - source $env: MyGetDevelopFeedUrl
682
+ }
618
683
}
619
684
620
685
Write-Output (" ************ MyGet Deployment Successful ************" )
@@ -631,8 +696,13 @@ Task -Name DeployMasterPackageToMyGet -Description "Takes the packaged Chocolate
631
696
try {
632
697
Write-Output " Deploying to MyGet..."
633
698
634
- exec {
635
- & $nugetExe push " $buildArtifactsDirectory \*.nupkg" $env: MyGetMasterApiKey - source $env: MyGetMasterFeedUrl
699
+ exec {
700
+ Get-ChildItem $buildArtifactsDirectory - Filter * .nupkg | Foreach-Object {
701
+ $nugetPath = ($_ | Resolve-Path ).Path;
702
+ $convertedPath = Convert-Path $nugetPath ;
703
+
704
+ & $nugetExe push $convertedPath $env: MyGetMasterApiKey - source $env: MyGetMasterFeedUrl
705
+ }
636
706
}
637
707
638
708
Write-Output (" ************ MyGet Deployment Successful ************" )
@@ -643,20 +713,29 @@ Task -Name DeployMasterPackageToMyGet -Description "Takes the packaged Chocolate
643
713
}
644
714
}
645
715
646
- Task - Name DeployPackageToChocolatey - Description " Takes the packaged Chocolatey package and deploys to Chocolatey.org" - Action {
716
+ Task - Name DeployPackageToChocolateyAndNuget - Description " Takes the packages and deploys to Chocolatey.org and nuget .org" - Action {
647
717
$buildArtifactsDirectory = get-buildArtifactsDirectory ;
648
718
649
719
try {
650
- Write-Output " Deploying to Chocolatey..."
651
-
652
- exec {
653
- & $nugetExe push " $buildArtifactsDirectory \*.nupkg" $env: ChocolateyApiKey - source $env: ChocolateyFeedUrl
720
+ Write-Output " Deploying to Chocolatey and Nuget..."
721
+
722
+ exec {
723
+ Get-ChildItem $buildArtifactsDirectory - Filter * .nupkg | Foreach-Object {
724
+ $nugetPath = ($_ | Resolve-Path ).Path;
725
+ $convertedPath = Convert-Path $nugetPath ;
726
+
727
+ if (& _ -like ' *cli*' ) {
728
+ & $nugetExe push $convertedPath $env: ChocolateyApiKey - source $env: ChocolateyFeedUrl
729
+ } else {
730
+ & $nugetExe push $convertedPath $env: NugetApiKey - source $env: NugetFeedUrl
731
+ }
732
+ }
654
733
}
655
734
656
- Write-Output (" ************ Chocolatey Deployment Successful ************" )
735
+ Write-Output (" ************ Chocolatey and Nuget Deployment Successful ************" )
657
736
}
658
737
catch {
659
738
Write-Error $_
660
- Write-Output (" ************ Chocolatey Deployment Failed ************" )
739
+ Write-Output (" ************ Chocolatey and Nuget Deployment Failed ************" )
661
740
}
662
741
}
0 commit comments