2017-10-20 09:43:10 +02:00
|
|
|
|
|
|
|
|
param (
|
2017-10-25 13:23:14 +02:00
|
|
|
# get, don't execute
|
2017-10-20 09:43:10 +02:00
|
|
|
[Parameter(Mandatory=$false)]
|
2017-10-25 13:23:14 +02:00
|
|
|
[Alias("g")]
|
|
|
|
|
[switch] $get = $false,
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
# run local, don't download, assume everything is ready
|
2017-07-07 16:42:27 +02:00
|
|
|
[Parameter(Mandatory=$false)]
|
2017-10-20 09:43:10 +02:00
|
|
|
[Alias("l")]
|
|
|
|
|
[Alias("loc")]
|
|
|
|
|
[switch] $local = $false,
|
2017-07-09 18:46:10 +02:00
|
|
|
|
2019-05-08 14:27:44 +02:00
|
|
|
# enable docfx
|
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
|
|
|
[Alias("doc")]
|
|
|
|
|
[switch] $docfx = $false,
|
2019-06-24 13:18:20 +01:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# keep the build directories, don't clear them
|
2017-07-09 18:46:10 +02:00
|
|
|
[Parameter(Mandatory=$false)]
|
2017-10-25 13:23:14 +02:00
|
|
|
[Alias("c")]
|
|
|
|
|
[Alias("cont")]
|
2019-03-06 10:35:26 +01:00
|
|
|
[switch] $continue = $false,
|
|
|
|
|
|
|
|
|
|
# execute a command
|
|
|
|
|
[Parameter(Mandatory=$false, ValueFromRemainingArguments=$true)]
|
|
|
|
|
[String[]]
|
|
|
|
|
$command
|
2017-10-20 09:43:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# ################################################################
|
|
|
|
|
# BOOTSTRAP
|
|
|
|
|
# ################################################################
|
|
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
# create and boot the buildsystem
|
|
|
|
|
$ubuild = &"$PSScriptRoot\build-bootstrap.ps1"
|
|
|
|
|
if (-not $?) { return }
|
2018-04-05 12:50:00 +02:00
|
|
|
$ubuild.Boot($PSScriptRoot,
|
2019-05-08 14:27:44 +02:00
|
|
|
@{ Local = $local; WithDocFx = $docfx },
|
2017-10-25 13:23:14 +02:00
|
|
|
@{ Continue = $continue })
|
|
|
|
|
if ($ubuild.OnError()) { return }
|
|
|
|
|
|
2018-03-30 10:16:21 +02:00
|
|
|
Write-Host "Umbraco Cms Build"
|
2017-10-20 09:43:10 +02:00
|
|
|
Write-Host "Umbraco.Build v$($ubuild.BuildVersion)"
|
|
|
|
|
|
|
|
|
|
# ################################################################
|
|
|
|
|
# TASKS
|
|
|
|
|
# ################################################################
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("SetMoreUmbracoVersion",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
param ( $semver )
|
|
|
|
|
|
2021-02-16 12:28:37 +01:00
|
|
|
$port = "" + $semver.Major + $semver.Minor + ("" + $semver.Patch).PadLeft(2, '0')
|
|
|
|
|
Write-Host "Update port in launchSettings.json to $port"
|
2021-08-18 11:13:58 +02:00
|
|
|
$filePath = "$($this.SolutionRoot)\src\Umbraco.Web.UI\Properties\launchSettings.json"
|
2021-02-16 12:28:37 +01:00
|
|
|
$this.ReplaceFileText($filePath, `
|
|
|
|
|
"http://localhost:(\d+)?", `
|
|
|
|
|
"http://localhost:$port")
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("SandboxNode",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
$global:node_path = $env:path
|
|
|
|
|
$nodePath = $this.BuildEnv.NodePath
|
2018-04-05 12:50:00 +02:00
|
|
|
$gitExe = (Get-Command git).Source
|
2018-07-27 11:39:27 +01:00
|
|
|
if (-not $gitExe) { $gitExe = (Get-Command git).Path }
|
2017-10-20 09:43:10 +02:00
|
|
|
$gitPath = [System.IO.Path]::GetDirectoryName($gitExe)
|
|
|
|
|
$env:path = "$nodePath;$gitPath"
|
|
|
|
|
|
|
|
|
|
$global:node_nodepath = $this.ClearEnvVar("NODEPATH")
|
|
|
|
|
$global:node_npmcache = $this.ClearEnvVar("NPM_CONFIG_CACHE")
|
|
|
|
|
$global:node_npmprefix = $this.ClearEnvVar("NPM_CONFIG_PREFIX")
|
2018-11-15 08:47:47 +01:00
|
|
|
|
2018-09-04 09:35:39 +02:00
|
|
|
# https://github.com/gruntjs/grunt-contrib-connect/issues/235
|
|
|
|
|
$this.SetEnvVar("NODE_NO_HTTP2", "1")
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("RestoreNode",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
$env:path = $node_path
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.SetEnvVar("NODEPATH", $node_nodepath)
|
|
|
|
|
$this.SetEnvVar("NPM_CONFIG_CACHE", $node_npmcache)
|
|
|
|
|
$this.SetEnvVar("NPM_CONFIG_PREFIX", $node_npmprefix)
|
2018-11-15 08:47:47 +01:00
|
|
|
|
2018-09-04 09:35:39 +02:00
|
|
|
$ignore = $this.ClearEnvVar("NODE_NO_HTTP2")
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("CompileBelle",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
$src = "$($this.SolutionRoot)\src"
|
|
|
|
|
$log = "$($this.BuildTemp)\belle.log"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
Write-Host "Compile Belle"
|
2018-04-05 12:50:00 +02:00
|
|
|
Write-Host "Logging to $log"
|
2017-10-20 09:43:10 +02:00
|
|
|
|
|
|
|
|
# get a temp clean node env (will restore)
|
|
|
|
|
$this.SandboxNode()
|
|
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
# stupid PS is going to gather all "warnings" in $error
|
|
|
|
|
# so we have to take care of it else they'll bubble and kill the build
|
|
|
|
|
if ($error.Count -gt 0) { return }
|
|
|
|
|
|
2019-01-01 01:10:31 +11:00
|
|
|
try {
|
|
|
|
|
Push-Location "$($this.SolutionRoot)\src\Umbraco.Web.UI.Client"
|
|
|
|
|
Write-Output "" > $log
|
|
|
|
|
|
|
|
|
|
Write-Output "### node version is:" > $log
|
|
|
|
|
node -v >> $log 2>&1
|
|
|
|
|
if (-not $?) { throw "Failed to report node version." }
|
|
|
|
|
|
|
|
|
|
Write-Output "### npm version is:" >> $log 2>&1
|
|
|
|
|
npm -v >> $log 2>&1
|
|
|
|
|
if (-not $?) { throw "Failed to report npm version." }
|
|
|
|
|
|
|
|
|
|
Write-Output "### clean npm cache" >> $log 2>&1
|
|
|
|
|
npm cache clean --force >> $log 2>&1
|
|
|
|
|
$error.Clear() # that one can fail 'cos security bug - ignore
|
|
|
|
|
|
|
|
|
|
Write-Output "### npm install" >> $log 2>&1
|
|
|
|
|
npm install >> $log 2>&1
|
|
|
|
|
Write-Output ">> $? $($error.Count)" >> $log 2>&1
|
|
|
|
|
# Don't really care about the messages from npm install making us think there are errors
|
|
|
|
|
$error.Clear()
|
|
|
|
|
|
|
|
|
|
Write-Output "### gulp build for version $($this.Version.Release)" >> $log 2>&1
|
2020-09-03 10:36:58 +02:00
|
|
|
npm run build --buildversion=$this.Version.Release >> $log 2>&1
|
2021-01-20 21:01:45 +01:00
|
|
|
|
2020-09-03 10:36:58 +02:00
|
|
|
# We can ignore this warning, we need to update to node 12 at some point - https://github.com/jsdom/jsdom/issues/2939
|
|
|
|
|
$indexes = [System.Collections.ArrayList]::new()
|
|
|
|
|
$index = 0;
|
|
|
|
|
$error | ForEach-Object {
|
|
|
|
|
# Find which of the errors is the ExperimentalWarning
|
|
|
|
|
if($_.ToString().Contains("ExperimentalWarning: The fs.promises API is experimental")) {
|
|
|
|
|
[void]$indexes.Add($index)
|
|
|
|
|
}
|
|
|
|
|
$index++
|
|
|
|
|
}
|
|
|
|
|
$indexes | ForEach-Object {
|
|
|
|
|
# Loop through the list of indexes and remove the errors that we expect and feel confident we can ignore
|
|
|
|
|
$error.Remove($error[$_])
|
|
|
|
|
}
|
2021-01-20 21:01:45 +01:00
|
|
|
|
2019-01-01 01:10:31 +11:00
|
|
|
if (-not $?) { throw "Failed to build" } # that one is expected to work
|
|
|
|
|
} finally {
|
|
|
|
|
Pop-Location
|
|
|
|
|
|
2019-01-27 01:17:32 -05:00
|
|
|
# FIXME: should we filter the log to find errors?
|
2019-01-01 01:10:31 +11:00
|
|
|
#get-content .\build.tmp\belle.log | %{ if ($_ -match "build") { write $_}}
|
|
|
|
|
|
|
|
|
|
# restore
|
|
|
|
|
$this.RestoreNode()
|
|
|
|
|
}
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# setting node_modules folder to hidden
|
|
|
|
|
# used to prevent VS13 from crashing on it while loading the websites project
|
|
|
|
|
# also makes sure aspnet compiler does not try to handle rogue files and chokes
|
|
|
|
|
# in VSO with Microsoft.VisualC.CppCodeProvider -related errors
|
|
|
|
|
# use get-item -force 'cos it might be hidden already
|
|
|
|
|
Write-Host "Set hidden attribute on node_modules"
|
|
|
|
|
$dir = Get-Item -force "$src\Umbraco.Web.UI.Client\node_modules"
|
|
|
|
|
$dir.Attributes = $dir.Attributes -bor ([System.IO.FileAttributes]::Hidden)
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("CompileUmbraco",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
$buildConfiguration = "Release"
|
|
|
|
|
|
|
|
|
|
$src = "$($this.SolutionRoot)\src"
|
2020-06-30 23:10:51 +02:00
|
|
|
$log = "$($this.BuildTemp)\build.umbraco.log"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
if ($this.BuildEnv.VisualStudio -eq $null)
|
|
|
|
|
{
|
|
|
|
|
throw "Build environment does not provide VisualStudio."
|
|
|
|
|
}
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
Write-Host "Compile Umbraco"
|
|
|
|
|
Write-Host "Logging to $log"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2021-08-18 11:13:58 +02:00
|
|
|
& dotnet build "$src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" `
|
2020-06-30 23:10:51 +02:00
|
|
|
--configuration $buildConfiguration `
|
|
|
|
|
--output "$($this.BuildTemp)\bin\\" `
|
2017-10-20 09:43:10 +02:00
|
|
|
> $log
|
|
|
|
|
|
2020-06-30 23:10:51 +02:00
|
|
|
# get files into WebApp\bin
|
2021-08-18 11:13:58 +02:00
|
|
|
& dotnet publish "$src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" `
|
2020-08-24 09:23:37 +02:00
|
|
|
--configuration Release --output "$($this.BuildTemp)\WebApp\bin\\" `
|
2020-06-30 23:10:51 +02:00
|
|
|
> $log
|
|
|
|
|
|
2021-01-20 21:01:45 +01:00
|
|
|
& dotnet publish "$src\Umbraco.Persistence.SqlCe\Umbraco.Persistence.SqlCe.csproj" `
|
2020-08-24 09:23:37 +02:00
|
|
|
--configuration Release --output "$($this.BuildTemp)\SqlCe\" `
|
2020-08-11 10:40:37 +02:00
|
|
|
> $log
|
|
|
|
|
|
2020-06-30 23:10:51 +02:00
|
|
|
# remove extra files
|
|
|
|
|
$webAppBin = "$($this.BuildTemp)\WebApp\bin"
|
2021-03-11 13:20:46 +01:00
|
|
|
$excludeDirs = @("$($webAppBin)\refs","$($webAppBin)\runtimes","$($webAppBin)\Umbraco","$($webAppBin)\wwwroot")
|
2020-06-30 23:10:51 +02:00
|
|
|
$excludeFiles = @("$($webAppBin)\appsettings.*","$($webAppBin)\*.deps.json","$($webAppBin)\*.exe","$($webAppBin)\*.config","$($webAppBin)\*.runtimeconfig.json")
|
|
|
|
|
$this.RemoveDirectory($excludeDirs)
|
|
|
|
|
$this.RemoveFile($excludeFiles)
|
|
|
|
|
|
|
|
|
|
# copy rest of the files into WebApp
|
2021-08-18 11:13:58 +02:00
|
|
|
$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Web.UI\Umbraco", "*", "$($this.BuildTemp)\WebApp\umbraco")
|
2020-08-11 08:28:16 +02:00
|
|
|
$excludeUmbracoDirs = @("$($this.BuildTemp)\WebApp\umbraco\lib")
|
2020-06-30 23:10:51 +02:00
|
|
|
$this.RemoveDirectory($excludeUmbracoDirs)
|
2021-08-18 11:13:58 +02:00
|
|
|
$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Web.UI\Views", "*", "$($this.BuildTemp)\WebApp\Views")
|
|
|
|
|
Copy-Item "$($this.SolutionRoot)\src\Umbraco.Web.UI\appsettings.json" "$($this.BuildTemp)\WebApp"
|
2020-06-30 23:10:51 +02:00
|
|
|
|
2021-08-18 11:13:58 +02:00
|
|
|
if (-not $?) { throw "Failed to compile Umbraco.Web.UI." }
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# /p:UmbracoBuild tells the csproj that we are building from PS, not VS
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2021-06-24 13:34:42 +01:00
|
|
|
$ubuild.DefineMethod("CompileJsonSchema",
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Generating JSON Schema for AppSettings"
|
|
|
|
|
Write-Host "Logging to $($this.BuildTemp)\json.schema.log"
|
|
|
|
|
|
2021-06-25 10:56:49 +02:00
|
|
|
## NOTE: Need to specify the outputfile to point to the build temp folder
|
2021-06-24 13:34:42 +01:00
|
|
|
&dotnet run --project "$($this.SolutionRoot)\src\JsonSchema\JsonSchema.csproj" `
|
2021-06-25 09:35:39 +02:00
|
|
|
-c Release > "$($this.BuildTemp)\json.schema.log" `
|
|
|
|
|
-- `
|
|
|
|
|
--outputFile "$($this.BuildTemp)\WebApp\umbraco\config\appsettings-schema.json"
|
2021-06-24 13:34:42 +01:00
|
|
|
})
|
|
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("PrepareTests",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
Write-Host "Prepare Tests"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2019-01-27 01:17:32 -05:00
|
|
|
# FIXME: - idea is to avoid rebuilding everything for tests
|
2017-10-20 09:43:10 +02:00
|
|
|
# but because of our weird assembly versioning (with .* stuff)
|
|
|
|
|
# everything gets rebuilt all the time...
|
|
|
|
|
#Copy-Files "$tmp\bin" "." "$tmp\tests"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# data
|
|
|
|
|
Write-Host "Copy data files"
|
|
|
|
|
if (-not (Test-Path -Path "$($this.BuildTemp)\tests\Packaging" ))
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Create packaging directory"
|
|
|
|
|
mkdir "$($this.BuildTemp)\tests\Packaging" > $null
|
|
|
|
|
}
|
2021-01-20 21:01:45 +01:00
|
|
|
#$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Tests\Packaging\Packages", "*", "$($this.BuildTemp)\tests\Packaging\Packages")
|
2018-04-05 12:50:00 +02:00
|
|
|
|
|
|
|
|
# required for package install tests
|
2017-10-20 09:43:10 +02:00
|
|
|
if (-not (Test-Path -Path "$($this.BuildTemp)\tests\bin" ))
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Create bin directory"
|
|
|
|
|
mkdir "$($this.BuildTemp)\tests\bin" > $null
|
|
|
|
|
}
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("CompileTests",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
$buildConfiguration = "Release"
|
|
|
|
|
$log = "$($this.BuildTemp)\msbuild.tests.log"
|
|
|
|
|
|
|
|
|
|
if ($this.BuildEnv.VisualStudio -eq $null)
|
|
|
|
|
{
|
|
|
|
|
throw "Build environment does not provide VisualStudio."
|
|
|
|
|
}
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
Write-Host "Compile Tests"
|
|
|
|
|
Write-Host "Logging to $log"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# beware of the weird double \\ at the end of paths
|
|
|
|
|
# see http://edgylogic.com/blog/powershell-and-external-commands-done-right/
|
|
|
|
|
&$this.BuildEnv.VisualStudio.MsBuild "$($this.SolutionRoot)\src\Umbraco.Tests\Umbraco.Tests.csproj" `
|
|
|
|
|
/p:WarningLevel=0 `
|
|
|
|
|
/p:Configuration=$buildConfiguration `
|
|
|
|
|
/p:Platform=AnyCPU `
|
|
|
|
|
/p:UseWPP_CopyWebApplication=True `
|
|
|
|
|
/p:PipelineDependsOnBuild=False `
|
|
|
|
|
/p:OutDir="$($this.BuildTemp)\tests\\" `
|
|
|
|
|
/p:Verbosity=minimal `
|
|
|
|
|
/t:Build `
|
2017-10-26 11:25:01 +02:00
|
|
|
/tv:"$($this.BuildEnv.VisualStudio.ToolsVersion)" `
|
2017-10-20 09:43:10 +02:00
|
|
|
/p:UmbracoBuild=True `
|
|
|
|
|
> $log
|
|
|
|
|
|
2021-01-20 21:01:45 +01:00
|
|
|
# copy Umbraco.Persistence.SqlCe files into WebApp
|
|
|
|
|
Copy-Item "$($this.BuildTemp)\tests\Umbraco.Persistence.SqlCe.*" "$($this.BuildTemp)\WebApp\bin"
|
2020-07-07 16:10:06 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
if (-not $?) { throw "Failed to compile tests." }
|
|
|
|
|
|
|
|
|
|
# /p:UmbracoBuild tells the csproj that we are building from PS
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("PreparePackages",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
2018-04-05 12:50:00 +02:00
|
|
|
Write-Host "Prepare Packages"
|
|
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
$src = "$($this.SolutionRoot)\src"
|
|
|
|
|
$tmp = "$($this.BuildTemp)"
|
|
|
|
|
$out = "$($this.BuildOutput)"
|
2020-08-11 08:28:16 +02:00
|
|
|
$templates = "$($this.SolutionRoot)\build\templates"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
$buildConfiguration = "Release"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# cleanup build
|
|
|
|
|
Write-Host "Clean build"
|
|
|
|
|
$this.RemoveFile("$tmp\bin\*.dll.config")
|
|
|
|
|
$this.RemoveFile("$tmp\WebApp\bin\*.dll.config")
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# cleanup presentation
|
|
|
|
|
Write-Host "Cleanup presentation"
|
|
|
|
|
$this.RemoveDirectory("$tmp\WebApp\umbraco.presentation")
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# create directories
|
|
|
|
|
Write-Host "Create directories"
|
|
|
|
|
mkdir "$tmp\WebApp\App_Data" > $null
|
2020-08-11 08:28:16 +02:00
|
|
|
mkdir "$tmp\Templates" > $null
|
2017-10-20 09:43:10 +02:00
|
|
|
#mkdir "$tmp\WebApp\Media" > $null
|
|
|
|
|
#mkdir "$tmp\WebApp\Views" > $null
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# copy various files
|
|
|
|
|
Write-Host "Copy xml documentation"
|
|
|
|
|
Copy-Item -force "$tmp\bin\*.xml" "$tmp\WebApp\bin"
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# offset the modified timestamps on all umbraco dlls, as WebResources
|
|
|
|
|
# break if date is in the future, which, due to timezone offsets can happen.
|
|
|
|
|
Write-Host "Offset dlls timestamps"
|
|
|
|
|
Get-ChildItem -r "$tmp\*.dll" | ForEach-Object {
|
|
|
|
|
$_.CreationTime = $_.CreationTime.AddHours(-11)
|
|
|
|
|
$_.LastWriteTime = $_.LastWriteTime.AddHours(-11)
|
|
|
|
|
}
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# copy libs
|
|
|
|
|
Write-Host "Copy SqlCE libraries"
|
2018-07-31 15:55:31 +02:00
|
|
|
$nugetPackages = $env:NUGET_PACKAGES
|
|
|
|
|
if (-not $nugetPackages)
|
|
|
|
|
{
|
|
|
|
|
$nugetPackages = [System.Environment]::ExpandEnvironmentVariables("%userprofile%\.nuget\packages")
|
|
|
|
|
}
|
2020-06-30 23:10:51 +02:00
|
|
|
#$this.CopyFiles("$nugetPackages\umbraco.sqlserverce\4.0.0.1\runtimes\win-x86\native", "*.*", "$tmp\bin\x86")
|
|
|
|
|
#$this.CopyFiles("$nugetPackages\umbraco.sqlserverce\4.0.0.1\runtimes\win-x64\native", "*.*", "$tmp\bin\amd64")
|
|
|
|
|
#$this.CopyFiles("$nugetPackages\umbraco.sqlserverce\4.0.0.1\runtimes\win-x86\native", "*.*", "$tmp\WebApp\bin\x86")
|
|
|
|
|
#$this.CopyFiles("$nugetPackages\umbraco.sqlserverce\4.0.0.1\runtimes\win-x64\native", "*.*", "$tmp\WebApp\bin\amd64")
|
2018-04-05 12:50:00 +02:00
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# copy Belle
|
|
|
|
|
Write-Host "Copy Belle"
|
2021-08-18 11:13:58 +02:00
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI\wwwroot\umbraco\assets", "*", "$tmp\WebApp\wwwroot\umbraco\assets")
|
|
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI\wwwroot\umbraco\js", "*", "$tmp\WebApp\wwwroot\umbraco\js")
|
|
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI\wwwroot\umbraco\lib", "*", "$tmp\WebApp\wwwroot\umbraco\lib")
|
|
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI\wwwroot\umbraco\views", "*", "$tmp\WebApp\wwwroot\umbraco\views")
|
2020-08-11 08:28:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Prepare templates
|
|
|
|
|
Write-Host "Copy template files"
|
|
|
|
|
$this.CopyFiles("$templates", "*", "$tmp\Templates")
|
|
|
|
|
|
2021-02-05 14:41:33 +01:00
|
|
|
Write-Host "Copy files for dotnet templates"
|
2021-08-18 11:13:58 +02:00
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI", "Program.cs", "$tmp\Templates\UmbracoProject")
|
|
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI", "Startup.cs", "$tmp\Templates\UmbracoProject")
|
|
|
|
|
$this.CopyFiles("$src\Umbraco.Web.UI\Views", "*", "$tmp\Templates\UmbracoProject\Views")
|
2020-08-11 08:28:16 +02:00
|
|
|
|
2021-04-22 12:22:01 +01:00
|
|
|
$this.RemoveDirectory("$tmp\Templates\UmbracoProject\bin")
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
|
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("PrepareBuild",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
2018-04-12 22:58:46 +02:00
|
|
|
Write-host "Set environment"
|
|
|
|
|
$env:UMBRACO_VERSION=$this.Version.Semver.ToString()
|
|
|
|
|
$env:UMBRACO_RELEASE=$this.Version.Release
|
|
|
|
|
$env:UMBRACO_COMMENT=$this.Version.Comment
|
|
|
|
|
$env:UMBRACO_BUILD=$this.Version.Build
|
2020-08-11 12:26:01 +02:00
|
|
|
$env:UMBRACO_TMP="$($this.SolutionRoot)\build.tmp"
|
2018-05-16 15:19:46 +02:00
|
|
|
|
2018-04-12 22:58:46 +02:00
|
|
|
if ($args -and $args[0] -eq "vso")
|
|
|
|
|
{
|
|
|
|
|
Write-host "Set VSO environment"
|
|
|
|
|
# set environment variable for VSO
|
|
|
|
|
# https://github.com/Microsoft/vsts-tasks/issues/375
|
|
|
|
|
# https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md
|
|
|
|
|
Write-Host ("##vso[task.setvariable variable=UMBRACO_VERSION;]$($this.Version.Semver.ToString())")
|
|
|
|
|
Write-Host ("##vso[task.setvariable variable=UMBRACO_RELEASE;]$($this.Version.Release)")
|
|
|
|
|
Write-Host ("##vso[task.setvariable variable=UMBRACO_COMMENT;]$($this.Version.Comment)")
|
|
|
|
|
Write-Host ("##vso[task.setvariable variable=UMBRACO_BUILD;]$($this.Version.Build)")
|
|
|
|
|
|
|
|
|
|
Write-Host ("##vso[task.setvariable variable=UMBRACO_TMP;]$($this.SolutionRoot)\build.tmp")
|
|
|
|
|
}
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2020-03-13 13:30:54 +01:00
|
|
|
$nugetsourceUmbraco = "https://api.nuget.org/v3/index.json"
|
|
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("RestoreNuGet",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
Write-Host "Restore NuGet"
|
|
|
|
|
Write-Host "Logging to $($this.BuildTemp)\nuget.restore.log"
|
2020-05-13 15:18:40 +02:00
|
|
|
$params = "-Source", $nugetsourceUmbraco
|
2021-03-04 14:10:55 +01:00
|
|
|
&$this.BuildEnv.NuGet restore "$($this.SolutionRoot)\src\umbraco-netcore-only.sln" > "$($this.BuildTemp)\nuget.restore.log" @params
|
2018-04-05 12:50:00 +02:00
|
|
|
if (-not $?) { throw "Failed to restore NuGet packages." }
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("PackageNuGet",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
|
|
|
|
$nuspecs = "$($this.SolutionRoot)\build\NuSpecs"
|
2020-08-11 08:28:16 +02:00
|
|
|
$templates = "$($this.BuildTemp)\Templates"
|
2017-10-20 09:43:10 +02:00
|
|
|
|
|
|
|
|
Write-Host "Create NuGet packages"
|
|
|
|
|
|
2021-03-04 14:10:55 +01:00
|
|
|
&dotnet pack "$($this.SolutionRoot)\src\umbraco-netcore-only.sln" `
|
|
|
|
|
--output "$($this.BuildOutput)" `
|
|
|
|
|
--verbosity detailed `
|
|
|
|
|
-c Release `
|
|
|
|
|
-p:PackageVersion="$($this.Version.Semver.ToString())" > "$($this.BuildTemp)\pack.umbraco.log"
|
|
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.nuspec" `
|
|
|
|
|
-Properties BuildTmp="$($this.BuildTemp)" `
|
2018-08-29 10:49:55 +10:00
|
|
|
-Version "$($this.Version.Semver.ToString())" `
|
2017-10-25 13:23:14 +02:00
|
|
|
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cms.log"
|
2017-10-20 09:43:10 +02:00
|
|
|
if (-not $?) { throw "Failed to pack NuGet UmbracoCms." }
|
|
|
|
|
|
2020-07-07 16:10:06 +02:00
|
|
|
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.SqlCe.nuspec" `
|
|
|
|
|
-Properties BuildTmp="$($this.BuildTemp)" `
|
|
|
|
|
-Version "$($this.Version.Semver.ToString())" `
|
|
|
|
|
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmssqlce.log"
|
|
|
|
|
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.SqlCe." }
|
|
|
|
|
|
2021-03-19 08:08:00 +01:00
|
|
|
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.StaticAssets.nuspec" `
|
|
|
|
|
-Properties BuildTmp="$($this.BuildTemp)" `
|
|
|
|
|
-Version "$($this.Version.Semver.ToString())" `
|
|
|
|
|
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmsstaticassets.log"
|
|
|
|
|
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.StaticAssets." }
|
|
|
|
|
|
2020-08-11 08:28:16 +02:00
|
|
|
&$this.BuildEnv.NuGet Pack "$templates\Umbraco.Templates.nuspec" `
|
|
|
|
|
-Properties BuildTmp="$($this.BuildTemp)" `
|
|
|
|
|
-Version "$($this.Version.Semver.ToString())" `
|
|
|
|
|
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.templates.log"
|
|
|
|
|
if (-not $?) { throw "Failed to pack NuGet Umbraco.Templates." }
|
|
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# run hook
|
|
|
|
|
if ($this.HasMethod("PostPackageNuGet"))
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Run PostPackageNuGet hook"
|
|
|
|
|
$this.PostPackageNuGet();
|
|
|
|
|
if (-not $?) { throw "Failed to run hook." }
|
|
|
|
|
}
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("VerifyNuGet",
|
|
|
|
|
{
|
|
|
|
|
$this.VerifyNuGetConsistency(
|
2021-03-11 13:29:31 +01:00
|
|
|
("UmbracoCms"),
|
2021-08-18 11:13:58 +02:00
|
|
|
("Umbraco.Core", "Umbraco.Infrastructure", "Umbraco.Web.UI", "Umbraco.Examine.Lucene", "Umbraco.PublishedCache.NuCache", "Umbraco.Web.Common", "Umbraco.Web.Website", "Umbraco.Web.BackOffice", "Umbraco.Persistence.SqlCe"))
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
|
|
|
|
})
|
|
|
|
|
|
2018-03-20 10:43:18 +01:00
|
|
|
$ubuild.DefineMethod("PrepareAzureGallery",
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Prepare Azure Gallery"
|
|
|
|
|
$this.CopyFile("$($this.SolutionRoot)\build\Azure\azuregalleryrelease.ps1", $this.BuildOutput)
|
|
|
|
|
})
|
2019-06-24 13:18:20 +01:00
|
|
|
|
2019-05-01 15:25:47 +02:00
|
|
|
$ubuild.DefineMethod("PrepareCSharpDocs",
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Prepare C# Documentation"
|
2019-06-24 13:18:20 +01:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
$src = "$($this.SolutionRoot)\src"
|
2019-05-15 13:54:35 +02:00
|
|
|
$tmp = $this.BuildTemp
|
|
|
|
|
$out = $this.BuildOutput
|
2019-05-10 13:07:06 +10:00
|
|
|
$DocFxJson = Join-Path -Path $src "\ApiDocs\docfx.json"
|
|
|
|
|
$DocFxSiteOutput = Join-Path -Path $tmp "\_site\*.*"
|
2019-06-24 13:18:20 +01:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
# run DocFx
|
|
|
|
|
$DocFx = $this.BuildEnv.DocFx
|
2019-06-24 13:18:20 +01:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
& $DocFx metadata $DocFxJson
|
|
|
|
|
& $DocFx build $DocFxJson
|
|
|
|
|
|
|
|
|
|
# zip it
|
|
|
|
|
& $this.BuildEnv.Zip a -tzip -r "$out\csharp-docs.zip" $DocFxSiteOutput
|
2019-05-01 15:25:47 +02:00
|
|
|
})
|
2019-06-24 13:18:20 +01:00
|
|
|
|
2019-05-01 15:25:47 +02:00
|
|
|
$ubuild.DefineMethod("PrepareAngularDocs",
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Prepare Angular Documentation"
|
2019-12-05 12:38:57 +00:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
$src = "$($this.SolutionRoot)\src"
|
2019-09-25 10:52:33 +02:00
|
|
|
$out = $this.BuildOutput
|
2019-12-05 12:38:57 +00:00
|
|
|
|
2020-07-07 20:40:44 +02:00
|
|
|
# Check if the solution has been built
|
2020-05-12 12:20:32 +02:00
|
|
|
if (!(Test-Path "$src\Umbraco.Web.UI.Client\node_modules")) {throw "Umbraco needs to be built before generating the Angular Docs"}
|
|
|
|
|
|
2019-09-25 10:52:33 +02:00
|
|
|
"Moving to Umbraco.Web.UI.Docs folder"
|
2020-05-12 12:20:32 +02:00
|
|
|
cd $src\Umbraco.Web.UI.Docs
|
2019-05-01 15:25:47 +02:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
"Generating the docs and waiting before executing the next commands"
|
2019-09-25 10:52:33 +02:00
|
|
|
& npm install
|
|
|
|
|
& npx gulp docs
|
2019-05-01 15:25:47 +02:00
|
|
|
|
2019-05-15 13:54:35 +02:00
|
|
|
Pop-Location
|
2020-07-07 20:40:44 +02:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
# change baseUrl
|
2021-08-09 07:48:37 +02:00
|
|
|
$BaseUrl = "https://apidocs.umbraco.com/v9/ui/"
|
2019-09-25 10:52:33 +02:00
|
|
|
$IndexPath = "./api/index.html"
|
2020-06-18 11:28:31 +02:00
|
|
|
(Get-Content $IndexPath).replace('origin + location.href.substr(origin.length).replace(rUrl, indexFile)', "`'" + $BaseUrl + "`'") | Set-Content $IndexPath
|
2019-05-01 15:25:47 +02:00
|
|
|
|
2019-05-10 13:07:06 +10:00
|
|
|
# zip it
|
2019-09-25 10:52:33 +02:00
|
|
|
& $this.BuildEnv.Zip a -tzip -r "$out\ui-docs.zip" "$src\Umbraco.Web.UI.Docs\api\*.*"
|
2019-05-01 15:25:47 +02:00
|
|
|
})
|
2018-11-15 08:47:47 +01:00
|
|
|
|
2017-10-25 13:23:14 +02:00
|
|
|
$ubuild.DefineMethod("Build",
|
2017-10-20 09:43:10 +02:00
|
|
|
{
|
2018-05-21 10:17:39 +02:00
|
|
|
$error.Clear()
|
|
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.PrepareBuild()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.RestoreNuGet()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.CompileBelle()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.CompileUmbraco()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2021-06-24 13:34:42 +01:00
|
|
|
$this.CompileJsonSchema()
|
|
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.PrepareTests()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.CompileTests()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
# not running tests
|
|
|
|
|
$this.PreparePackages()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
|
|
|
|
$this.VerifyNuGet()
|
|
|
|
|
if ($this.OnError()) { return }
|
2017-10-20 09:43:10 +02:00
|
|
|
$this.PackageNuGet()
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($this.OnError()) { return }
|
2018-03-20 10:43:18 +01:00
|
|
|
$this.PrepareAzureGallery()
|
|
|
|
|
if ($this.OnError()) { return }
|
2019-01-07 19:39:46 +01:00
|
|
|
$this.PostPackageHook()
|
|
|
|
|
if ($this.OnError()) { return }
|
2019-05-10 13:07:06 +10:00
|
|
|
|
2018-09-04 09:35:39 +02:00
|
|
|
Write-Host "Done"
|
2017-10-25 13:23:14 +02:00
|
|
|
})
|
2017-10-20 09:43:10 +02:00
|
|
|
|
2019-01-07 19:39:46 +01:00
|
|
|
$ubuild.DefineMethod("PostPackageHook",
|
|
|
|
|
{
|
|
|
|
|
# run hook
|
|
|
|
|
if ($this.HasMethod("PostPackage"))
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Run PostPackage hook"
|
|
|
|
|
$this.PostPackage();
|
|
|
|
|
if (-not $?) { throw "Failed to run hook." }
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2017-10-20 09:43:10 +02:00
|
|
|
# ################################################################
|
|
|
|
|
# RUN
|
|
|
|
|
# ################################################################
|
|
|
|
|
|
|
|
|
|
# configure
|
|
|
|
|
$ubuild.ReleaseBranches = @( "master" )
|
|
|
|
|
|
|
|
|
|
# run
|
2018-04-05 12:50:00 +02:00
|
|
|
if (-not $get)
|
2017-10-25 13:23:14 +02:00
|
|
|
{
|
2020-05-13 15:18:40 +02:00
|
|
|
cd
|
2019-03-06 10:35:26 +01:00
|
|
|
if ($command.Length -eq 0)
|
|
|
|
|
{
|
|
|
|
|
$command = @( "Build" )
|
|
|
|
|
}
|
|
|
|
|
$ubuild.RunMethod($command);
|
2017-10-25 13:23:14 +02:00
|
|
|
if ($ubuild.OnError()) { return }
|
|
|
|
|
}
|
|
|
|
|
if ($get) { return $ubuild }
|