diff --git a/.gitignore b/.gitignore index d99550b..a888917 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,6 @@ obj # mstest test results TestResults -#node/gulp -node_modules -npm-debug.log - # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore @@ -22,4 +18,10 @@ npm-debug.log # except build/, which is used as an MSBuild target. !**/packages/build/ # If using the old MSBuild-Integrated Package Restore, uncomment this: -#!**/packages/repositories.config \ No newline at end of file +#!**/packages/repositories.config + +#Build Script Artifacts +Package +BCLExtensionsCoverage.xml +BCLExtensions.*.zip +BCLExtensions.*.nupkg \ No newline at end of file diff --git a/src/BCLExtensions/BCLExtensions.nuspec b/BCLExtensions.nuspec similarity index 85% rename from src/BCLExtensions/BCLExtensions.nuspec rename to BCLExtensions.nuspec index 3dd61eb..1743b81 100644 --- a/src/BCLExtensions/BCLExtensions.nuspec +++ b/BCLExtensions.nuspec @@ -2,14 +2,14 @@ BCLExtensions - 0.1.0.0 + 1.0.0.0 BCLExtensions csmacnz csmacnz false Base Class Library Extensions for C# base class library classes Initial Release. - Copyright 2014 + Copyright 2015 BCLExtensions, PCL diff --git a/Build.environment.ps1 b/Build.environment.ps1 index 857dfa2..709592e 100644 --- a/Build.environment.ps1 +++ b/Build.environment.ps1 @@ -1,5 +1,7 @@ choco install psake choco install pscx +choco install GitVersion.Portable +choco install nuget.CommandLine $pscxPath = "C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx"; @@ -7,8 +9,8 @@ if (-not (Test-Path $pscxPath)) { $pscxPath = $null; Write-Host "Searching for the pscx powershell module."; - $pscxPath = (Get-ChildItem -Path "C:\Program Files\" -Filter "pscx.dll" -Recurse).FullName; - if (!$pscxPath) { $pscxPath = (Get-ChildItem -Path "C:\Program Files (x86)\" -Filter "pscx.dll" -Recurse).FullName; } + $pscxPath = (Get-ChildItem -Path "C:\Program Files\" -Filter "pscx.dll" -Recurse -ErrorAction SilentlyContinue).FullName; + if (!$pscxPath) { $pscxPath = (Get-ChildItem -Path "C:\Program Files (x86)\" -Filter "pscx.dll" -Recurse -ErrorAction SilentlyContinue).FullName; } $pscxPath = Split-Path $pscxPath; Write-Host "Found it at " + $pscxPath; } diff --git a/appveyor.yml b/appveyor.yml index c4eb0b3..8d21382 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,20 @@ -version: 0.1.{build} +version: 1.0.0.{build} +os: Windows Server 2012 R2 +branches: + except: + - master +environment: + COVERALLS_REPO_TOKEN: + secure: BBCvZzwY+hZfJFv/nnoi708GIAELA2a3gN2+D6xE14vejYrxjpWyAfhK4Kj0HSSy install: - ps: .\build.environment.ps1 +- ps: psake .\build.tasks.ps1 appveyor-install build_script: - ps: psake .\build.tasks.ps1 appveyor-build test_script: - ps: psake .\build.tasks.ps1 appveyor-test artifacts: -- path: BCLExtensionsTests.xml - name: BCLExtensionsTests.xml \ No newline at end of file +- path: BCLExtensionsCoverage.xml + name: BCLExtensionsCoverage.xml +- path: BCLExtensions.*.zip +- path: BCLExtensions.*.nupkg \ No newline at end of file diff --git a/build.tasks.ps1 b/build.tasks.ps1 index 93334b3..659505f 100644 --- a/build.tasks.ps1 +++ b/build.tasks.ps1 @@ -2,17 +2,24 @@ properties { # build variables $framework = "4.5.1" # .net framework version $configuration = "Release" # build configuration - $script:version = "0.1.0" + $script:version = "1.0.0" + $script:nugetVersion = "1.0.0" + $script:runCoverity = $false # directories $base_dir = . resolve-path .\ $build_output_dir = "$base_dir\src\BCLExtensions\bin\$configuration\" $test_results_dir = "$base_dir\TestResults\" + $package_dir = "$base_dir\Package\" + $archive_dir = "$package_dir" + "Archive" + $nuget_pack_dir = "$package_dir" + "Pack" # files $sln_file = "$base_dir\src\BCLExtensions.sln" + $nuspec_filename = "BCLExtensions.nuspec" $testOptions = "" $script:xunit = "$base_dir\src\packages\xunit.runners.1.9.2\tools\xunit.console.clr4.exe" + $script:coveralls = "csmacnz.Coveralls.exe" } @@ -22,26 +29,59 @@ task RestoreNuGetPackages { exec { nuget.exe restore $sln_file } } +task GitVersion { + GitVersion /output buildserver /updateassemblyinfo true /assemblyVersionFormat Major + if($env:APPVEYOR_REPO_TAG) { + Update-AppveyorBuild -Version $env:GitVersion_FullSemVer + } +} + task LocalTestSettings { $script:xunit = "$base_dir/src/packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe" $script:testOptions = "" } -task AppVeyorTestSettings { - if (Test-Path Env:\APPVEYOR_BUILD_VERSION) { +task ResolveCoverallsPath { + $script:coveralls = (Resolve-Path "src/packages/coveralls.net.*/csmacnz.coveralls.exe").ToString() +} + +task AppVeyorEnvironmentSettings { + if(Test-Path Env:\GitVersion_ClassicVersion) { + $script:version = $env:GitVersion_ClassicVersion + echo "version set to $script:version" + } + elseif (Test-Path Env:\APPVEYOR_BUILD_VERSION) { $script:version = $env:APPVEYOR_BUILD_VERSION echo "version set to $script:version" } + if(Test-Path Env:\GitVersion_NuGetVersionV2) { + $script:nugetVersion = $env:GitVersion_NuGetVersionV2 + echo "nuget version set to $script:nugetVersion" + } + elseif (Test-Path Env:\APPVEYOR_BUILD_VERSION) { + $script:nugetVersion = $env:APPVEYOR_BUILD_VERSION + echo "nuget version set to $script:nugetVersion" + } $script:xunit = "xunit.console.clr4.exe" $script:testOptions = "/appveyor" } task clean { + if (Test-Path $package_dir) { + Remove-Item $package_dir -r + } if (Test-Path $test_results_dir) { Remove-Item $test_results_dir -r } - + $archive_filename = "BCLExtensions.*.zip" + if (Test-Path $archive_filename) { + Remove-Item $archive_filename + } + $nupkg_filename = "BCLExtensions.*.nupkg" + if (Test-Path $nupkg_filename) { + Remove-Item $nupkg_filename + } exec { msbuild "/t:Clean" "/p:Configuration=$configuration" $sln_file } } @@ -49,26 +89,79 @@ task build { exec { msbuild "/t:Clean;Build" "/p:Configuration=$configuration" $sln_file } } -task coverity { - cov-build --dir cov-int msbuild "/t:Clean;Build" "/p:Configuration=$configuration" $sln_file +task appveyor-checkCoverity { + if($env:APPVEYOR_SCHEDULED_BUILD -eq "True") { + $script:runCoverity = $true + + #download coverity + Invoke-WebRequest ` + -Uri "https://scan.coverity.com/download/cxx/win_64" ` + -Body @{ project = "$env:APPVEYOR_REPO_NAME"; + token = "$env:CoverityProjectToken" } ` + -OutFile "$env:APPVEYOR_BUILD_FOLDER\coverity.zip" + + # Unzip downloaded package. + Add-Type -AssemblyName "System.IO.Compression.FileSystem" + IO.Compression.ZipFile]::ExtractToDirectory( "$env:APPVEYOR_BUILD_FOLDER\coverity.zip", "$env:APPVEYOR_BUILD_FOLDER") + } +} + +task coverity -precondition { return $script:runCoverity }{ + $covbuild = (Resolve-Path ".\cov-analysis-win64-*\bin\cov-build.exe").ToString(); + & $covbuild --dir cov-int msbuild "/t:Clean;Build" "/p:Configuration=$configuration" $sln_file + + Write-Zip -Path "cov-int" -OutputPath BCLExtensions.coverity.$script:nugetVersion.zip - Write-Zip -Path "cov-int" -OutputPath BCLExtensions.coverity.$script:version.zip + #TODO: Upload coverity } task coverage -depends LocalTestSettings, build, coverage-only task coverage-only { - exec { & .\src\packages\OpenCover.4.5.3522\OpenCover.Console.exe -register:user -target:$script:xunit "-targetargs:""src\BCLExtensions.Tests\bin\$Configuration\BCLExtensions.Tests.dll"" /noshadow $script:testOptions" -filter:"+[BCLExtensions*]*" -output:BCLExtensionsTests.xml } + exec { & .\src\packages\OpenCover.4.5.3522\OpenCover.Console.exe -register:user -target:$script:xunit "-targetargs:""src\BCLExtensions.Tests\bin\$Configuration\BCLExtensions.Tests.dll"" /noshadow $script:testOptions" -filter:"+[BCLExtensions*]*" -output:BCLExtensionsCoverage.xml } } -task coveralls -depends coverage, coveralls-only +task test-coveralls -depends coverage, ResolveCoverallsPath { + exec { & $coveralls --opencover -i BCLExtensionsCoverage.xml --dryrun -o coverallsTestOutput.json --repoToken "NOTAREALTOKEN" } +} + +task coveralls -depends ResolveCoverallsPath { + exec { & $coveralls --opencover -i BCLExtensionsCoverage.xml --repoToken $env:COVERALLS_REPO_TOKEN --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID } +} + +task archive -depends build, archive-only -task coveralls-only { - exec { & ".\src\packages\coveralls.net.0.4.0\csmacnz.Coveralls.exe" --opencover -i BCLExtensionsTests.xml --repoToken "JnVjBzTw7uW2AwhUXpeCKUNHj41JbHSGu" --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID} +task archive-only { + $archive_filename = "BCLExtensions.$script:nugetVersion.zip" + + mkdir $archive_dir + + cp "$build_output_dir\BCLExtensions.dll" "$archive_dir" + + Write-Zip -Path "$archive_dir\*" -OutputPath $archive_filename } -task postbuild -depends coverage-only, coveralls-only +task pack -depends build, pack-only + +task pack-only { + + mkdir $nuget_pack_dir + cp "$nuspec_filename" "$nuget_pack_dir" + + mkdir "$nuget_pack_dir\lib" + cp "$build_output_dir\BCLExtensions.dll" "$nuget_pack_dir\lib" + + $Spec = [xml](get-content "$nuget_pack_dir\$nuspec_filename") + $Spec.package.metadata.version = ([string]$Spec.package.metadata.version).Replace("{Version}", $script:nugetVersion) + $Spec.Save("$nuget_pack_dir\$nuspec_filename") + + exec { nuget pack "$nuget_pack_dir\$nuspec_filename" } +} + +task postbuild -depends pack, archive, coverage-only, coveralls + +task appveyor-install -depends GitVersion, RestoreNuGetPackages -task appveyor-build -depends RestoreNuGetPackages, build +task appveyor-build -depends build -task appveyor-test -depends AppVeyorTestSettings, postbuild +task appveyor-test -depends AppVeyorEnvironmentSettings, postbuild, appveyor-checkCoverity, coverity diff --git a/src/BCLExtensions.Tests/Properties/AssemblyInfo.cs b/src/BCLExtensions.Tests/Properties/AssemblyInfo.cs index fab956b..ec6b274 100644 --- a/src/BCLExtensions.Tests/Properties/AssemblyInfo.cs +++ b/src/BCLExtensions.Tests/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("csmacnz")] [assembly: AssemblyProduct("BCLExtensions.Tests")] -[assembly: AssemblyCopyright("Copyright © csmacnz 2014")] +[assembly: AssemblyCopyright("Copyright © csmacnz 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -31,6 +31,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] -[assembly: AssemblyInformationalVersion("0.1.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/src/BCLExtensions.sln b/src/BCLExtensions.sln index af3ca60..e2a2e3a 100644 --- a/src/BCLExtensions.sln +++ b/src/BCLExtensions.sln @@ -9,8 +9,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BCLExtensions.Tests", "BCLE EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{76757003-F98A-49EB-B953-7FE5972DE2AC}" ProjectSection(SolutionItems) = preProject + ..\.gitattributes = ..\.gitattributes + ..\.gitignore = ..\.gitignore ..\.travis.yml = ..\.travis.yml ..\appveyor.yml = ..\appveyor.yml + ..\BCLExtensions.nuspec = ..\BCLExtensions.nuspec ..\Build.environment.ps1 = ..\Build.environment.ps1 ..\build.tasks.ps1 = ..\build.tasks.ps1 ..\README.md = ..\README.md diff --git a/src/BCLExtensions/BCLExtensions.csproj b/src/BCLExtensions/BCLExtensions.csproj index 0e3ee0e..632cb08 100644 --- a/src/BCLExtensions/BCLExtensions.csproj +++ b/src/BCLExtensions/BCLExtensions.csproj @@ -45,9 +45,6 @@ - - -