|
| 1 | +param( |
| 2 | + [String] $majorMinor = "0.0", # 2.0 |
| 3 | + [String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION |
| 4 | + [String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll |
| 5 | + [Switch] $notouch, |
| 6 | + [String] $sln # e.g serilog-sink-name |
| 7 | +) |
| 8 | + |
| 9 | +function Set-AssemblyVersions($informational, $assembly) |
| 10 | +{ |
| 11 | + (Get-Content assets/CommonAssemblyInfo.cs) | |
| 12 | + ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } | |
| 13 | + ForEach-Object { $_ -replace """1.0.0""", """$informational""" } | |
| 14 | + ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } | |
| 15 | + Set-Content assets/CommonAssemblyInfo.cs |
| 16 | +} |
| 17 | + |
| 18 | +function Install-NuGetPackages($solution) |
| 19 | +{ |
| 20 | + nuget restore $solution |
| 21 | +} |
| 22 | + |
| 23 | +function Invoke-MSBuild($solution, $customLogger) |
| 24 | +{ |
| 25 | + if ($customLogger) |
| 26 | + { |
| 27 | + msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger" |
| 28 | + } |
| 29 | + else |
| 30 | + { |
| 31 | + msbuild "$solution" /verbosity:minimal /p:Configuration=Release |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +function Invoke-NuGetPackProj($csproj) |
| 36 | +{ |
| 37 | + nuget pack -Prop Configuration=Release -Symbols $csproj |
| 38 | +} |
| 39 | + |
| 40 | +function Invoke-NuGetPackSpec($nuspec, $version) |
| 41 | +{ |
| 42 | + nuget pack $nuspec -Version $version -OutputDirectory ..\..\ |
| 43 | +} |
| 44 | + |
| 45 | +function Invoke-NuGetPack($version) |
| 46 | +{ |
| 47 | + ls src/**/*.csproj | |
| 48 | + Where-Object { -not ($_.Name -like "*net40*") } | |
| 49 | + ForEach-Object { Invoke-NuGetPackProj $_ } |
| 50 | +} |
| 51 | + |
| 52 | +function Invoke-Build($majorMinor, $patch, $customLogger, $notouch, $sln) |
| 53 | +{ |
| 54 | + $package="$majorMinor.$patch" |
| 55 | + $slnfile = "$sln.sln" |
| 56 | + |
| 57 | + Write-Output "$sln $package" |
| 58 | + |
| 59 | + if (-not $notouch) |
| 60 | + { |
| 61 | + $assembly = "$majorMinor.0.0" |
| 62 | + |
| 63 | + Write-Output "Assembly version will be set to $assembly" |
| 64 | + Set-AssemblyVersions $package $assembly |
| 65 | + } |
| 66 | + |
| 67 | + Install-NuGetPackages $slnfile |
| 68 | + |
| 69 | + Invoke-MSBuild $slnfile $customLogger |
| 70 | + |
| 71 | + Invoke-NuGetPack $package |
| 72 | +} |
| 73 | + |
| 74 | +$ErrorActionPreference = "Stop" |
| 75 | + |
| 76 | +if (-not $sln) |
| 77 | +{ |
| 78 | + $slnfull = ls *.sln | |
| 79 | + Where-Object { -not ($_.Name -like "*net40*") } | |
| 80 | + Select -first 1 |
| 81 | + |
| 82 | + $sln = $slnfull.BaseName |
| 83 | +} |
| 84 | + |
| 85 | +Invoke-Build $majorMinor $patch $customLogger $notouch $sln |
0 commit comments