Skip to content

Commit

Permalink
Updated build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
csMACnz committed Feb 15, 2015
1 parent 7c6765d commit 5ee9ede
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 37 deletions.
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ 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
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# If using the old MSBuild-Integrated Package Restore, uncomment this:
#!**/packages/repositories.config
#!**/packages/repositories.config

#Build Script Artifacts
Package
BCLExtensionsCoverage.xml
BCLExtensions.*.zip
BCLExtensions.*.nupkg
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<package >
<metadata>
<id>BCLExtensions</id>
<version>0.1.0.0</version>
<version>1.0.0.0</version>
<title>BCLExtensions</title>
<authors>csmacnz</authors>
<owners>csmacnz</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Base Class Library Extensions for C# base class library classes</description>
<releaseNotes>Initial Release.</releaseNotes>
<copyright>Copyright 2014</copyright>
<copyright>Copyright 2015</copyright>
<tags>BCLExtensions, PCL</tags>
</metadata>
</package>
6 changes: 4 additions & 2 deletions Build.environment.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
choco install psake
choco install pscx
choco install GitVersion.Portable
choco install nuget.CommandLine

$pscxPath = "C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx";

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;
}
Expand Down
16 changes: 13 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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
- path: BCLExtensionsCoverage.xml
name: BCLExtensionsCoverage.xml
- path: BCLExtensions.*.zip
- path: BCLExtensions.*.nupkg
121 changes: 107 additions & 14 deletions build.tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

Expand All @@ -22,53 +29,139 @@ 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 }
}

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
8 changes: 4 additions & 4 deletions src/BCLExtensions.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("")]

Expand All @@ -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")]
3 changes: 3 additions & 0 deletions src/BCLExtensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/BCLExtensions/BCLExtensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TypeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="BCLExtensions.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
8 changes: 4 additions & 4 deletions src/BCLExtensions/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("csmacnz")]
[assembly: AssemblyProduct("BCLExtensions")]
[assembly: AssemblyCopyright("Copyright © csmacnz 2014")]
[assembly: AssemblyCopyright("Copyright © csmacnz 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
Expand All @@ -24,6 +24,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")]

0 comments on commit 5ee9ede

Please sign in to comment.