From 9083e1a7be35cdc6199f98efb049d897f9de34d2 Mon Sep 17 00:00:00 2001 From: Luk Vermeulen Date: Thu, 8 Feb 2018 06:19:45 +0100 Subject: [PATCH] fix build script --- appveyor.yml | 5 +- build/build.ps1 | 36 +++++++------- build/cover.ps1 | 110 +++++++++++++++++++++---------------------- build/coverlocal.ps1 | 68 ++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 75 deletions(-) create mode 100644 build/coverlocal.ps1 diff --git a/appveyor.yml b/appveyor.yml index 14f70a8..e203ffa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ branches: - master pull_requests: do_not_increment_build_number: true +image: Visual Studio 2017 environment: COVERALLS_REPO_TOKEN: secure: kDcf0mhCCCONpQVpeaA6M5qIuuLggG7lfv1tCMiZCzUmdjtmoIcwFaRQRf00bIdn @@ -15,10 +16,10 @@ test_script: if ($true) { .\build\test.ps1 - .\build\cover.ps1 "$env:COVERALLS_REPO_TOKEN" "$env:COVER_FILTER" + #.\build\cover.ps1 "$env:COVERALLS_REPO_TOKEN" "$env:COVER_FILTER" } artifacts: -- path: '**\*.nupkg' +- path: '.\artifacts\*.nupkg' deploy: - provider: NuGet api_key: diff --git a/build/build.ps1 b/build/build.ps1 index af8195f..12c945c 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -1,25 +1,25 @@ param ( - [string]$BuildVersionNumber=$(throw "-BuildVersionNumber is required."), - [string]$TagVersionNumber + [string]$BuildVersionNumber=$(throw "-BuildVersionNumber is required."), + [string]$TagVersionNumber ) -# set version number in package.json -Get-ChildItem -Path $PSScriptRoot\..\src -Filter *.csproj -Recurse | ForEach-Object{ - $ProjectPath = $_.FullName - if ($TagVersionNumber){ - (gc -Path $ProjectPath) ` - -replace "(?<=`"version`":\s`")[.\w-]*(?=`",)", "$TagVersionNumber" | - sc -Path $ProjectPath -Encoding UTF8 +& dotnet restore --no-cache + +foreach ($src in ls $PSScriptRoot\..\src/*) { + Push-Location $src + + Write-Output "build: Building & packaging project in $src" + + if ($TagVersionNumber -ne $null) { + $version = $TagVersionNumber } - else{ - (gc -Path $ProjectPath) ` - -replace "(?<=`"version`":\s`")[.\w-]*(?=`",)", "$BuildVersionNumber" | - sc -Path $ProjectPath -Encoding UTF8 + else { + $version = $BuildVersionNumber } -} -# run restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools -Get-ChildItem -Path $PSScriptRoot\..\src -Filter *.csproj -Recurse | ForEach-Object { & dotnet restore $_.FullName 2>1 } + & dotnet build -c Release + & dotnet pack -c Release --include-symbols -o ..\..\artifacts --no-build /p:PackageVersion=$version + if($LASTEXITCODE -ne 0) { exit 1 } -# run pack on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools -Get-ChildItem -Path $PSScriptRoot\..\src -Filter *.csproj -Recurse | ForEach-Object { & dotnet pack $_.FullName -c Release 2>1 } + Pop-Location +} diff --git a/build/cover.ps1 b/build/cover.ps1 index 41daeab..500eeb1 100644 --- a/build/cover.ps1 +++ b/build/cover.ps1 @@ -1,70 +1,70 @@ -param ( - [string]$CoverallsRepoToken=$(throw "-CoverallsRepoToken is required."), - [string]$CoverFilter=$(throw "-CoverFilter is required.") -) +#param ( +# [string]$CoverallsRepoToken=$(throw "-CoverallsRepoToken is required."), +# [string]$CoverFilter=$(throw "-CoverFilter is required.") +#) -Write-Output "Starting code coverage with filter: $CoverFilter" +#Write-Output "Starting code coverage with filter: $CoverFilter" -$alwaysFilter = "-[xunit*]* -[Microsoft*]* -[dotnet*]* -[NuGet*]* -[Newtonsoft*]* -[Consul*]* -[Nancy*]* -[AngleSharp]* -[csc]* -[Anonymously*]*" -$filter = "$CoverFilter $alwaysFilter" +#$alwaysFilter = "-[xunit*]* -[Microsoft*]* -[dotnet*]* -[NuGet*]* -[Newtonsoft*]* -[Consul*]* -[Nancy*]* -[AngleSharp]* -[csc]* -[Anonymously*]*" +#$filter = "$CoverFilter $alwaysFilter" -$packagesPath = $env:USERPROFILE + "\.nuget\packages" -$opencoverPath = $packagesPath + "\OpenCover\4.6.519\tools\OpenCover.Console.exe" -$coverallsPath = $packagesPath + "\coveralls.io\1.3.4\tools\coveralls.net.exe" -$tempPath = "c:\codecoverage" -$tempCoveragePath = $tempPath + "\coverage\" -$tempCoverageFileName = $tempCoveragePath + "coverage.xml" +#$packagesPath = $env:USERPROFILE + "\.nuget\packages" +#$opencoverPath = $packagesPath + "\OpenCover\4.6.519\tools\OpenCover.Console.exe" +#$coverallsPath = $packagesPath + "\coveralls.io\1.3.4\tools\coveralls.net.exe" +#$tempPath = "c:\codecoverage" +#$tempCoveragePath = $tempPath + "\coverage\" +#$tempCoverageFileName = $tempCoveragePath + "coverage.xml" -# create temp path -if (-not (test-path $tempPath) ) { - mkdir $tempPath | Out-Null -} +## create temp path +#if (-not (test-path $tempPath) ) { +# mkdir $tempPath | Out-Null +#} -# run opencover -Get-ChildItem -Path $PSScriptRoot\..\test -Filter *.csproj -Recurse | ForEach-Object { - $path = "$tempPath\$($_.Directory.BaseName)" - if (-not (test-path $path) ) { - mkdir $path | Out-Null - } +## run opencover +#Get-ChildItem -Path $PSScriptRoot\..\test -Filter *.csproj -Recurse | ForEach-Object { +# $path = "$tempPath\$($_.Directory.BaseName)" +# if (-not (test-path $path) ) { +# mkdir $path | Out-Null +# } - $tempBinPath = $path + "\bin\" - $targetArgs = "`"test -o $tempBinPath $($_.FullName)`"" +# $tempBinPath = $path + "\bin\" +# $targetArgs = "`"test -o $tempBinPath $($_.FullName)`"" - if (-not (test-path $tempBinPath) ) { - mkdir $tempBinPath | Out-Null - } +# if (-not (test-path $tempBinPath) ) { +# mkdir $tempBinPath | Out-Null +# } - if (-not (test-path $tempCoveragePath) ) { - mkdir $tempCoveragePath | Out-Null - } +# if (-not (test-path $tempCoveragePath) ) { +# mkdir $tempCoveragePath | Out-Null +# } - & $opencoverPath ` - -register:user ` - -target:"dotnet.exe" ` - -targetargs:$targetArgs ` - -searchdirs:$tempBinPath ` - -output:$tempCoverageFileName ` - -mergebyhash ` - -mergeoutput ` - -skipautoprops ` - -returntargetcode ` - -filter:$filter ` - -hideskipped:Filter ` - -oldstyle -} +# & $opencoverPath ` +# -register:user ` +# -target:"dotnet.exe" ` +# -targetargs:$targetArgs ` +# -searchdirs:$tempBinPath ` +# -output:$tempCoverageFileName ` +# -mergebyhash ` +# -mergeoutput ` +# -skipautoprops ` +# -returntargetcode ` +# -filter:$filter ` +# -hideskipped:Filter ` +# -oldstyle +#} -# upload to coveralls.io -Write-Output "Sending code coverage results to coveralls.io" +## upload to coveralls.io +#Write-Output "Sending code coverage results to coveralls.io" -& $coverallsPath ` - --opencover $tempCoverageFileName ` - --full-sources ` - --repo-token $CoverallsRepoToken +#& $coverallsPath ` +# --opencover $tempCoverageFileName ` +# --full-sources ` +# --repo-token $CoverallsRepoToken -7z a codecoverage.zip $tempCoverageFileName -Push-AppveyorArtifact codecoverage.zip +#7z a codecoverage.zip $tempCoverageFileName +#Push-AppveyorArtifact codecoverage.zip -pip install codecov -codecov -f $tempCoverageFileName -X gcov +#pip install codecov +#codecov -f $tempCoverageFileName -X gcov diff --git a/build/coverlocal.ps1 b/build/coverlocal.ps1 new file mode 100644 index 0000000..6ad5b02 --- /dev/null +++ b/build/coverlocal.ps1 @@ -0,0 +1,68 @@ +Write-Host "PSScriptRoot: " $PSScriptRoot +$CoverFilter='+[Flurl.Http.Xml*]* -[*]*.Logging.* -[*Tests]*' + +Write-Output "Starting code coverage with filter: $CoverFilter" + +$alwaysFilter = "-[xunit*]* -[Microsoft*]* -[dotnet*]* -[NuGet*]* -[Newtonsoft*]* -[Consul*]* -[Nancy*]* -[AngleSharp]* -[csc]* -[Anonymously*]*" +$filter = "$CoverFilter $alwaysFilter" + +$packagesPath = $env:USERPROFILE + "\.nuget\packages" +$opencoverPath = $packagesPath + "\OpenCover\4.6.519\tools\OpenCover.Console.exe" +$coverallsPath = $packagesPath + "\coveralls.io\1.3.4\tools\coveralls.net.exe" +$tempPath = "c:\codecoverage" +$tempCoveragePath = $tempPath + "\coverage\" +$tempCoverageFileName = $tempCoveragePath + "coverage.xml" + +# create temp path +if (-not (test-path $tempPath) ) { + mkdir $tempPath | Out-Null +} + +# run opencover +Get-ChildItem -Path $PSScriptRoot\..\test -Filter *.csproj -Recurse | ForEach-Object { + $path = "$tempPath\$($_.Directory.BaseName)" + if (-not (test-path $path) ) { + mkdir $path | Out-Null + } + + $tempBinPath = $path + "\bin\" + $targetArgs = "`"test -o $tempBinPath $($_.FullName)`"" + + if (-not (test-path $tempBinPath) ) { + mkdir $tempBinPath | Out-Null + } + + if (-not (test-path $tempCoveragePath) ) { + mkdir $tempCoveragePath | Out-Null + } + + & $opencoverPath ` + -register:user ` + -target:"dotnet.exe" ` + -targetargs:$targetArgs ` + -searchdirs:$tempBinPath ` + -output:$tempCoverageFileName ` + -mergebyhash ` + -mergeoutput ` + -skipautoprops ` + -returntargetcode ` + -filter:$filter ` + -hideskipped:Filter ` + -oldstyle +} +<# +# upload to coveralls.io +Write-Output "Sending code coverage results to coveralls.io" + +& $coverallsPath ` + --opencover $tempCoverageFileName ` + --full-sources ` + --repo-token $CoverallsRepoToken + +7z a codecoverage.zip $tempCoverageFileName +Push-AppveyorArtifact codecoverage.zip + +pip install codecov +codecov -f $tempCoverageFileName -X gcov +#> +