Skip to content

Commit

Permalink
build.ps1 - Reorder scripts so functions are declared first
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland committed Oct 13, 2021
1 parent 7c57c10 commit 13c725c
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
param(
#requires -Version 5

param(
[ValidateSet("vs2022","vs2019", "netcore31", "nupkg-only")]
[Parameter(Position = 0)]
[string] $Target = "vs2019",
Expand All @@ -14,20 +16,6 @@
)
Set-StrictMode -version latest;
$ErrorActionPreference = "Stop";
$IsNetCoreBuild = $TargetFramework.Contains("NetCore")

$ARCHES = $BuildArches.Split(" ");
$ARCHES_TO_BITKEY = @{};
foreach ($arch in $ARCHES) {
$arch_bit = $arch;
if ($arch_bit.StartsWith("x")) {
$arch_bit = $arch.Substring(1);
if ($arch_bit -eq "86"){
$arch_bit = "32";
}
$ARCHES_TO_BITKEY[$arch] = $arch_bit;
}
}

function TernaryReturn
{
Expand All @@ -47,16 +35,6 @@ function TernaryReturn
$Value2
}


$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition
$CefSln = Join-Path $WorkingDir ('CefSharp3' + (TernaryReturn $IsNetCoreBuild ".netcore" "") + '.sln')

# Extract the current CEF Redist version from the CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.config file
# Save having to update this file manually Example 3.2704.1418
$CefSharpCorePackagesXml = [xml](Get-Content (Join-Path $WorkingDir ('CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime' + (TernaryReturn $IsNetCoreBuild ".netcore" "") + '.config')))
$RedistVersion = $CefSharpCorePackagesXml.SelectSingleNode("//packages/package[@id='cef.sdk']/@version").value
$nuget = Join-Path $WorkingDir .\nuget\NuGet.exe

function Write-Diagnostic
{
param(
Expand All @@ -69,24 +47,6 @@ function Write-Diagnostic
Write-Host
}

if (Test-Path Env:\APPVEYOR_BUILD_VERSION)
{
$Version = $env:APPVEYOR_BUILD_VERSION
}

if ($env:APPVEYOR_REPO_TAG -eq "True")
{
$Version = "$env:APPVEYOR_REPO_TAG_NAME".Substring(1) # trim leading "v"
$AssemblyVersion = $Version
#Stip the -pre
if($AssemblyVersion.Contains("-pre"))
{
$AssemblyVersion = $AssemblyVersion.Substring(0, $AssemblyVersion.IndexOf("-pre"))
}
Write-Diagnostic "Setting Version based on tag to $Version"
Write-Diagnostic "Setting AssemblyVersion based on tag to $AssemblyVersion"
}

# https://github.com/jbake/Powershell_scripts/blob/master/Invoke-BatchFile.ps1
function Invoke-BatchFile
{
Expand Down Expand Up @@ -135,7 +95,6 @@ function Warn
Write-Host
}


function Msvs
{
param(
Expand Down Expand Up @@ -472,6 +431,48 @@ function WriteVersionToNugetTargets
[System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding)
}

$IsNetCoreBuild = $TargetFramework.Contains("NetCore")

$ARCHES = $BuildArches.Split(" ");
$ARCHES_TO_BITKEY = @{};
foreach ($arch in $ARCHES) {
$arch_bit = $arch;
if ($arch_bit.StartsWith("x")) {
$arch_bit = $arch.Substring(1);
if ($arch_bit -eq "86"){
$arch_bit = "32";
}
$ARCHES_TO_BITKEY[$arch] = $arch_bit;
}
}

$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition
$CefSln = Join-Path $WorkingDir ('CefSharp3' + (TernaryReturn $IsNetCoreBuild ".netcore" "") + '.sln')

# Extract the current CEF Redist version from the CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.config file
# Save having to update this file manually Example 3.2704.1418
$CefSharpCorePackagesXml = [xml](Get-Content (Join-Path $WorkingDir ('CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime' + (TernaryReturn $IsNetCoreBuild ".netcore" "") + '.config')))
$RedistVersion = $CefSharpCorePackagesXml.SelectSingleNode("//packages/package[@id='cef.sdk']/@version").value
$nuget = Join-Path $WorkingDir .\nuget\NuGet.exe

if (Test-Path Env:\APPVEYOR_BUILD_VERSION)
{
$Version = $env:APPVEYOR_BUILD_VERSION
}

if ($env:APPVEYOR_REPO_TAG -eq "True")
{
$Version = "$env:APPVEYOR_REPO_TAG_NAME".Substring(1) # trim leading "v"
$AssemblyVersion = $Version
#Stip the -pre
if($AssemblyVersion.Contains("-pre"))
{
$AssemblyVersion = $AssemblyVersion.Substring(0, $AssemblyVersion.IndexOf("-pre"))
}
Write-Diagnostic "Setting Version based on tag to $Version"
Write-Diagnostic "Setting AssemblyVersion based on tag to $AssemblyVersion"
}

Write-Diagnostic "CEF Redist Version = $RedistVersion"

DownloadNuget
Expand Down

0 comments on commit 13c725c

Please sign in to comment.