Browse Source

Merge branch 'build-process' of https://github.com/cosmo0/ImageProcessor into V2

Former-commit-id: 8429d490c79740b95087099837286cbe0c68f62d
af/merge-core
James South 12 years ago
parent
commit
b0b74c1635
  1. 55
      appveyor.yml
  2. 52
      build/build.ps1
  3. 2
      build/build.xml

55
appveyor.yml

@ -0,0 +1,55 @@
# http://www.appveyor.com/docs/appveyor-yml
#---------------------------------#
# general configuration #
#---------------------------------#
# branches to build
branches:
# blacklist
except:
- gh-pages
#---------------------------------#
# environment configuration #
#---------------------------------#
# Operating system (build VM template)
os: Windows Server 2012
# this is how to allow failing jobs in the matrix
matrix:
fast_finish: true # set this flag to immediately finish build once one of the jobs fails.
#---------------------------------#
# build configuration #
#---------------------------------#
# to run your custom scripts instead of automatic MSBuild
build_script:
- ps: Import-Module .\build\psake.psm1
- ps: Invoke-Psake .\build\build.ps1 -properties @{"BuildNumber"=$env:APPVEYOR_BUILD_NUMBER}
#---------------------------------#
# tests configuration #
#---------------------------------#
# to disable automatic tests (they're included in the build process)
test: off
#---------------------------------#
# artifacts configuration #
#---------------------------------#
artifacts:
- path: build\_BuildOutput\NuGets\*.nupkg
#---------------------------------#
# global handlers #
#---------------------------------#
# on successful build
on_success:
- ps: Import-Module .\build\psake.psm1
- ps: Invoke-Psake .\build\build.ps1 Publish-Nuget -properties @{"NugetApiKey"=$env:APIKEY;"NugetSource"=$env:SOURCE}

52
build/build.ps1

@ -1,7 +1,14 @@
Properties { Properties {
# call nuget.bat with these values as parameters
$NugetApiKey = $null
$NugetSource = $null
# see appveyor.yml for usage
$BuildNumber = $null
# Input and output paths # Input and output paths
$BUILD_PATH = Resolve-Path "." $BUILD_PATH = Resolve-Path "."
$SRC_PATH = Resolve-Path "..\src" $SRC_PATH = Join-Path $BUILD_PATH "..\src"
$PLUGINS_PATH = Join-Path $SRC_PATH "Plugins\ImageProcessor" $PLUGINS_PATH = Join-Path $SRC_PATH "Plugins\ImageProcessor"
$NUSPECS_PATH = Join-Path $BUILD_PATH "NuSpecs" $NUSPECS_PATH = Join-Path $BUILD_PATH "NuSpecs"
$BIN_PATH = Join-Path $BUILD_PATH "_BuildOutput" $BIN_PATH = Join-Path $BUILD_PATH "_BuildOutput"
@ -16,7 +23,8 @@ Properties {
$NUNITREPORT_EXE = Join-Path $BUILD_PATH "tools\NUnitHTMLReportGenerator.exe" $NUNITREPORT_EXE = Join-Path $BUILD_PATH "tools\NUnitHTMLReportGenerator.exe"
# list of projects # list of projects
[xml]$PROJECTS = Get-Content ".\build.xml" $PROJECTS_PATH = (Join-Path $BUILD_PATH "build.xml")
[xml]$PROJECTS = Get-Content $PROJECTS_PATH
$TestProjects = @( $TestProjects = @(
"ImageProcessor.UnitTests", "ImageProcessor.UnitTests",
@ -27,7 +35,7 @@ Properties {
Framework "4.0x86" Framework "4.0x86"
FormatTaskName "-------- {0} --------" FormatTaskName "-------- {0} --------"
task default -depends Cleanup-Binaries, Build-Solution, Run-Tests, Generate-Package task default -depends Cleanup-Binaries, Set-VersionNumber, Build-Solution, Run-Tests, Generate-Package
# cleans up the binaries output folder # cleans up the binaries output folder
task Cleanup-Binaries { task Cleanup-Binaries {
@ -45,8 +53,22 @@ task Cleanup-Binaries {
} }
} }
# sets the version number from the build number in the build.xml file
task Set-VersionNumber {
if ($BuildNumber -eq $null -or $BuildNumber -eq "") {
return
}
$PROJECTS.projects.project | % {
if ($_.version -match "([\d+\.]*)[\d+|\*]") { # get numbers of current version except last one
$_.version = "$($Matches[1])$BuildNumber"
}
}
$PROJECTS.Save($PROJECTS_PATH)
}
# builds the solutions # builds the solutions
task Build-Solution -depends Cleanup-Binaries { task Build-Solution -depends Cleanup-Binaries, Set-VersionNumber {
Write-Host "Building projects" Write-Host "Building projects"
# build the projects # build the projects
@ -87,7 +109,6 @@ task Build-Tests -depends Cleanup-Binaries {
msbuild (Join-Path $SRC_PATH "$_\$_.csproj") /t:Build /p:Configuration=Release /p:Platform="AnyCPU" /p:Warnings=true /clp:WarningsOnly /clp:ErrorsOnly /v:Normal /nologo msbuild (Join-Path $SRC_PATH "$_\$_.csproj") /t:Build /p:Configuration=Release /p:Platform="AnyCPU" /p:Warnings=true /clp:WarningsOnly /clp:ErrorsOnly /v:Normal /nologo
} }
} }
} }
# runs the unit tests # runs the unit tests
@ -128,7 +149,7 @@ task Run-Coverage -depends Build-Tests {
} }
# generates a Nuget package # generates a Nuget package
task Generate-Package -depends Build-Solution { task Generate-Package -depends Set-VersionNumber, Build-Solution {
Write-Host "Generating Nuget packages for each project" Write-Host "Generating Nuget packages for each project"
# Nuget doesn't create the output dir automatically... # Nuget doesn't create the output dir automatically...
@ -146,11 +167,30 @@ task Generate-Package -depends Build-Solution {
$nuspec_contents.package.metadata.version = $_.version $nuspec_contents.package.metadata.version = $_.version
$nuspec_contents.Save($nuspec_local_path) $nuspec_contents.Save($nuspec_local_path)
if ((-not (Test-Path $nuspec_local_path)) -or (-not (Test-Path $NUGET_OUTPUT))) {
throw New-Object [System.IO.FileNotFoundException] "The file $nuspec_local_path or $NUGET_OUTPUT could not be found"
}
# pack the nuget # pack the nuget
& $NUGET_EXE Pack $nuspec_local_path -OutputDirectory $NUGET_OUTPUT & $NUGET_EXE Pack $nuspec_local_path -OutputDirectory $NUGET_OUTPUT
} }
} }
# publishes the nuget on a feed
task Publish-Nuget {
if ($NugetApiKey -eq $null -or $NugetApiKey -eq "") {
throw New-Object [System.ArgumentException] "You must provide an API key as parameter: 'Invoke-psake Publish-Nuget -properties @{`"NugetApiKey`"=`"YOURAPIKEY`"}' ; or add a APIKEY environment variable to AppVeyor"
}
Get-ChildItem $NUGET_OUTPUT -Filter "*.nugpkg" | % {
if ($NugetSource -eq $null -or $NugetSource -eq "") {
& $NUGET_EXE push $_ -ApiKey $apikey -Source $NugetSource
} else {
& $NUGET_EXE push $_ -ApiKey $apikey
}
}
}
# updates the AssemblyInfo file with the specified version # updates the AssemblyInfo file with the specified version
# http://www.luisrocha.net/2009/11/setting-assembly-version-with-windows.html # http://www.luisrocha.net/2009/11/setting-assembly-version-with-windows.html
function Update-AssemblyInfo ([string]$file, [string] $version) { function Update-AssemblyInfo ([string]$file, [string] $version) {

2
build/build.xml

@ -20,7 +20,7 @@
<project> <project>
<name>ImageProcessor Web.config sample</name> <name>ImageProcessor Web.config sample</name>
<version>2.0.0.0</version> <version>2.0.0.0</version>
<nuspec>ImageProcessor.Web.nuspec</nuspec> <nuspec>ImageProcessor.Web.Config.nuspec</nuspec>
</project> </project>
<project> <project>

Loading…
Cancel
Save