Migrate to Umbraco.Build

This commit is contained in:
Stephan
2017-10-20 09:43:10 +02:00
parent 14eb4fe6e0
commit 0fe96a58c1
14 changed files with 489 additions and 1734 deletions

4
.gitignore vendored
View File

@@ -148,5 +148,5 @@ src/PrecompiledWeb/*
# build
build.out/
build.tmp/
build/Modules/*/temp/
build/hooks/
build/hooks/
build/temp/

View File

@@ -1,113 +0,0 @@
#
function Build-UmbracoDocs
{
$uenv = Get-UmbracoBuildEnv
$src = "$($uenv.SolutionRoot)\src"
$out = "$($uenv.SolutionRoot)\build.out"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$buildTemp = "$PSScriptRoot\temp"
$cache = 2
Prepare-Build -keep $uenv
################ Do the UI docs
Write-Host "Build UI documentation"
# get a temp clean node env (will restore)
Sandbox-Node $uenv
push-location "$src\Umbraco.Web.UI.Client"
write "" > $tmp\belle-docs.log
write "node version is:" > $tmp\belle.log
&node -v >> $tmp\belle.log 2>&1
write "npm version is:" >> $tmp\belle.log 2>&1
&npm -v >> $tmp\belle.log 2>&1
write "clean npm cache" >> $tmp\belle.log 2>&1
&npm cache clean >> $tmp\belle.log 2>&1
write "npm install" >> $tmp\belle.log 2>&1
&npm install >> $tmp\belle.log 2>&1
write "installing bower" >> $tmp\belle.log 2>&1
&npm install -g bower >> $tmp\belle.log 2>&1
write "installing gulp" >> $tmp\belle.log 2>&1
&npm install -g gulp >> $tmp\belle.log 2>&1
write "installing gulp-cli" >> $tmp\belle.log 2>&1
&npm install -g gulp-cli --quiet >> $tmp\belle.log 2>&1
write "gulp docs" >> $tmp\belle.log 2>&1
&gulp docs >> $tmp\belle.log 2>&1
pop-location
# fixme - should we filter the log to find errors?
#get-content .\build.tmp\belle-docs.log | %{ if ($_ -match "build") { write $_}}
# change baseUrl
$baseUrl = "https://our.umbraco.org/apidocs/ui/"
$indexPath = "$src/Umbraco.Web.UI.Client/docs/api/index.html"
(Get-Content $indexPath).Replace("location.href.replace(rUrl, indexFile)", "'$baseUrl'") `
| Set-Content $indexPath
# restore
Restore-Node
# zip
&$uenv.Zip a -tzip -r "$out\ui-docs.zip" "$src\Umbraco.Web.UI.Client\docs\api\*.*" `
> $null
################ Do the c# docs
Write-Host "Build C# documentation"
# Build the solution in debug mode
# FIXME no only a simple compilation should be enough!
# FIXME we MUST handle msbuild & co error codes!
# FIXME deal with weird things in gitconfig?
#Build-Umbraco -Configuration Debug
Restore-NuGet $uenv
Compile-Umbraco $uenv "Debug" # FIXME different log file!
Restore-WebConfig "$src\Umbraco.Web.UI"
# ensure we have docfx
Get-DocFx $uenv $buildTemp
# clear
$docFxOutput = "$($uenv.SolutionRoot)\apidocs\_site"
if (test-path($docFxOutput))
{
Remove-Directory $docFxOutput
}
# run
$docFxJson = "$($uenv.SolutionRoot)\apidocs\docfx.json"
push-location "$($uenv.SolutionRoot)\build" # silly docfx.json wants this
Write-Host "Run DocFx metadata"
Write-Host "Logging to $tmp\docfx.metadata.log"
&$uenv.DocFx metadata $docFxJson > "$tmp\docfx.metadata.log"
Write-Host "Run DocFx build"
Write-Host "Logging to $tmp\docfx.build.log"
&$uenv.DocFx build $docFxJson > "$tmp\docfx.build.log"
pop-location
# zip
&$uenv.Zip a -tzip -r "$out\csharp-docs.zip" "$docFxOutput\*.*" `
> $null
}
function Get-DocFx($uenv, $buildTemp)
{
$docFx = "$buildTemp\docfx"
if (-not (test-path $docFx))
{
Write-Host "Download DocFx..."
$source = "https://github.com/dotnet/docfx/releases/download/v2.19.2/docfx.zip"
Invoke-WebRequest $source -OutFile "$buildTemp\docfx.zip"
&$uenv.Zip x "$buildTemp\docfx.zip" -o"$buildTemp\docfx" -aos > $nul
Remove-File "$buildTemp\docfx.zip"
}
$uenv | add-member -memberType NoteProperty -name DocFx -value "$docFx\docfx.exe"
}

View File

@@ -1,174 +0,0 @@
#
# Get-UmbracoBuildEnv
# Gets the Umbraco build environment
# Downloads tools if necessary
#
function Get-UmbracoBuildEnv
{
# cache for 2 days
$cache = 2
# ensure we have NuGet
$nuget = "$scriptTemp\nuget.exe"
$source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
if ((test-path $nuget) -and ((ls $nuget).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-File $nuget
}
if (-not (test-path $nuget))
{
Write-Host "Download NuGet..."
Invoke-WebRequest $source -OutFile $nuget
}
# ensure we have 7-Zip
$sevenZip = "$scriptTemp\7za.exe"
if ((test-path $sevenZip) -and ((ls $sevenZip).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-File $sevenZip
}
if (-not (test-path $sevenZip))
{
Write-Host "Download 7-Zip..."
&$nuget install 7-Zip.CommandLine -OutputDirectory $scriptTemp -Verbosity quiet
$dir = ls "$scriptTemp\7-Zip.CommandLine.*" | sort -property Name -descending | select -first 1
$file = ls -path "$dir" -name 7za.exe -recurse
mv "$dir\$file" $sevenZip
Remove-Directory $dir
}
# ensure we have vswhere
$vswhere = "$scriptTemp\vswhere.exe"
if ((test-path $vswhere) -and ((ls $vswhere).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-File $vswhere
}
if (-not (test-path $vswhere))
{
Write-Host "Download VsWhere..."
&$nuget install vswhere -OutputDirectory $scriptTemp -Verbosity quiet
$dir = ls "$scriptTemp\vswhere.*" | sort -property Name -descending | select -first 1
$file = ls -path "$dir" -name vswhere.exe -recurse
mv "$dir\$file" $vswhere
Remove-Directory $dir
}
# ensure we have semver
$semver = "$scriptTemp\Semver.dll"
if ((test-path $semver) -and ((ls $semver).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-File $semver
}
if (-not (test-path $semver))
{
Write-Host "Download Semver..."
&$nuget install semver -OutputDirectory $scriptTemp -Verbosity quiet
$dir = ls "$scriptTemp\semver.*" | sort -property Name -descending | select -first 1
$file = "$dir\lib\net452\Semver.dll"
if (-not (test-path $file))
{
Write-Error "Failed to file $file"
return
}
mv "$file" $semver
Remove-Directory $dir
}
try
{
[Reflection.Assembly]::LoadFile($semver) > $null
}
catch
{
Write-Error -Exception $_.Exception -Message "Failed to load $semver"
break
}
# ensure we have node
$node = "$scriptTemp\node-v6.9.1-win-x86"
$source = "http://nodejs.org/dist/v6.9.1/node-v6.9.1-win-x86.7z"
if (-not (test-path $node))
{
Write-Host "Download Node..."
Invoke-WebRequest $source -OutFile "$scriptTemp\node-v6.9.1-win-x86.7z"
&$sevenZip x "$scriptTemp\node-v6.9.1-win-x86.7z" -o"$scriptTemp" -aos > $nul
Remove-File "$scriptTemp\node-v6.9.1-win-x86.7z"
}
# note: why? node already brings everything we need!
## ensure we have npm
#$npm = "$scriptTemp\npm.*"
#$getNpm = $true
#if (test-path $npm)
#{
# $getNpm = $false
# $tmpNpm = ls "$scriptTemp\npm.*" | sort -property Name -descending | select -first 1
# if ($tmpNpm.CreationTime -lt [DateTime]::Now.AddDays(-$cache))
# {
# $getNpm = $true
# }
# else
# {
# $npm = $tmpNpm.ToString()
# }
#}
#if ($getNpm)
#{
# Write-Host "Download Npm..."
# &$nuget install npm -OutputDirectory $scriptTemp -Verbosity quiet
# $npm = ls "$scriptTemp\npm.*" | sort -property Name -descending | select -first 1
# $npm.CreationTime = [DateTime]::Now
# $npm = $npm.ToString()
#}
# find visual studio
# will not work on VSO but VSO does not need it
$vsPath = ""
$vsVer = ""
$msBuild = $null
&$vswhere | foreach {
if ($_.StartsWith("installationPath:")) { $vsPath = $_.SubString("installationPath:".Length).Trim() }
if ($_.StartsWith("installationVersion:")) { $vsVer = $_.SubString("installationVersion:".Length).Trim() }
}
if ($vsPath -ne "")
{
$vsVerParts = $vsVer.Split('.')
$vsMajor = [int]::Parse($vsVerParts[0])
$vsMinor = [int]::Parse($vsVerParts[1])
if ($vsMajor -eq 15) {
$msBuild = "$vsPath\MSBuild\$vsMajor.0\Bin"
}
elseif ($vsMajor -eq 14) {
$msBuild = "c:\Program Files (x86)\MSBuild\$vsMajor\Bin"
}
else
{
$msBuild = $null
}
}
$vs = $null
if ($msBuild)
{
$vs = new-object -typeName PsObject
$vs | add-member -memberType NoteProperty -name Path -value $vsPath
$vs | add-member -memberType NoteProperty -name Major -value $vsMajor
$vs | add-member -memberType NoteProperty -name Minor -value $vsMinor
$vs | add-member -memberType NoteProperty -name MsBuild -value "$msBuild\MsBuild.exe"
}
#$solutionRoot = Get-FullPath "$PSScriptRoot\..\..\.."
$solutionRoot = [System.IO.Path]::GetFullPath("$scriptRoot\..")
$uenv = new-object -typeName PsObject
$uenv | add-member -memberType NoteProperty -name SolutionRoot -value $solutionRoot
$uenv | add-member -memberType NoteProperty -name VisualStudio -value $vs
$uenv | add-member -memberType NoteProperty -name NuGet -value $nuget
$uenv | add-member -memberType NoteProperty -name Zip -value $sevenZip
$uenv | add-member -memberType NoteProperty -name VsWhere -value $vswhere
$uenv | add-member -memberType NoteProperty -name Semver -value $semver
$uenv | add-member -memberType NoteProperty -name NodePath -value $node
#$uenv | add-member -memberType NoteProperty -name NpmPath -value $npm
return $uenv
}

View File

@@ -1,26 +0,0 @@
#
# Get-UmbracoVersion
# Gets the Umbraco version
#
function Get-UmbracoVersion
{
$uenv = Get-UmbracoBuildEnv
# parse SolutionInfo and retrieve the version string
$filepath = "$($uenv.SolutionRoot)\src\SolutionInfo.cs"
$text = [System.IO.File]::ReadAllText($filepath)
$match = [System.Text.RegularExpressions.Regex]::Matches($text, "AssemblyInformationalVersion\(`"(.+)?`"\)")
$version = $match.Groups[1]
# semver-parse the version string
$semver = [SemVer.SemVersion]::Parse($version)
$release = "" + $semver.Major + "." + $semver.Minor + "." + $semver.Patch
$versions = new-object -typeName PsObject
$versions | add-member -memberType NoteProperty -name Semver -value $semver
$versions | add-member -memberType NoteProperty -name Release -value $release
$versions | add-member -memberType NoteProperty -name Comment -value $semver.PreRelease
$versions | add-member -memberType NoteProperty -name Build -value $semver.Build
return $versions
}

View File

@@ -1,30 +0,0 @@
# finds msbuild
function Get-VisualStudio($vswhere)
{
$vsPath = ""
$vsVer = ""
&$vswhere | foreach {
if ($_.StartsWith("installationPath:")) { $vsPath = $_.SubString("installationPath:".Length).Trim() }
if ($_.StartsWith("installationVersion:")) { $vsVer = $_.SubString("installationVersion:".Length).Trim() }
}
if ($vsPath -eq "") { return $null }
$vsVerParts = $vsVer.Split('.')
$vsMajor = [int]::Parse($vsVerParts[0])
$vsMinor = [int]::Parse($vsVerParts[1])
if ($vsMajor -eq 15) {
$msBuild = "$vsPath\MSBuild\$vsMajor.$vsMinor\Bin"
}
elseif ($vsMajor -eq 14) {
$msBuild = "c:\Program Files (x86)\MSBuild\$vsMajor\Bin"
}
else { return $null }
$msBuild = "$msBuild\MsBuild.exe"
$vs = new-object -typeName PsObject
$vs | add-member -memberType NoteProperty -name Path -value $vsPath
$vs | add-member -memberType NoteProperty -name Major -value $vsMajor
$vs | add-member -memberType NoteProperty -name Minor -value $vsMinor
$vs | add-member -memberType NoteProperty -name MsBuild -value $msBuild
return $vs
}

View File

@@ -1,117 +0,0 @@
#
# Set-UmbracoVersion
# Sets the Umbraco version
#
# -Version <version>
# where <version> is a Semver valid version
# eg 1.2.3, 1.2.3-alpha, 1.2.3-alpha+456
#
function Set-UmbracoVersion
{
param (
[Parameter(Mandatory=$true)]
[string]
$version
)
$uenv = Get-UmbracoBuildEnv
try
{
[Reflection.Assembly]::LoadFile($uenv.Semver) > $null
}
catch
{
Write-Error "Failed to load $uenv.Semver"
break
}
# validate input
$ok = [Regex]::Match($version, "^[0-9]+\.[0-9]+\.[0-9]+(\-[a-z0-9\.]+)?(\+[0-9]+)?$")
if (-not $ok.Success)
{
Write-Error "Invalid version $version"
break
}
# parse input
try
{
$semver = [SemVer.SemVersion]::Parse($version)
}
catch
{
Write-Error "Invalid version $version"
break
}
#
$release = "" + $semver.Major + "." + $semver.Minor + "." + $semver.Patch
# edit files and set the proper versions and dates
Write-Host "Update UmbracoVersion.cs"
Replace-FileText "$($uenv.SolutionRoot)\src\Umbraco.Core\Configuration\UmbracoVersion.cs" `
"(\d+)\.(\d+)\.(\d+)(.(\d+))?" `
"$release"
Replace-FileText "$($uenv.SolutionRoot)\src\Umbraco.Core\Configuration\UmbracoVersion.cs" `
"CurrentComment => `"(.+)`"" `
"CurrentComment => `"$($semver.PreRelease)`""
Write-Host "Update SolutionInfo.cs"
Replace-FileText "$($uenv.SolutionRoot)\src\SolutionInfo.cs" `
"AssemblyFileVersion\(`"(.+)?`"\)" `
"AssemblyFileVersion(`"$release`")"
Replace-FileText "$($uenv.SolutionRoot)\src\SolutionInfo.cs" `
"AssemblyInformationalVersion\(`"(.+)?`"\)" `
"AssemblyInformationalVersion(`"$semver`")"
$year = [System.DateTime]::Now.ToString("yyyy")
Replace-FileText "$($uenv.SolutionRoot)\src\SolutionInfo.cs" `
"AssemblyCopyright\(`"Copyright © Umbraco (\d{4})`"\)" `
"AssemblyCopyright(`"Copyright © Umbraco $year`")"
# edit csproj and set IIS Express port number
# this is a raw copy of ReplaceIISExpressPortNumber.exe
# it probably can be achieved in a much nicer way - l8tr
$source = @"
using System;
using System.IO;
using System.Xml;
using System.Globalization;
namespace Umbraco
{
public static class PortUpdater
{
public static void Update(string path, string release)
{
XmlDocument xmlDocument = new XmlDocument();
string fullPath = Path.GetFullPath(path);
xmlDocument.Load(fullPath);
int result = 1;
int.TryParse(release.Replace(`".`", `"`"), out result);
while (result < 1024)
result *= 10;
XmlNode xmlNode1 = xmlDocument.GetElementsByTagName(`"IISUrl`").Item(0);
if (xmlNode1 != null)
xmlNode1.InnerText = `"http://localhost:`" + (object) result;
XmlNode xmlNode2 = xmlDocument.GetElementsByTagName(`"DevelopmentServerPort`").Item(0);
if (xmlNode2 != null)
xmlNode2.InnerText = result.ToString((IFormatProvider) CultureInfo.InvariantCulture);
xmlDocument.Save(fullPath);
}
}
}
"@
$assem = (
"System.Xml",
"System.IO",
"System.Globalization"
)
Write-Host "Update Umbraco.Web.UI.csproj"
add-type -referencedAssemblies $assem -typeDefinition $source -language CSharp
$csproj = "$($uenv.SolutionRoot)\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj"
[Umbraco.PortUpdater]::Update($csproj, $release)
return $semver
}

View File

@@ -1,634 +0,0 @@
# Umbraco.Build.psm1
#
# $env:PSModulePath = "$pwd\build\Modules\;$env:PSModulePath"
# Import-Module Umbraco.Build -Force -DisableNameChecking
#
# PowerShell Modules:
# https://msdn.microsoft.com/en-us/library/dd878324%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
#
# PowerShell Module Manifest:
# https://msdn.microsoft.com/en-us/library/dd878337%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
#
# See also
# http://www.powershellmagazine.com/2014/08/15/pstip-taking-control-of-verbose-and-debug-output-part-5/
. "$PSScriptRoot\Utilities.ps1"
. "$PSScriptRoot\Get-VisualStudio.ps1"
. "$PSScriptRoot\Get-UmbracoBuildEnv.ps1"
. "$PSScriptRoot\Set-UmbracoVersion.ps1"
. "$PSScriptRoot\Get-UmbracoVersion.ps1"
. "$PSScriptRoot\Verify-NuGet.ps1"
. "$PSScriptRoot\Build-UmbracoDocs.ps1"
#
# Prepares the build
#
function Prepare-Build
{
param (
$uenv, # an Umbraco build environment (see Get-UmbracoBuildEnv)
[Alias("k")]
[switch]
$keep = $false
)
Write-Host ">> Prepare Build"
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$($uenv.SolutionRoot)\build.out"
# clear
Write-Host "Clear folders and files"
Remove-Directory "$src\Umbraco.Web.UI.Client\bower_components"
if (-not $keep)
{
Remove-Directory "$tmp"
mkdir "$tmp" > $null
Remove-Directory "$out"
mkdir "$out" > $null
}
# ensure proper web.config
$webUi = "$src\Umbraco.Web.UI"
Store-WebConfig $webUi
Write-Host "Create clean web.config"
Copy-File "$webUi\web.Template.config" "$webUi\web.config"
}
function Clear-EnvVar($var)
{
$value = [Environment]::GetEnvironmentVariable($var)
if (test-path "env:$var") { rm "env:$var" }
return $value
}
function Set-EnvVar($var, $value)
{
if ($value)
{
[Environment]::SetEnvironmentVariable($var, $value)
}
else
{
if (test-path "env:$var") { rm "env:$var" }
}
}
function Sandbox-Node
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
$global:node_path = $env:path
$nodePath = $uenv.NodePath
$gitExe = (get-command git).Source
$gitPath = [System.IO.Path]::GetDirectoryName($gitExe)
$env:path = "$nodePath;$gitPath"
$global:node_nodepath = Clear-EnvVar "NODEPATH"
$global:node_npmcache = Clear-EnvVar "NPM_CONFIG_CACHE"
$global:node_npmprefix = Clear-EnvVar "NPM_CONFIG_PREFIX"
}
function Restore-Node
{
$env:path = $node_path
Set-EnvVar "NODEPATH" $node_nodepath
Set-EnvVar "NPM_CONFIG_CACHE" $node_npmcache
Set-EnvVar "NPM_CONFIG_PREFIX" $node_npmprefix
}
#
# Builds the Belle UI project
#
function Compile-Belle
{
param (
$uenv, # an Umbraco build environment (see Get-UmbracoBuildEnv)
$version # an Umbraco version object (see Get-UmbracoVersion)
)
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$src = "$($uenv.SolutionRoot)\src"
Write-Host ">> Compile Belle"
Write-Host "Logging to $tmp\belle.log"
# get a temp clean node env (will restore)
Sandbox-Node $uenv
push-location "$($uenv.SolutionRoot)\src\Umbraco.Web.UI.Client"
write "" > $tmp\belle.log
write "node version is:" > $tmp\belle.log
&node -v >> $tmp\belle.log 2>&1
write "npm version is:" >> $tmp\belle.log 2>&1
&npm -v >> $tmp\belle.log 2>&1
write "clean npm cache" >> $tmp\belle.log 2>&1
&npm cache clean >> $tmp\belle.log 2>&1
write "npm install" >> $tmp\belle.log 2>&1
&npm install >> $tmp\belle.log 2>&1
write "install bower" >> $tmp\belle.log 2>&1
&npm install -g bower >> $tmp\belle.log 2>&1
write "install gulp" >> $tmp\belle.log 2>&1
&npm install -g gulp >> $tmp\belle.log 2>&1
write "install gulp-cli" >> $tmp\belle.log 2>&1
&npm install -g gulp-cli --quiet >> $tmp\belle.log 2>&1
write "gulp build for version $version" >> $tmp\belle.log 2>&1
&gulp build --buildversion=$version.Release >> $tmp\belle.log 2>&1
pop-location
# fixme - should we filter the log to find errors?
#get-content .\build.tmp\belle.log | %{ if ($_ -match "build") { write $_}}
# restore
Restore-Node
# 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 "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)
}
#
# Compiles Umbraco
#
function Compile-Umbraco
{
param (
$uenv, # an Umbraco build environment (see Get-UmbracoBuildEnv)
[string] $buildConfiguration = "Release"
)
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$($uenv.SolutionRoot)\build.out"
if ($uenv.VisualStudio -eq $null)
{
Write-Error "Build environment does not provide VisualStudio."
break
}
$toolsVersion = "4.0"
if ($uenv.VisualStudio.Major -eq 15)
{
$toolsVersion = "15.0"
}
Write-Host ">> Compile Umbraco"
Write-Host "Logging to $tmp\msbuild.umbraco.log"
# beware of the weird double \\ at the end of paths
# see http://edgylogic.com/blog/powershell-and-external-commands-done-right/
&$uenv.VisualStudio.MsBuild "$src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" `
/p:WarningLevel=0 `
/p:Configuration=$buildConfiguration `
/p:Platform=AnyCPU `
/p:UseWPP_CopyWebApplication=True `
/p:PipelineDependsOnBuild=False `
/p:OutDir=$tmp\bin\\ `
/p:WebProjectOutputDir=$tmp\WebApp\\ `
/p:Verbosity=minimal `
/t:Clean`;Rebuild `
/tv:$toolsVersion `
/p:UmbracoBuild=True `
> $tmp\msbuild.umbraco.log
&$uenv.VisualStudio.MsBuild "$src\Umbraco.Compat7\Umbraco.Compat7.csproj" `
/p:WarningLevel=0 `
/p:Configuration=$buildConfiguration `
/p:Platform=AnyCPU `
/p:UseWPP_CopyWebApplication=True `
/p:PipelineDependsOnBuild=False `
/p:OutDir=$tmp\bin\\ `
/p:WebProjectOutputDir=$tmp\WebApp\\ `
/p:Verbosity=minimal `
/t:Rebuild `
/tv:$toolsVersion `
/p:UmbracoBuild=True `
> $tmp\msbuild.compat7.log
# /p:UmbracoBuild tells the csproj that we are building from PS, not VS
}
#
# Prepare Tests
#
function Prepare-Tests
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
Write-Host ">> Prepare Tests"
# fixme - idea is to avoid rebuilding everything for tests
# but because of our weird assembly versioning (with .* stuff)
# everything gets rebuilt all the time...
#Copy-Files "$tmp\bin" "." "$tmp\tests"
# data
Write-Host "Copy data files"
if (-not (Test-Path -Path "$tmp\tests\Packaging" ))
{
Write-Host "Create packaging directory"
mkdir "$tmp\tests\Packaging" > $null
}
Copy-Files "$src\Umbraco.Tests\Packaging\Packages" "*" "$tmp\tests\Packaging\Packages"
# required for package install tests
if (-not (Test-Path -Path "$tmp\tests\bin" ))
{
Write-Host "Create bin directory"
mkdir "$tmp\tests\bin" > $null
}
}
#
# Compiles Tests
#
function Compile-Tests
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$tmp\tests"
$buildConfiguration = "Release"
if ($uenv.VisualStudio -eq $null)
{
Write-Error "Build environment does not provide VisualStudio."
break
}
$toolsVersion = "4.0"
if ($uenv.VisualStudio.Major -eq 15)
{
$toolsVersion = "15.0"
}
Write-Host ">> Compile Tests"
Write-Host "Logging to $tmp\msbuild.tests.log"
# beware of the weird double \\ at the end of paths
# see http://edgylogic.com/blog/powershell-and-external-commands-done-right/
&$uenv.VisualStudio.MsBuild "$src\Umbraco.Tests\Umbraco.Tests.csproj" `
/p:WarningLevel=0 `
/p:Configuration=$buildConfiguration `
/p:Platform=AnyCPU `
/p:UseWPP_CopyWebApplication=True `
/p:PipelineDependsOnBuild=False `
/p:OutDir=$out\\ `
/p:Verbosity=minimal `
/t:Build `
/tv:$toolsVersion `
/p:UmbracoBuild=True `
/p:NugetPackages=$src\packages `
> $tmp\msbuild.tests.log
# /p:UmbracoBuild tells the csproj that we are building from PS
}
#
# Cleans things up and prepare files after compilation
#
function Prepare-Packages
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
Write-Host ">> Prepare Packages"
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$($uenv.SolutionRoot)\build.out"
$buildConfiguration = "Release"
# restore web.config
Restore-WebConfig "$src\Umbraco.Web.UI"
# cleanup build
Write-Host "Clean build"
Remove-File "$tmp\bin\*.dll.config"
Remove-File "$tmp\WebApp\bin\*.dll.config"
# cleanup presentation
Write-Host "Cleanup presentation"
Remove-Directory "$tmp\WebApp\umbraco.presentation"
# create directories
Write-Host "Create directories"
mkdir "$tmp\Configs" > $null
mkdir "$tmp\Configs\Lang" > $null
mkdir "$tmp\WebApp\App_Data" > $null
#mkdir "$tmp\WebApp\Media" > $null
#mkdir "$tmp\WebApp\Views" > $null
# copy various files
Write-Host "Copy xml documentation"
cp -force "$tmp\bin\*.xml" "$tmp\WebApp\bin"
Write-Host "Copy transformed configs and langs"
# note: exclude imageprocessor/*.config as imageprocessor pkg installs them
Copy-Files "$tmp\WebApp\config" "*.config" "$tmp\Configs" `
{ -not $_.RelativeName.StartsWith("imageprocessor") }
Copy-Files "$tmp\WebApp\config" "*.js" "$tmp\Configs"
Copy-Files "$tmp\WebApp\config\lang" "*.xml" "$tmp\Configs\Lang"
Copy-File "$tmp\WebApp\web.config" "$tmp\Configs\web.config.transform"
Write-Host "Copy transformed web.config"
Copy-File "$src\Umbraco.Web.UI\web.$buildConfiguration.Config.transformed" "$tmp\WebApp\web.config"
# 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"
ls -r "$tmp\*.dll" | foreach {
$_.CreationTime = $_.CreationTime.AddHours(-11)
$_.LastWriteTime = $_.LastWriteTime.AddHours(-11)
}
# copy libs
Write-Host "Copy SqlCE libraries"
Copy-Files "$src\packages\SqlServerCE.4.0.0.1" "*.*" "$tmp\bin" `
{ -not $_.Extension.StartsWith(".nu") -and -not $_.RelativeName.StartsWith("lib\") }
Copy-Files "$src\packages\SqlServerCE.4.0.0.1" "*.*" "$tmp\WebApp\bin" `
{ -not $_.Extension.StartsWith(".nu") -and -not $_.RelativeName.StartsWith("lib\") }
# copy Belle
Write-Host "Copy Belle"
Copy-Files "$src\Umbraco.Web.UI\umbraco\assets" "*" "$tmp\WebApp\umbraco\assets"
Copy-Files "$src\Umbraco.Web.UI\umbraco\js" "*" "$tmp\WebApp\umbraco\js"
Copy-Files "$src\Umbraco.Web.UI\umbraco\lib" "*" "$tmp\WebApp\umbraco\lib"
Copy-Files "$src\Umbraco.Web.UI\umbraco\views" "*" "$tmp\WebApp\umbraco\views"
Copy-Files "$src\Umbraco.Web.UI\umbraco\preview" "*" "$tmp\WebApp\umbraco\preview"
# prepare WebPI
Write-Host "Prepare WebPI"
Remove-Directory "$tmp\WebPi"
mkdir "$tmp\WebPi" > $null
mkdir "$tmp\WebPi\umbraco" > $null
Copy-Files "$tmp\WebApp" "*" "$tmp\WebPi\umbraco"
Copy-Files "$src\WebPi" "*" "$tmp\WebPi"
}
#
# Creates the Zip packages
#
function Package-Zip
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
Write-Host ">> Create Zip packages"
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$($uenv.SolutionRoot)\build.out"
Write-Host "Zip all binaries"
&$uenv.Zip a -r "$out\UmbracoCms.AllBinaries.$($version.Semver).zip" `
"$tmp\bin\*" `
"-x!dotless.Core.*" "-x!Umbraco.Compat7.*" `
> $null
Write-Host "Zip cms"
&$uenv.Zip a -r "$out\UmbracoCms.$($version.Semver).zip" `
"$tmp\WebApp\*" `
"-x!dotless.Core.*" "-x!Content_Types.xml" "-x!*.pdb" "-x!Umbraco.Compat7.*" `
> $null
Write-Host "Zip WebPI"
&$uenv.Zip a -r "$out\UmbracoCms.WebPI.$($version.Semver).zip" "-x!*.pdb" `
"$tmp\WebPi\*" `
"-x!dotless.Core.*" "-x!Umbraco.Compat7.*" `
> $null
# hash the webpi file
Write-Host "Hash WebPI"
$hash = Get-FileHash "$out\UmbracoCms.WebPI.$($version.Semver).zip"
Write $hash | out-file "$out\webpihash.txt" -encoding ascii
}
#
# Prepares NuGet
#
function Prepare-NuGet
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
Write-Host ">> Prepare NuGet"
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$($uenv.SolutionRoot)\build.out"
# add Web.config transform files to the NuGet package
Write-Host "Add web.config transforms to NuGet package"
mv "$tmp\WebApp\Views\Web.config" "$tmp\WebApp\Views\Web.config.transform"
# fixme - that one does not exist in .bat build either?
#mv "$tmp\WebApp\Xslt\Web.config" "$tmp\WebApp\Xslt\Web.config.transform"
}
#
# Restores NuGet
#
function Restore-NuGet
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
Write-Host ">> Restore NuGet"
Write-Host "Logging to $tmp\nuget.restore.log"
&$uenv.NuGet restore "$src\Umbraco.sln" > "$tmp\nuget.restore.log"
}
#
# Creates the NuGet packages
#
function Package-NuGet
{
param (
$uenv, # an Umbraco build environment (see Get-UmbracoBuildEnv)
$version # an Umbraco version object (see Get-UmbracoVersion)
)
$src = "$($uenv.SolutionRoot)\src"
$tmp = "$($uenv.SolutionRoot)\build.tmp"
$out = "$($uenv.SolutionRoot)\build.out"
$nuspecs = "$($uenv.SolutionRoot)\build\NuSpecs"
Write-Host ">> Create NuGet packages"
# see https://docs.microsoft.com/en-us/nuget/schema/nuspec
# note - warnings about SqlCE native libs being outside of 'lib' folder,
# nothing much we can do about it as it's intentional yet there does not
# seem to be a way to disable the warning
&$uenv.NuGet Pack "$nuspecs\UmbracoCms.Core.nuspec" `
-Properties BuildTmp="$tmp" `
-Version $version.Semver.ToString() `
-Symbols -Verbosity quiet -outputDirectory $out
&$uenv.NuGet Pack "$nuspecs\UmbracoCms.nuspec" `
-Properties BuildTmp="$tmp" `
-Version $version.Semver.ToString() `
-Verbosity quiet -outputDirectory $out
&$uenv.NuGet Pack "$nuspecs\UmbracoCms.Compat7.nuspec" `
-Properties BuildTmp="$tmp" `
-Version $version.Semver.ToString() `
-Verbosity quiet -outputDirectory $out
$hook = "$($uenv.SolutionRoot)\build\hooks\Post-Package-NuGet.ps1"
if (Test-Path -Path $hook)
{
. "$hook"
Post-Package-NuGet $uenv $version
}
}
#
# Builds Umbraco
#
function Build-Umbraco
{
[CmdletBinding()]
param (
[string]
$target = "all",
[string]
$buildConfiguration = "Release"
)
$target = $target.ToLowerInvariant()
Write-Host ">> Build-Umbraco <$target> <$buildConfiguration>"
Write-Host "Get Build Environment"
$uenv = Get-UmbracoBuildEnv
Write-Host "Get Version"
$version = Get-UmbracoVersion
Write-Host "Version $($version.Semver)"
if ($target -eq "pre-build")
{
Prepare-Build $uenv
#Compile-Belle $uenv $version
# set environment variables
$env:UMBRACO_VERSION=$version.Semver.ToString()
$env:UMBRACO_RELEASE=$version.Release
$env:UMBRACO_COMMENT=$version.Comment
$env:UMBRACO_BUILD=$version.Build
# 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;]$($version.Semver.ToString())")
Write-Host ("##vso[task.setvariable variable=UMBRACO_RELEASE;]$($version.Release)")
Write-Host ("##vso[task.setvariable variable=UMBRACO_COMMENT;]$($version.Comment)")
Write-Host ("##vso[task.setvariable variable=UMBRACO_BUILD;]$($version.Build)")
Write-Host ("##vso[task.setvariable variable=UMBRACO_TMP;]$($uenv.SolutionRoot)\build.tmp")
}
elseif ($target -eq "pre-tests")
{
Prepare-Tests $uenv
}
elseif ($target -eq "compile-tests")
{
Compile-Tests $uenv
}
elseif ($target -eq "compile-umbraco")
{
Compile-Umbraco $uenv $buildConfiguration
}
elseif ($target -eq "pre-packages")
{
Prepare-Packages $uenv
}
elseif ($target -eq "pre-nuget")
{
Prepare-NuGet $uenv
}
elseif ($target -eq "Restore-NuGet" -or $target -eq "restore-nuget")
{
Restore-NuGet $uenv
}
elseif ($target -eq "Package-Zip" -eq $target -eq "pkg-zip")
{
Package-Zip $uenv
}
elseif ($target -eq "Package-NuGet" -eq $target -eq "pkg-nuget")
{
Package-NuGet $uenv $version
}
elseif ($target -eq "compile-belle")
{
Compile-Belle $uenv $version
}
elseif ($target -eq "all")
{
Prepare-Build $uenv
Restore-NuGet $uenv
Compile-Belle $uenv $version
Compile-Umbraco $uenv $buildConfiguration
Prepare-Tests $uenv
Compile-Tests $uenv
# not running tests...
Prepare-Packages $uenv
Package-Zip $uenv
Verify-NuGet $uenv
Prepare-NuGet $uenv
Package-NuGet $uenv $version
}
else
{
Write-Error "Unsupported target `"$target`"."
}
}
#
# export functions
#
Export-ModuleMember -function Get-UmbracoBuildEnv
Export-ModuleMember -function Set-UmbracoVersion
Export-ModuleMember -function Get-UmbracoVersion
Export-ModuleMember -function Build-Umbraco
Export-ModuleMember -function Build-UmbracoDocs
Export-ModuleMember -function Verify-NuGet
#eof

View File

@@ -1,120 +0,0 @@
# returns a string containing the hash of $file
function Get-FileHash($file)
{
try
{
$crypto = new-object System.Security.Cryptography.SHA1CryptoServiceProvider
$stream = [System.IO.File]::OpenRead($file)
$hash = $crypto.ComputeHash($stream)
$text = ""
$hash | foreach `
{
$text = $text + $_.ToString("x2")
}
return $text
}
finally
{
if ($stream)
{
$stream.Dispose()
}
$crypto.Dispose()
}
}
# returns the full path if $file is relative to $pwd
function Get-FullPath($file)
{
$path = [System.IO.Path]::Combine($pwd, $file)
$path = [System.IO.Path]::GetFullPath($path)
return $path
}
# removes a directory, doesn't complain if it does not exist
function Remove-Directory($dir)
{
remove-item $dir -force -recurse -errorAction SilentlyContinue > $null
}
# removes a file, doesn't complain if it does not exist
function Remove-File($file)
{
remove-item $file -force -errorAction SilentlyContinue > $null
}
# copies a file, creates target dir if needed
function Copy-File($source, $target)
{
$ignore = new-item -itemType file -path $target -force
cp -force $source $target
}
# copies files to a directory
function Copy-Files($source, $select, $target, $filter)
{
$files = ls -r "$source\$select"
$files | foreach {
$relative = $_.FullName.SubString($source.Length+1)
$_ | add-member -memberType NoteProperty -name RelativeName -value $relative
}
if ($filter -ne $null) {
$files = $files | where $filter
}
$files |
foreach {
if ($_.PsIsContainer) {
$ignore = new-item -itemType directory -path "$target\$($_.RelativeName)" -force
}
else {
Copy-File $_.FullName "$target\$($_.RelativeName)"
}
}
}
# regex-replaces content in a file
function Replace-FileText($filename, $source, $replacement)
{
$filepath = Get-FullPath $filename
$text = [System.IO.File]::ReadAllText($filepath)
$text = [System.Text.RegularExpressions.Regex]::Replace($text, $source, $replacement)
$utf8bom = New-Object System.Text.UTF8Encoding $true
[System.IO.File]::WriteAllText($filepath, $text, $utf8bom)
}
# store web.config
function Store-WebConfig($webUi)
{
if (test-path "$webUi\web.config")
{
if (test-path "$webUi\web.config.temp-build")
{
Write-Host "Found existing web.config.temp-build"
$i = 0
while (test-path "$webUi\web.config.temp-build.$i")
{
$i = $i + 1
}
Write-Host "Save existing web.config as web.config.temp-build.$i"
Write-Host "(WARN: the original web.config.temp-build will be restored during post-build)"
mv "$webUi\web.config" "$webUi\web.config.temp-build.$i"
}
else
{
Write-Host "Save existing web.config as web.config.temp-build"
Write-Host "(will be restored during post-build)"
mv "$webUi\web.config" "$webUi\web.config.temp-build"
}
}
}
# restore web.config
function Restore-WebConfig($webUi)
{
if (test-path "$webUi\web.config.temp-build")
{
Write-Host "Restoring existing web.config"
Remove-File "$webUi\web.config"
mv "$webUi\web.config.temp-build" "$webUi\web.config"
}
}

View File

@@ -1,446 +0,0 @@
#
# Verify-NuGet
#
function Format-Dependency
{
param ( $d )
$m = $d.Id + " "
if ($d.MinInclude) { $m = $m + "[" }
else { $m = $m + "(" }
$m = $m + $d.MinVersion
if ($d.MaxVersion -ne $d.MinVersion) { $m = $m + "," + $d.MaxVersion }
if ($d.MaxInclude) { $m = $m + "]" }
else { $m = $m + ")" }
return $m
}
function Write-NuSpec
{
param ( $name, $deps )
Write-Host ""
Write-Host "$name NuSpec dependencies:"
foreach ($d in $deps)
{
$m = Format-Dependency $d
Write-Host " $m"
}
}
function Write-Package
{
param ( $name, $pkgs )
Write-Host ""
Write-Host "$name packages:"
foreach ($p in $pkgs)
{
Write-Host " $($p.Id) $($p.Version)"
}
}
function Verify-NuGet
{
param (
$uenv # an Umbraco build environment (see Get-UmbracoBuildEnv)
)
if ($uenv -eq $null)
{
$uenv = Get-UmbracoBuildEnv
}
$source = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using Semver;
namespace Umbraco.Build
{
public class NuGet
{
public static Dependency[] GetNuSpecDependencies(string filename)
{
NuSpec nuspec;
var serializer = new XmlSerializer(typeof(NuSpec));
using (var reader = new StreamReader(filename))
{
nuspec = (NuSpec) serializer.Deserialize(reader);
}
var nudeps = nuspec.Metadata.Dependencies;
var deps = new List<Dependency>();
foreach (var nudep in nudeps)
{
var dep = new Dependency();
dep.Id = nudep.Id;
var parts = nudep.Version.Split(',');
if (parts.Length == 1)
{
dep.MinInclude = parts[0].StartsWith("[");
dep.MaxInclude = parts[0].EndsWith("]");
SemVersion version;
if (!SemVersion.TryParse(parts[0].Substring(1, parts[0].Length-2).Trim(), out version)) continue;
dep.MinVersion = dep.MaxVersion = version; //parts[0].Substring(1, parts[0].Length-2).Trim();
}
else
{
SemVersion version;
if (!SemVersion.TryParse(parts[0].Substring(1).Trim(), out version)) continue;
dep.MinVersion = version; //parts[0].Substring(1).Trim();
if (!SemVersion.TryParse(parts[1].Substring(0, parts[1].Length-1).Trim(), out version)) continue;
dep.MaxVersion = version; //parts[1].Substring(0, parts[1].Length-1).Trim();
dep.MinInclude = parts[0].StartsWith("[");
dep.MaxInclude = parts[1].EndsWith("]");
}
deps.Add(dep);
}
return deps.ToArray();
}
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(/*this*/ IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> knownKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (knownKeys.Add(keySelector(element)))
{
yield return element;
}
}
}
public static Package[] GetProjectsPackages(string src, string[] projects)
{
var l = new List<Package>();
foreach (var project in projects)
{
var path = Path.Combine(src, project);
var packageConfig = Path.Combine(path, "packages.config");
if (File.Exists(packageConfig))
ReadPackagesConfig(packageConfig, l);
var csprojs = Directory.GetFiles(path, "*.csproj");
foreach (var csproj in csprojs)
{
ReadCsProj(csproj, l);
}
}
IEnumerable<Package> p = l.OrderBy(x => x.Id);
p = DistinctBy(p, x => x.Id + ":::" + x.Version);
return p.ToArray();
}
public static object[] GetPackageErrors(Package[] pkgs)
{
return pkgs
.GroupBy(x => x.Id)
.Where(x => x.Count() > 1)
.ToArray();
}
public static object[] GetNuSpecErrors(Package[] pkgs, Dependency[] deps)
{
var d = pkgs.ToDictionary(x => x.Id, x => x.Version);
return deps
.Select(x =>
{
SemVersion v;
if (!d.TryGetValue(x.Id, out v)) return null;
var ok = true;
/*
if (x.MinInclude)
{
if (v < x.MinVersion) ok = false;
}
else
{
if (v <= x.MinVersion) ok = false;
}
if (x.MaxInclude)
{
if (v > x.MaxVersion) ok = false;
}
else
{
if (v >= x.MaxVersion) ok = false;
}
*/
if (!x.MinInclude || v != x.MinVersion) ok = false;
return ok ? null : new { Dependency = x, Version = v };
})
.Where(x => x != null)
.ToArray();
}
/*
public static Package[] GetProjectPackages(string path)
{
var l = new List<Package>();
var packageConfig = Path.Combine(path, "packages.config");
if (File.Exists(packageConfig))
ReadPackagesConfig(packageConfig, l);
var csprojs = Directory.GetFiles(path, "*.csproj");
foreach (var csproj in csprojs)
{
ReadCsProj(csproj, l);
}
return l.ToArray();
}
*/
public static string GetDirectoryName(string filename)
{
return Path.GetFileName(Path.GetDirectoryName(filename));
}
public static void ReadPackagesConfig(string filename, List<Package> packages)
{
//Console.WriteLine("read " + filename);
PackagesConfigPackages pkgs;
var serializer = new XmlSerializer(typeof(PackagesConfigPackages));
using (var reader = new StreamReader(filename))
{
pkgs = (PackagesConfigPackages) serializer.Deserialize(reader);
}
foreach (var p in pkgs.Packages)
{
SemVersion version;
if (!SemVersion.TryParse(p.Version, out version)) continue;
packages.Add(new Package { Id = p.Id, Version = version, Project = GetDirectoryName(filename) });
}
}
public static void ReadCsProj(string filename, List<Package> packages)
{
//Console.WriteLine("read " + filename);
// if xmlns then it's not a VS2017 with PackageReference
var text = File.ReadAllLines(filename);
var line = text.FirstOrDefault(x => x.Contains("<Project"));
if (line == null) return;
if (line.Contains("xmlns")) return;
CsProjProject proj;
var serializer = new XmlSerializer(typeof(CsProjProject));
using (var reader = new StreamReader(filename))
{
proj = (CsProjProject) serializer.Deserialize(reader);
}
foreach (var p in proj.ItemGroups.Where(x => x.Packages != null).SelectMany(x => x.Packages))
{
var sversion = p.VersionE ?? p.VersionA;
SemVersion version;
if (!SemVersion.TryParse(sversion, out version)) continue;
packages.Add(new Package { Id = p.Id, Version = version, Project = GetDirectoryName(filename) });
}
}
public class Dependency
{
public string Id { get; set; }
public SemVersion MinVersion { get; set; }
public SemVersion MaxVersion { get; set; }
public bool MinInclude { get; set; }
public bool MaxInclude { get; set; }
}
public class Package
{
public string Id { get; set; }
public SemVersion Version { get; set; }
public string Project { get; set; }
}
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd")]
[XmlRoot(Namespace = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd", IsNullable = false, ElementName = "package")]
public class NuSpec
{
[XmlElement("metadata")]
public NuSpecMetadata Metadata { get; set; }
}
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd", TypeName = "metadata")]
public class NuSpecMetadata
{
[XmlArray("dependencies")]
[XmlArrayItem("dependency", IsNullable = false)]
public NuSpecDependency[] Dependencies { get; set; }
}
[XmlType(AnonymousType = true, Namespace = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd", TypeName = "dependencies")]
public class NuSpecDependency
{
[XmlAttribute(AttributeName = "id")]
public string Id { get; set; }
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }
}
[XmlType(AnonymousType = true)]
[XmlRoot(Namespace = "", IsNullable = false, ElementName = "packages")]
public class PackagesConfigPackages
{
[XmlElement("package")]
public PackagesConfigPackage[] Packages { get; set; }
}
[XmlType(AnonymousType = true, TypeName = "package")]
public class PackagesConfigPackage
{
[XmlAttribute(AttributeName = "id")]
public string Id { get; set; }
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }
}
[XmlType(AnonymousType = true)]
[XmlRoot(Namespace = "", IsNullable = false, ElementName = "Project")]
public class CsProjProject
{
[XmlElement("ItemGroup")]
public CsProjItemGroup[] ItemGroups { get; set; }
}
[XmlType(AnonymousType = true, TypeName = "ItemGroup")]
public class CsProjItemGroup
{
[XmlElement("PackageReference")]
public CsProjPackageReference[] Packages { get; set; }
}
[XmlType(AnonymousType = true, TypeName = "PackageReference")]
public class CsProjPackageReference
{
[XmlAttribute(AttributeName = "Include")]
public string Id { get; set; }
[XmlAttribute(AttributeName = "Version")]
public string VersionA { get; set; }
[XmlElement("Version")]
public string VersionE { get; set;}
}
}
}
"@
Write-Host ">> Verify NuGet consistency"
$assem = (
"System.Xml",
"System.Core", # "System.Collections.Generic"
"System.Linq",
"System.Xml.Serialization",
"System.IO",
"System.Globalization",
$uenv.Semver
)
try
{
# as long as the code hasn't changed it's fine to re-add, but if the code
# has changed this will throw - better warn the dev that we have an issue
add-type -referencedAssemblies $assem -typeDefinition $source -language CSharp
}
catch
{
if ($_.FullyQualifiedErrorId.StartsWith("TYPE_ALREADY_EXISTS,"))
{ Write-Error "Failed to add type, did you change the code?" }
else
{ Write-Error $_ }
}
if (-not $?) { break }
$nuspecs = (
"UmbracoCms",
"UmbracoCms.Core",
"UmbracoCms.Compat7"
)
$projects = (
"Umbraco.Core",
"Umbraco.Web",
"Umbraco.Web.UI",
"Umbraco.Examine",
"Umbraco.Compat7"#,
#"Umbraco.Tests",
#"Umbraco.Tests.Benchmarks"
)
$src = "$($uenv.SolutionRoot)\src"
$pkgs = [Umbraco.Build.NuGet]::GetProjectsPackages($src, $projects)
if (-not $?) { break }
#Write-Package "All" $pkgs
$errs = [Umbraco.Build.NuGet]::GetPackageErrors($pkgs)
if (-not $?) { break }
if ($errs.Length -gt 0)
{
Write-Host ""
}
foreach ($err in $errs)
{
Write-Host $err.Key
foreach ($e in $err)
{
Write-Host " $($e.Version) required by $($e.Project)"
}
}
if ($errs.Length -gt 0)
{
Write-Error "Found non-consolidated package dependencies"
break
}
$nuerr = $false
$nupath = "$($uenv.SolutionRoot)\build\NuSpecs"
foreach ($nuspec in $nuspecs)
{
$deps = [Umbraco.Build.NuGet]::GetNuSpecDependencies("$nupath\$nuspec.nuspec")
if (-not $?) { break }
#Write-NuSpec $nuspec $deps
$errs = [Umbraco.Build.NuGet]::GetNuSpecErrors($pkgs, $deps)
if (-not $?) { break }
if ($errs.Length -gt 0)
{
Write-Host ""
Write-Host "$nuspec requires:"
$nuerr = $true
}
foreach ($err in $errs)
{
$m = Format-Dependency $err.Dependency
Write-Host " $m but projects require $($err.Version)"
}
}
if ($nuerr)
{
Write-Error "Found inconsistent NuGet dependencies"
break
}
}

View File

@@ -1,67 +1,495 @@
param (
param (
# load but don't execute
[Parameter(Mandatory=$false)]
[string]
$version,
[Alias("n")]
[switch] $nop = $false,
# run local - don't download, assume everything is ready
[Parameter(Mandatory=$false)]
[Alias("mo")]
[switch]
$moduleOnly = $false
)
[Alias("l")]
[Alias("loc")]
[switch] $local = $false,
# the script can run either from the solution root,
# or from the ./build directory - anything else fails
if ([System.IO.Path]::GetFileName($pwd) -eq "build")
{
$mpath = [System.IO.Path]::GetDirectoryName($pwd) + "\build\Modules\"
}
else
{
$mpath = "$pwd\build\Modules\"
}
# keep the build directories, don't clear them
[Parameter(Mandatory=$false)]
[Alias("k")]
[Alias("keep")]
[switch] $keepBuildDirs = $false
)
# look for the module and throw if not found
if (-not [System.IO.Directory]::Exists($mpath + "Umbraco.Build"))
{
Write-Error "Could not locate Umbraco build Powershell module."
break
}
Write-Host "Umbraco.Cms Build"
# add the module path (if not already there)
if (-not $env:PSModulePath.Contains($mpath))
{
$env:PSModulePath = "$mpath;$env:PSModulePath"
}
# ################################################################
# BOOTSTRAP
# ################################################################
# force-import (or re-import) the module
Write-Host "Import Umbraco build Powershell module"
Import-Module Umbraco.Build -Force -DisableNameChecking
# ensure we have temp folder for downloads
$scriptRoot = "$PSScriptRoot"
$scriptTemp = "$scriptRoot\temp"
if (-not (test-path $scriptTemp)) { mkdir $scriptTemp > $null }
# module only?
if ($moduleOnly)
{
if (-not [string]::IsNullOrWhiteSpace($version))
# get NuGet
$cache = 4
$nuget = "$scriptTemp\nuget.exe"
if (-not $local)
{
Write-Host "(module only: ignoring version parameter)"
$source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
if ((test-path $nuget) -and ((ls $nuget).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-Item $nuget -force -errorAction SilentlyContinue > $null
}
if (-not (test-path $nuget))
{
Write-Host "Download NuGet..."
Invoke-WebRequest $source -OutFile $nuget
if (-not $?) { throw "Failed to download NuGet." }
}
}
else
elseif (-not (test-path $nuget))
{
Write-Host "(module only)"
throw "Failed to locate NuGet.exe."
}
break
}
# get build environment
Write-Host "Setup Umbraco build Environment"
$uenv = Get-UmbracoBuildEnv
# get the build system
if (-not $local)
{
$solutionRoot = "$scriptRoot\.."
$nugetConfig = @{$true="$solutionRoot\src\NuGet.config.user";$false="$solutionRoot\src\NuGet.config"}[(test-path "$solutionRoot\src\NuGet.config.user")]
&$nuget install Umbraco.Build -OutputDirectory $scriptTemp -Verbosity quiet -PreRelease -ConfigFile $nugetConfig
if (-not $?) { throw "Failed to download Umbraco.Build." }
}
# set the version if any
if (-not [string]::IsNullOrWhiteSpace($version))
{
Write-Host "Set Umbraco version to $version"
Set-UmbracoVersion $version
}
# ensure we have the build system
$ubuildPath = ls "$scriptTemp\Umbraco.Build.*" | sort -property CreationTime -descending | select -first 1
if (-not $ubuildPath)
{
throw "Failed to locate the build system."
}
# full umbraco build
Write-Host "Build Umbraco"
Build-Umbraco
# boot the build system
# this creates $global:ubuild
&"$ubuildPath\ps\Boot.ps1"
$ubuild.Boot($ubuildPath.FullName, [System.IO.Path]::GetFullPath("$scriptRoot\.."),
@{ Local = $local; },
@{ KeepBuildDirs = $keepBuildDirs })
if (-not $?) { throw "Failed to boot the build system." }
Write-Host "Umbraco.Build v$($ubuild.BuildVersion)"
# ################################################################
# TASKS
# ################################################################
$ubuild | Add-Member -MemberType ScriptMethod SetMoreUmbracoVersion -value `
{
param ( $semver )
$release = "" + $semver.Major + "." + $semver.Minor + "." + $semver.Patch
Write-Host "Update UmbracoVersion.cs"
$this.ReplaceFileText("$($this.SolutionRoot)\src\Umbraco.Core\Configuration\UmbracoVersion.cs", `
"(\d+)\.(\d+)\.(\d+)(.(\d+))?", `
"$release")
$this.ReplaceFileText("$($this.SolutionRoot)\src\Umbraco.Core\Configuration\UmbracoVersion.cs", `
"CurrentComment => `"(.+)`"", `
"CurrentComment => `"$($semver.PreRelease)`"")
Write-Host "Update IIS Express port in csproj"
$updater = New-Object "Umbraco.Build.ExpressPortUpdater"
$csproj = "$($this.SolutionRoot)\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj"
$updater.Update($csproj, $release)
}
$ubuild | Add-Member -MemberType ScriptMethod SandboxNode -value `
{
$global:node_path = $env:path
$nodePath = $this.BuildEnv.NodePath
$gitExe = (Get-Command git).Source
$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")
}
$ubuild | Add-Member -MemberType ScriptMethod RestoreNode -value `
{
$env:path = $node_path
$this.SetEnvVar("NODEPATH", $node_nodepath)
$this.SetEnvVar("NPM_CONFIG_CACHE", $node_npmcache)
$this.SetEnvVar("NPM_CONFIG_PREFIX", $node_npmprefix)
}
$ubuild | Add-Member -MemberType ScriptMethod CompileBelle -value `
{
$src = "$($this.SolutionRoot)\src"
$log = "$($this.BuildTemp)\belle.log"
Write-Host "Compile Belle"
Write-Host "Logging to $log"
# get a temp clean node env (will restore)
$this.SandboxNode()
Push-Location "$($uenv.SolutionRoot)\src\Umbraco.Web.UI.Client"
Write-Output "" > $log
Write-Output "node version is:" > $log
&node -v >> $log 2>&1
Write-Output "npm version is:" >> $log 2>&1
&npm -v >> $log 2>&1
Write-Output "clean npm cache" >> $log 2>&1
&npm cache clean >> $log 2>&1
Write-Output "npm install" >> $log 2>&1
&npm install >> $log 2>&1
Write-Output "install bower" >> $log 2>&1
&npm install -g bower >> $log 2>&1
Write-Output "install gulp" >> $log 2>&1
&npm install -g gulp >> $log 2>&1
Write-Output "install gulp-cli" >> $log 2>&1
&npm install -g gulp-cli --quiet >> $log 2>&1
Write-Output "gulp build for version $($this.Version.Release)" >> $log 2>&1
&gulp build --buildversion=$this.Version.Release >> $log 2>&1
Pop-Location
# fixme - should we filter the log to find errors?
#get-content .\build.tmp\belle.log | %{ if ($_ -match "build") { write $_}}
# restore
$this.RestoreNode()
# 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)
}
$ubuild | Add-Member -MemberType ScriptMethod CompileUmbraco -value `
{
$buildConfiguration = "Release"
$src = "$($this.SolutionRoot)\src"
$log = "$($this.BuildTemp)\msbuild.umbraco.log"
$log7 = "$($this.BuildTemp)\msbuild.compat7.log"
if ($this.BuildEnv.VisualStudio -eq $null)
{
throw "Build environment does not provide VisualStudio."
}
Write-Host "Compile Umbraco"
Write-Host "Logging to $log"
# 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 "$src\Umbraco.Web.UI\Umbraco.Web.UI.csproj" `
/p:WarningLevel=0 `
/p:Configuration=$buildConfiguration `
/p:Platform=AnyCPU `
/p:UseWPP_CopyWebApplication=True `
/p:PipelineDependsOnBuild=False `
/p:OutDir="$($this.BuildTemp)\bin\\" `
/p:WebProjectOutputDir="$($this.BuildTemp)\WebApp\\" `
/p:Verbosity=minimal `
/t:Clean`;Rebuild `
/tv:"$($ubuild.BuildEnv.VisualStudio.ToolsVersion)" `
/p:UmbracoBuild=True `
> $log
if (-not $?) { throw "Failed to compile Umbraco.Web.UI." }
Write-Host "Logging to $log7"
&$this.BuildEnv.VisualStudio.MsBuild "$src\Umbraco.Compat7\Umbraco.Compat7.csproj" `
/p:WarningLevel=0 `
/p:Configuration=$buildConfiguration `
/p:Platform=AnyCPU `
/p:UseWPP_CopyWebApplication=True `
/p:PipelineDependsOnBuild=False `
/p:OutDir="$($this.BuildTemp)\bin\\" `
/p:WebProjectOutputDir="$($this.BuildTemp)\WebApp\\" `
/p:Verbosity=minimal `
/t:Rebuild `
/tv:"$($ubuild.BuildEnv.VisualStudio.ToolsVersion)" `
/p:UmbracoBuild=True `
> $log7
if (-not $?) { throw "Failed to compile Umbraco.Compat7." }
# /p:UmbracoBuild tells the csproj that we are building from PS, not VS
}
$ubuild | Add-Member -MemberType ScriptMethod PrepareTests -value `
{
Write-Host "Prepare Tests"
# fixme - idea is to avoid rebuilding everything for tests
# but because of our weird assembly versioning (with .* stuff)
# everything gets rebuilt all the time...
#Copy-Files "$tmp\bin" "." "$tmp\tests"
# 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
}
$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Tests\Packaging\Packages", "*", "$($this.BuildTemp)\tests\Packaging\Packages")
# required for package install tests
if (-not (Test-Path -Path "$($this.BuildTemp)\tests\bin" ))
{
Write-Host "Create bin directory"
mkdir "$($this.BuildTemp)\tests\bin" > $null
}
}
$ubuild | Add-Member -MemberType ScriptMethod CompileTests -value `
{
$buildConfiguration = "Release"
$log = "$($this.BuildTemp)\msbuild.tests.log"
if ($this.BuildEnv.VisualStudio -eq $null)
{
throw "Build environment does not provide VisualStudio."
}
Write-Host "Compile Tests"
Write-Host "Logging to $log"
# 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 `
/tv:"$($ubuild.BuildEnv.VisualStudio.ToolsVersion)" `
/p:UmbracoBuild=True `
/p:NugetPackages="$($this.SolutionRoot)\src\packages" `
> $log
if (-not $?) { throw "Failed to compile tests." }
# /p:UmbracoBuild tells the csproj that we are building from PS
}
$ubuild | Add-Member -MemberType ScriptMethod PreparePackages -value `
{
Write-Host "Prepare Packages"
$src = "$($this.SolutionRoot)\src"
$tmp = "$($this.BuildTemp)"
$out = "$($this.BuildOutput)"
$buildConfiguration = "Release"
# restore web.config
$this.TempRestoreFile("$src\Umbraco.Web.UI\web.config")
# cleanup build
Write-Host "Clean build"
$this.RemoveFile("$tmp\bin\*.dll.config")
$this.RemoveFile("$tmp\WebApp\bin\*.dll.config")
# cleanup presentation
Write-Host "Cleanup presentation"
$this.RemoveDirectory("$tmp\WebApp\umbraco.presentation")
# create directories
Write-Host "Create directories"
mkdir "$tmp\Configs" > $null
mkdir "$tmp\Configs\Lang" > $null
mkdir "$tmp\WebApp\App_Data" > $null
#mkdir "$tmp\WebApp\Media" > $null
#mkdir "$tmp\WebApp\Views" > $null
# copy various files
Write-Host "Copy xml documentation"
Copy-Item -force "$tmp\bin\*.xml" "$tmp\WebApp\bin"
Write-Host "Copy transformed configs and langs"
# note: exclude imageprocessor/*.config as imageprocessor pkg installs them
$this.CopyFiles("$tmp\WebApp\config", "*.config", "$tmp\Configs", `
{ -not $_.RelativeName.StartsWith("imageprocessor") })
$this.CopyFiles("$tmp\WebApp\config", "*.js", "$tmp\Configs")
$this.CopyFiles("$tmp\WebApp\config\lang", "*.xml", "$tmp\Configs\Lang")
$this.CopyFile("$tmp\WebApp\web.config", "$tmp\Configs\web.config.transform")
Write-Host "Copy transformed web.config"
$this.CopyFile("$src\Umbraco.Web.UI\web.$buildConfiguration.Config.transformed", "$tmp\WebApp\web.config")
# 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)
}
# copy libs
Write-Host "Copy SqlCE libraries"
$this.CopyFiles("$src\packages\SqlServerCE.4.0.0.1", "*.*", "$tmp\bin", `
{ -not $_.Extension.StartsWith(".nu") -and -not $_.RelativeName.StartsWith("lib\") })
$this.CopyFiles("$src\packages\SqlServerCE.4.0.0.1", "*.*", "$tmp\WebApp\bin", `
{ -not $_.Extension.StartsWith(".nu") -and -not $_.RelativeName.StartsWith("lib\") })
# copy Belle
Write-Host "Copy Belle"
$this.CopyFiles("$src\Umbraco.Web.UI\umbraco\assets", "*", "$tmp\WebApp\umbraco\assets")
$this.CopyFiles("$src\Umbraco.Web.UI\umbraco\js", "*", "$tmp\WebApp\umbraco\js")
$this.CopyFiles("$src\Umbraco.Web.UI\umbraco\lib", "*", "$tmp\WebApp\umbraco\lib")
$this.CopyFiles("$src\Umbraco.Web.UI\umbraco\views", "*", "$tmp\WebApp\umbraco\views")
$this.CopyFiles("$src\Umbraco.Web.UI\umbraco\preview", "*", "$tmp\WebApp\umbraco\preview")
# prepare WebPI
Write-Host "Prepare WebPI"
$this.RemoveDirectory("$tmp\WebPi")
mkdir "$tmp\WebPi" > $null
mkdir "$tmp\WebPi\umbraco" > $null
$this.CopyFiles("$tmp\WebApp", "*", "$tmp\WebPi\umbraco")
$this.CopyFiles("$src\WebPi", "*", "$tmp\WebPi")
}
$ubuild | Add-Member -MemberType ScriptMethod PackageZip -value `
{
Write-Host "Create Zip packages"
$src = "$($this.SolutionRoot)\src"
$tmp = $this.BuildTemp
$out = $this.BuildOutput
Write-Host "Zip all binaries"
&$this.BuildEnv.Zip a -r "$out\UmbracoCms.AllBinaries.$($this.Version.Semver).zip" `
"$tmp\bin\*" `
"-x!dotless.Core.*" "-x!Umbraco.Compat7.*" `
> $null
if (-not $?) { throw "Failed to zip UmbracoCms.AllBinaries." }
Write-Host "Zip cms"
&$this.BuildEnv.Zip a -r "$out\UmbracoCms.$($this.Version.Semver).zip" `
"$tmp\WebApp\*" `
"-x!dotless.Core.*" "-x!Content_Types.xml" "-x!*.pdb" "-x!Umbraco.Compat7.*" `
> $null
if (-not $?) { throw "Failed to zip UmbracoCms." }
Write-Host "Zip WebPI"
&$this.BuildEnv.Zip a -r "$out\UmbracoCms.WebPI.$($this.Version.Semver).zip" "-x!*.pdb" `
"$tmp\WebPi\*" `
"-x!dotless.Core.*" "-x!Umbraco.Compat7.*" `
> $null
if (-not $?) { throw "Failed to zip UmbracoCms.WebPI." }
# hash the webpi file
Write-Host "Hash WebPI"
$hash = $this.GetFileHash("$out\UmbracoCms.WebPI.$($this.Version.Semver).zip")
Write-Output $hash | out-file "$out\webpihash.txt" -encoding ascii
}
$ubuild | Add-Member -MemberType ScriptMethod PrepareBuild -value `
{
Write-Host "Clear folders and files"
$this.RemoveDirectory("$($this.SolutionRoot)\src\Umbraco.Web.UI.Client\bower_components")
$this.TempStoreFile("$($this.SolutionRoot)\src\Umbraco.Web.UI\web.config")
Write-Host "Create clean web.config"
$this.CopyFile("$($this.SolutionRoot)\src\Umbraco.Web.UI\web.Template.config", "$($this.SolutionRoot)\src\Umbraco.Web.UI\web.config")
}
$ubuild | Add-Member -MemberType ScriptMethod PrepareNuGet -value `
{
Write-Host "Prepare NuGet"
# add Web.config transform files to the NuGet package
Write-Host "Add web.config transforms to NuGet package"
mv "$($this.BuildTemp)\WebApp\Views\Web.config" "$($this.BuildTemp)\WebApp\Views\Web.config.transform"
# fixme - that one does not exist in .bat build either?
#mv "$($this.BuildTemp)\WebApp\Xslt\Web.config" "$($this.BuildTemp)\WebApp\Xslt\Web.config.transform"
}
$ubuild | Add-Member -MemberType ScriptMethod RestoreNuGet -value `
{
Write-Host "Restore NuGet"
Write-Host "Logging to $($this.BuildTemp)\nuget.restore.log"
&$this.BuildEnv.NuGet restore "$($this.SolutionRoot)\src\Umbraco.sln" -ConfigFile $this.BuildEnv.NuGetConfig > "$($this.BuildTemp)\nuget.restore.log"
if (-not $?) { throw "Failed to restore NuGet packages." }
}
$ubuild | Add-Member -MemberType ScriptMethod PackageNuGet -value `
{
$nuspecs = "$($this.SolutionRoot)\build\NuSpecs"
Write-Host "Create NuGet packages"
# see https://docs.microsoft.com/en-us/nuget/schema/nuspec
# note - warnings about SqlCE native libs being outside of 'lib' folder,
# nothing much we can do about it as it's intentional yet there does not
# seem to be a way to disable the warning
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Core.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version "$($this.Version.Semver.ToString())" `
-Symbols -Verbosity quiet -outputDirectory "$($this.BuildOutput)"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Core." }
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version $this.Version.Semver.ToString() `
-Verbosity quiet -outputDirectory "$($this.BuildOutput)"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms." }
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Compat7.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version $this.Version.Semver.ToString() `
-Verbosity quiet -outputDirectory "$($this.BuildOutput)"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Compat7." }
# run hook
if ($this.HasMethod("PostPackageNuGet"))
{
Write-Host "Run PostPackageNuGet hook"
$this.PostPackageNuGet();
if (-not $?) { throw "Failed to run hook." }
}
}
$ubuild | Add-Member -MemberType ScriptMethod Build -value `
{
$this.PrepareBuild()
$this.RestoreNuGet()
$this.CompileBelle()
$this.CompileUmbraco()
$this.PrepareTests()
$this.CompileTests()
# not running tests
$this.PreparePackages()
$this.PackageZip()
$this.VerifyNuGet(
("UmbracoCms", "UmbracoCms.Core", "UmbracoCms.Compat7"),
("Umbraco.Core", "Umbraco.Web", "Umbraco.Web.UI", "Umbraco.Examine", "Umbraco.Compat7"))
$this.PrepareNuGet()
$this.PackageNuGet()
}
# ################################################################
# RUN
# ################################################################
# configure
$ubuild.ReleaseBranches = @( "master" )
# run
if (-not $nop) { $ubuild.Build() }
Write-Host "Done"
if ($nop) { return $ubuild }

View File

@@ -1,17 +0,0 @@
# Usage: powershell .\setversion.ps1 7.6.8
# Or: powershell .\setversion 7.6.8-beta001
param (
[Parameter(Mandatory=$true)]
[string]
$version
)
# report
Write-Host "Setting Umbraco version to $version"
# import Umbraco Build PowerShell module - $pwd is ./build
./build.ps1 -mo
# run commands
$version = Set-UmbracoVersion -Version $version

View File

@@ -17,4 +17,4 @@ using System.Resources;
// these are FYI and changed automatically
[assembly: AssemblyFileVersion("8.0.0")]
[assembly: AssemblyInformationalVersion("8.0.0-alpha.26")]
[assembly: AssemblyInformationalVersion("8.0.0-alpha.27")]

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Core.Configuration
/// <summary>
/// Gets the version comment of the executing code (eg "beta").
/// </summary>
public static string CurrentComment => "alpha.26";
public static string CurrentComment => "alpha.27";
/// <summary>
/// Gets the assembly version of Umbraco.Code.dll.

View File

@@ -1,12 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
VisualStudioVersion = 15.0.27004.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.UI", "Umbraco.Web.UI\Umbraco.Web.UI.csproj", "{4C4C194C-B5E4-4991-8F87-4373E24CC19F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2849E9D4-3B4E-40A3-A309-F3CB4F0E125F}"
ProjectSection(SolutionItems) = preProject
..\build\build.md = ..\build\build.md
..\build\build.ps1 = ..\build\build.ps1
..\build\BuildDocs.ps1 = ..\build\BuildDocs.ps1
..\build\RevertToCleanInstall.bat = ..\build\RevertToCleanInstall.bat
..\build\RevertToEmptyInstall.bat = ..\build\RevertToEmptyInstall.bat
@@ -148,4 +149,7 @@ Global
{460C4687-9209-4100-AAB0-82867B592FDC} = {2849E9D4-3B4E-40A3-A309-F3CB4F0E125F}
{F80CA2F0-168E-4364-AB75-A27DDD58643D} = {460C4687-9209-4100-AAB0-82867B592FDC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A0F2E34-D2AF-4DAB-86A0-7D7764B3D0EC}
EndGlobalSection
EndGlobal