|
| 1 | + |
| 2 | + param ( |
| 3 | + # get, don't execute |
| 4 | + [Parameter(Mandatory=$false)] |
| 5 | + [Alias("g")] |
| 6 | + [switch] $get = $false, |
| 7 | + |
| 8 | + # run local, don't download, assume everything is ready |
| 9 | + [Parameter(Mandatory=$false)] |
| 10 | + [Alias("l")] |
| 11 | + [Alias("loc")] |
| 12 | + [switch] $local = $false, |
| 13 | + |
| 14 | + # keep the build directories, don't clear them |
| 15 | + [Parameter(Mandatory=$false)] |
| 16 | + [Alias("c")] |
| 17 | + [Alias("cont")] |
| 18 | + [switch] $continue = $false |
| 19 | + ) |
| 20 | + |
| 21 | + # ################################################################ |
| 22 | + # BOOTSTRAP |
| 23 | + # ################################################################ |
| 24 | + |
| 25 | + # create and boot the buildsystem |
| 26 | + $ubuild = &"$PSScriptRoot\build-bootstrap.ps1" |
| 27 | + if (-not $?) { return } |
| 28 | + $ubuild.Boot($PSScriptRoot, |
| 29 | + @{ Local = $local; }, |
| 30 | + @{ Continue = $continue }) |
| 31 | + if ($ubuild.OnError()) { return } |
| 32 | + |
| 33 | + Write-Host "Umbraco.Cloud.StorageProviders.AzureBlob Build" |
| 34 | + Write-Host "Umbraco.Build v$($ubuild.BuildVersion)" |
| 35 | + |
| 36 | + # ################################################################ |
| 37 | + # TASKS |
| 38 | + # ################################################################ |
| 39 | + |
| 40 | + $ubuild.DefineMethod("CompileUmbracoCloudStorageProvidersAzureBlob", |
| 41 | + { |
| 42 | + $buildConfiguration = "Release" |
| 43 | + |
| 44 | + $src = "$($this.SolutionRoot)\src" |
| 45 | + $log = "$($this.BuildTemp)\dotnet.build.umbraco.log" |
| 46 | + |
| 47 | + if ($this.BuildEnv.VisualStudio -eq $null) |
| 48 | + { |
| 49 | + throw "Build environment does not provide VisualStudio." |
| 50 | + } |
| 51 | + |
| 52 | + Write-Host "Compile Umbraco.Cloud.StorageProviders.AzureBlob" |
| 53 | + Write-Host "Logging to $log" |
| 54 | + |
| 55 | + &dotnet build "$src\Umbraco.Cloud.StorageProviders.AzureBlob\Umbraco.Cloud.StorageProviders.AzureBlob.csproj" ` |
| 56 | + --configuration $buildConfiguration ` |
| 57 | + --output "$($this.BuildTemp)\bin\\" ` |
| 58 | + > $log |
| 59 | + |
| 60 | + # get files into WebApp\bin |
| 61 | + &dotnet publish "$src\Umbraco.Cloud.StorageProviders.AzureBlob\Umbraco.Cloud.StorageProviders.AzureBlob.csproj" ` |
| 62 | + --configuration Release --output "$($this.BuildTemp)\WebApp\bin\\" ` |
| 63 | + > $log |
| 64 | + |
| 65 | + # remove extra files |
| 66 | + $webAppBin = "$($this.BuildTemp)\WebApp\bin" |
| 67 | + $excludeDirs = @("$($webAppBin)\refs","$($webAppBin)\runtimes","$($webAppBin)\Umbraco","$($webAppBin)\wwwroot") |
| 68 | + $excludeFiles = @("$($webAppBin)\appsettings.*","$($webAppBin)\*.deps.json","$($webAppBin)\*.exe","$($webAppBin)\*.config","$($webAppBin)\*.runtimeconfig.json") |
| 69 | + $this.RemoveDirectory($excludeDirs) |
| 70 | + $this.RemoveFile($excludeFiles) |
| 71 | + |
| 72 | + if (-not $?) { throw "Failed to compile Umbraco.StorageProviders." } |
| 73 | + |
| 74 | + # /p:UmbracoBuild tells the csproj that we are building from PS, not VS |
| 75 | + }) |
| 76 | + |
| 77 | + |
| 78 | + $ubuild.DefineMethod("PreparePackages", |
| 79 | + { |
| 80 | + Write-Host "Prepare Packages" |
| 81 | + |
| 82 | + $src = "$($this.SolutionRoot)\src" |
| 83 | + $tmp = "$($this.BuildTemp)" |
| 84 | + $out = "$($this.BuildOutput)" |
| 85 | + |
| 86 | + $buildConfiguration = "Release" |
| 87 | + |
| 88 | + # cleanup build |
| 89 | + Write-Host "Clean build" |
| 90 | + $this.RemoveFile("$tmp\bin\*.dll.config") |
| 91 | + |
| 92 | + # cleanup WebApp |
| 93 | + Write-Host "Cleanup WebApp" |
| 94 | + $this.RemoveDirectory("$tmp\WebApp") |
| 95 | + |
| 96 | + # offset the modified timestamps on all umbraco dlls, as WebResources |
| 97 | + # break if date is in the future, which, due to timezone offsets can happen. |
| 98 | + Write-Host "Offset dlls timestamps" |
| 99 | + Get-ChildItem -r "$tmp\*.dll" | ForEach-Object { |
| 100 | + $_.CreationTime = $_.CreationTime.AddHours(-11) |
| 101 | + $_.LastWriteTime = $_.LastWriteTime.AddHours(-11) |
| 102 | + } |
| 103 | + }) |
| 104 | + |
| 105 | + $ubuild.DefineMethod("PrepareBuild", |
| 106 | + { |
| 107 | + Write-Host "============ PrepareBuild ============" |
| 108 | + |
| 109 | + Write-host "Set environment" |
| 110 | + $env:UMBRACO_VERSION=$this.Version.Semver.ToString() |
| 111 | + $env:UMBRACO_RELEASE=$this.Version.Release |
| 112 | + $env:UMBRACO_COMMENT=$this.Version.Comment |
| 113 | + $env:UMBRACO_BUILD=$this.Version.Build |
| 114 | + |
| 115 | + if ($args -and $args[0] -eq "vso") |
| 116 | + { |
| 117 | + Write-host "Set VSO environment" |
| 118 | + # set environment variable for VSO |
| 119 | + # https://github.com/Microsoft/vsts-tasks/issues/375 |
| 120 | + # https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md |
| 121 | + Write-Host ("##vso[task.setvariable variable=UMBRACO_VERSION;]$($this.Version.Semver.ToString())") |
| 122 | + Write-Host ("##vso[task.setvariable variable=UMBRACO_RELEASE;]$($this.Version.Release)") |
| 123 | + Write-Host ("##vso[task.setvariable variable=UMBRACO_COMMENT;]$($this.Version.Comment)") |
| 124 | + Write-Host ("##vso[task.setvariable variable=UMBRACO_BUILD;]$($this.Version.Build)") |
| 125 | + |
| 126 | + Write-Host ("##vso[task.setvariable variable=UMBRACO_TMP;]$($this.SolutionRoot)\build.tmp") |
| 127 | + } |
| 128 | + }) |
| 129 | + |
| 130 | + $ubuild.DefineMethod("RestoreNuGet", |
| 131 | + { |
| 132 | + Write-Host "Restore NuGet" |
| 133 | + Write-Host "Logging to $($this.BuildTemp)\nuget.restore.log" |
| 134 | + &$this.BuildEnv.NuGet restore "$($this.SolutionRoot)\Umbraco.Cloud.StorageProviders.AzureBlob.sln" > "$($this.BuildTemp)\nuget.restore.log" |
| 135 | + if (-not $?) { throw "Failed to restore NuGet packages." } |
| 136 | + }) |
| 137 | + |
| 138 | + $ubuild.DefineMethod("PackageNuGet", |
| 139 | + { |
| 140 | + Write-Host "Create NuGet packages" |
| 141 | + |
| 142 | + $log = "$($this.BuildTemp)\dotnet.pack.umbraco.log" |
| 143 | + Write-Host "Logging to $log" |
| 144 | + |
| 145 | + &dotnet pack "Umbraco.Cloud.StorageProviders.AzureBlob.sln" ` |
| 146 | + --output "$($this.BuildOutput)" ` |
| 147 | + --verbosity detailed ` |
| 148 | + -c Release ` |
| 149 | + -p:PackageVersion="$($this.Version.Semver.ToString())" > $log |
| 150 | + |
| 151 | + # run hook |
| 152 | + if ($this.HasMethod("PostPackageNuGet")) |
| 153 | + { |
| 154 | + Write-Host "Run PostPackageNuGet hook" |
| 155 | + $this.PostPackageNuGet(); |
| 156 | + if (-not $?) { throw "Failed to run hook." } |
| 157 | + } |
| 158 | + }) |
| 159 | + |
| 160 | + $ubuild.DefineMethod("Build", |
| 161 | + { |
| 162 | + $error.Clear() |
| 163 | + |
| 164 | + # $this.PrepareBuild() |
| 165 | + # if ($this.OnError()) { return } |
| 166 | + $this.RestoreNuGet() |
| 167 | + if ($this.OnError()) { return } |
| 168 | + $this.CompileUmbracoCloudStorageProvidersAzureBlob() |
| 169 | + if ($this.OnError()) { return } |
| 170 | + $this.PreparePackages() |
| 171 | + if ($this.OnError()) { return } |
| 172 | + $this.PackageNuGet() |
| 173 | + if ($this.OnError()) { return } |
| 174 | + Write-Host "Done" |
| 175 | + }) |
| 176 | + |
| 177 | + # ################################################################ |
| 178 | + # RUN |
| 179 | + # ################################################################ |
| 180 | + |
| 181 | + # configure |
| 182 | + $ubuild.ReleaseBranches = @( "master" ) |
| 183 | + |
| 184 | + # run |
| 185 | + if (-not $get) |
| 186 | + { |
| 187 | + $ubuild.Build() |
| 188 | + if ($ubuild.OnError()) { return } |
| 189 | + } |
| 190 | + if ($get) { return $ubuild } |
0 commit comments