Skip to content

Commit a9c514d

Browse files
committed
Merge pull request #45 from gep13/release/0.1.0
Release/0.1.0
2 parents 19a3e23 + 9d98fa2 commit a9c514d

File tree

71 files changed

+2336
-1774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2336
-1774
lines changed

BuildScripts/build.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ if($Help){
2323
return
2424
}
2525

26-
if(Test-Path -Path env:\APPVEYOR) {
27-
if($env:APPVEYOR_REPO_BRANCH -eq "develop" -And $env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null) {
26+
if(Test-Path -Path env:\APPVEYOR) {
27+
if ($env:APPVEYOR_SCHEDULED_BUILD -eq "True") {
28+
Write-Output "Since this is a scheduled build, simply run a build, with deployment of Coverity Artifacts, but no other deployment"
29+
invoke-psake "$here/default.ps1" -task RebuildSolution -properties @{ 'config'='Release'; }
30+
} elseif($env:APPVEYOR_REPO_BRANCH -eq "develop" -And $env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null) {
2831
Write-Output "Since we are on develop branch with no pull request number, we are ready to deploy to Develop MyGet Feed"
2932
invoke-psake "$here/default.ps1" -task DeployDevelopSolutionToMyGet -properties @{ 'config'='Release'; }
3033
} elseif($env:APPVEYOR_REPO_BRANCH -eq "develop" -And $env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null) {

BuildScripts/default.ps1

Lines changed: 126 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ $psake.use_exit_on_error = $true
77
properties {
88
$config = 'Debug';
99
$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";
1116
}
1217

1318
$private = "This is a private task not meant for external use!";
@@ -227,7 +232,9 @@ Task -Name __EchoAppVeyorEnvironmentVariables -Description $private -Action {
227232
testEnvironmentVariable "APPVEYOR_REPO_COMMIT" $env:APPVEYOR_REPO_COMMIT;
228233
testEnvironmentVariable "APPVEYOR_REPO_COMMIT_AUTHOR" $env:APPVEYOR_REPO_COMMIT_AUTHOR;
229234
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;
231238
testEnvironmentVariable "PLATFORM" $env:PLATFORM;
232239
testEnvironmentVariable "CONFIGURATION" $env:CONFIGURATION;
233240
}
@@ -249,10 +256,15 @@ Task -Name __InstallChocolatey -Description $private -Action {
249256
if(isChocolateyInstalled) {
250257
Write-Output "Chocolatey already installed";
251258
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+
}
253265

254266
exec {
255-
Invoke-Expression "$choco upgrade chocolatey";
267+
Invoke-Expression "$script:chocolateyCommand upgrade chocolatey -y";
256268
}
257269

258270
Write-Output "Latest Chocolatey installed."
@@ -281,14 +293,13 @@ Task -Name __InstallChocolatey -Description $private -Action {
281293
Task -Name __InstallReSharperCommandLineTools -Depends __InstallChocolatey -Description $private -Action {
282294
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
283295
$inspectCodeExe = Join-Path $chocolateyBinDir -ChildPath "inspectcode.exe";
284-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
285296

286297
try {
287298
Write-Output "Running Install Command Line Tools..."
288299

289300
if (-not (Test-Path $inspectCodeExe)) {
290301
exec {
291-
Invoke-Expression "$choco install resharper-clt -y";
302+
Invoke-Expression "$script:chocolateyCommand install resharper-clt -y";
292303
}
293304
} else {
294305
Write-Output "resharper-clt already installed";
@@ -303,13 +314,11 @@ Task -Name __InstallReSharperCommandLineTools -Depends __InstallChocolatey -Desc
303314
}
304315

305316
Task -Name __UpdateReSharperCommandLineTools -Description $private -Action {
306-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
307-
308317
try {
309318
Write-Output "Running Upgrade Command Line Tools..."
310319

311320
exec {
312-
Invoke-Expression "$choco upgrade resharper-clt";
321+
Invoke-Expression "$script:chocolateyCommand upgrade resharper-clt -y";
313322
}
314323

315324
Write-Output ("************ Upgrade Command Line Tools Successful ************")
@@ -324,13 +333,14 @@ Task -Name __InstallPSBuild -Description $private -Action {
324333
try {
325334
Write-Output "Running Install PSBuild..."
326335

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";
330340
(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+
# }
334344
}
335345

336346
Write-Output ("************ Install PSBuild Successful ************")
@@ -344,14 +354,13 @@ Task -Name __InstallPSBuild -Description $private -Action {
344354
Task -Name __InstallGitVersion -Depends __InstallChocolatey -Description $private -Action {
345355
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
346356
$gitVersionExe = Join-Path $chocolateyBinDir -ChildPath "GitVersion.exe";
347-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
348357

349358
try {
350359
Write-Output "Running Install GitVersion.Portable..."
351360

352361
if (-not (Test-Path $gitVersionExe)) {
353362
exec {
354-
Invoke-Expression "$choco install GitVersion.Portable -pre -y";
363+
Invoke-Expression "$script:chocolateyCommand install GitVersion.Portable -pre -y";
355364
}
356365
} else {
357366
Write-Output "GitVersion.Portable already installed";
@@ -366,13 +375,11 @@ Task -Name __InstallGitVersion -Depends __InstallChocolatey -Description $privat
366375
}
367376

368377
Task -Name __UpdateGitVersion -Description $private -Action {
369-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
370-
371378
try {
372379
Write-Output "Running Upgrade GitVersion.Portable..."
373380

374381
exec {
375-
Invoke-Expression "$choco upgrade GitVersion.Portable";
382+
Invoke-Expression "$script:chocolateyCommand upgrade GitVersion.Portable -y";
376383
}
377384

378385
Write-Output ("************ Upgrade GitVersion.Portable Successful ************")
@@ -393,7 +400,7 @@ Task -Name DeployDevelopSolutionToMyGet -Depends InspectCodeForProblems, DeployD
393400

394401
Task -Name DeployMasterSolutionToMyGet -Depends InspectCodeForProblems, DeployMasterPackageToMyGet -Description "Complete build, including creation of Chocolatey Package and Deployment to MyGet.org"
395402

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."
397404

398405
# build tasks
399406

@@ -448,7 +455,10 @@ Task -Name RunInspectCode -Depends __InstallReSharperCommandLineTools -Descripti
448455
if(Test-Path $inspectCodeXmlFile) {
449456
applyXslTransform $inspectCodeXmlFile $inspectCodeXslFile $inspectCodeHtmlFile;
450457
$inspectCodeXmlFile | analyseInspectCodeResults;
451-
}
458+
}
459+
460+
# Reset the inspectcode.config file
461+
git checkout $inspectCodeConfigFile;
452462
}
453463
}
454464

@@ -472,7 +482,10 @@ Task -Name RunDupFinder -Depends __InstallReSharperCommandLineTools -Description
472482
if(Test-Path $dupFinderXmlFile) {
473483
applyXslTransform $dupFinderXmlFile $dupFinderXslFile $dupFinderHtmlFile;
474484
$dupFinderXmlFile | analyseDupFinderResults;
475-
}
485+
}
486+
487+
# Reset the dupfinder.config file
488+
git checkout $dupFinderConfigFile;
476489
}
477490
}
478491

@@ -521,8 +534,24 @@ Task -Name BuildSolution -Depends __RemoveBuildArtifactsDirectory, __VerifyConfi
521534
try {
522535
Write-Output "Running BuildSolution..."
523536

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+
}
526555

527556
$styleCopResultsFiles = Get-ChildItem $buildArtifactsDirectory -Filter "StyleCop*.xml"
528557
foreach ($styleCopResultsFile in $styleCopResultsFiles) {
@@ -541,9 +570,9 @@ Task -Name BuildSolution -Depends __RemoveBuildArtifactsDirectory, __VerifyConfi
541570
}
542571

543572
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;
547576
}
548577
}
549578
}
@@ -555,8 +584,37 @@ Task -Name BuildSolution -Depends __RemoveBuildArtifactsDirectory, __VerifyConfi
555584
Write-Output ("************ BuildSolution Failed ************")
556585
}
557586
}
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"
560618

561619
# clean tasks
562620

@@ -588,14 +646,16 @@ Task -Name PackageChocolatey -Description "Packs the module and example package"
588646
Write-Output "Running PackageChocolatey..."
589647

590648
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
592650
.$nugetExe pack "$sourceDirectory\..\Packaging\nuget\GitHubReleaseManager.nuspec" -OutputDirectory "$buildArtifactsDirectory" -NoPackageAnalysis -version $script:version
593651

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+
}
599659
}
600660
}
601661

@@ -613,8 +673,13 @@ Task -Name DeployDevelopPackageToMyGet -Description "Takes the packaged Chocolat
613673
try {
614674
Write-Output "Deploying to MyGet..."
615675

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+
}
618683
}
619684

620685
Write-Output ("************ MyGet Deployment Successful ************")
@@ -631,8 +696,13 @@ Task -Name DeployMasterPackageToMyGet -Description "Takes the packaged Chocolate
631696
try {
632697
Write-Output "Deploying to MyGet..."
633698

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+
}
636706
}
637707

638708
Write-Output ("************ MyGet Deployment Successful ************")
@@ -643,20 +713,29 @@ Task -Name DeployMasterPackageToMyGet -Description "Takes the packaged Chocolate
643713
}
644714
}
645715

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 {
647717
$buildArtifactsDirectory = get-buildArtifactsDirectory;
648718

649719
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+
}
654733
}
655734

656-
Write-Output ("************ Chocolatey Deployment Successful ************")
735+
Write-Output ("************ Chocolatey and Nuget Deployment Successful ************")
657736
}
658737
catch {
659738
Write-Error $_
660-
Write-Output ("************ Chocolatey Deployment Failed ************")
739+
Write-Output ("************ Chocolatey and Nuget Deployment Failed ************")
661740
}
662741
}

0 commit comments

Comments
 (0)