2025-08-16 08:31:41 +10:00
# requires -Version 5
2021-10-13 12:08:59 +10:00
param (
2021-12-16 13:02:24 +10:00
[ ValidateSet ( " vs2022 " , " vs2019 " , " nupkg-only " , " update-build-version " ) ]
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 0 ) ]
2025-07-01 20:33:55 +10:00
[ string ] $Target = " vs2022 " ,
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 1 ) ]
2026-03-26 21:09:12 +10:00
[ string ] $Version = " 146.0.70 " ,
2014-11-14 09:15:29 +10:00
[ Parameter ( Position = 2 ) ]
2026-03-26 21:09:12 +10:00
[ string ] $AssemblyVersion = " 146.0.70 " ,
2021-10-10 06:42:02 -07:00
[ Parameter ( Position = 3 ) ]
2025-07-27 02:40:58 +02:00
[ ValidateSet ( " NetFramework " , " NetCore " ) ]
2021-10-10 06:42:02 -07:00
[ string ] $TargetFramework = " NetFramework " ,
[ Parameter ( Position = 4 ) ]
2021-10-13 13:18:56 +10:00
[ string ] $BuildArches = " x86 x64 arm64 "
2014-10-02 20:17:24 +10:00
)
2021-10-11 01:51:53 -07:00
Set-StrictMode -version latest ;
$ErrorActionPreference = " Stop " ;
2021-10-10 06:42:02 -07:00
2014-11-24 20:48:33 +01:00
function Write-Diagnostic
{
param (
[ Parameter ( Position = 0 , Mandatory = $true , ValueFromPipeline = $true ) ]
[ string ] $Message
)
Write-Host
Write-Host $Message -ForegroundColor Green
Write-Host
}
2014-10-02 20:17:24 +10:00
# https://github.com/jbake/Powershell_scripts/blob/master/Invoke-BatchFile.ps1
function Invoke-BatchFile
{
param (
[ Parameter ( Position = 0 , Mandatory = $true , ValueFromPipeline = $true ) ]
2025-07-27 02:40:58 +02:00
[ string ] $Path ,
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 1 , Mandatory = $true , ValueFromPipeline = $true ) ]
[ string ] $Parameters
)
2025-07-27 02:40:58 +02:00
$tempFile = [ IO.Path ] :: GetTempFileName ( )
2014-10-02 20:17:24 +10:00
2025-07-27 02:40:58 +02:00
cmd . exe / c " `" $Path `" $Parameters && set > `" $tempFile `" "
2014-10-02 20:17:24 +10:00
2025-07-27 02:40:58 +02:00
Get-Content $tempFile | Foreach-Object {
if ( $_ -match " ^(.*?)=(.*) $ " )
{
Set-Content " env:\ $( $matches [ 1 ] ) " $matches [ 2 ]
}
}
2014-10-02 20:17:24 +10:00
Remove-Item $tempFile
}
function Die
{
param (
[ Parameter ( Position = 0 , ValueFromPipeline = $true ) ]
[ string ] $Message
)
Write-Host
2014-11-03 18:19:39 +10:00
Write-Error $Message
exit 1
2014-10-02 20:17:24 +10:00
}
2025-07-27 02:40:58 +02:00
function Warn
2014-10-02 20:17:24 +10:00
{
param (
[ Parameter ( Position = 0 , ValueFromPipeline = $true ) ]
[ string ] $Message
)
Write-Host
2014-11-03 18:19:39 +10:00
Write-Host $Message -ForegroundColor Yellow
Write-Host
2014-10-02 20:17:24 +10:00
}
2025-07-27 02:40:58 +02:00
function BuildSolution
2014-10-02 20:17:24 +10:00
{
param (
2021-10-13 13:18:56 +10:00
[ ValidateSet ( 'v142' , 'v143' ) ]
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 0 , ValueFromPipeline = $true ) ]
2025-07-27 02:40:58 +02:00
[ string ] $Toolchain ,
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 1 , ValueFromPipeline = $true ) ]
[ ValidateSet ( 'Debug' , 'Release' ) ]
2025-07-27 02:40:58 +02:00
[ string ] $Configuration ,
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 2 , ValueFromPipeline = $true ) ]
2021-10-10 06:42:02 -07:00
[ ValidateSet ( 'x86' , 'x64' , 'arm64' ) ]
2021-10-13 20:50:45 +10:00
[ string ] $Platform ,
2021-10-11 01:51:53 -07:00
2021-10-13 20:50:45 +10:00
[ Parameter ( Position = 3 , ValueFromPipeline = $true ) ]
[ string ] $VisualStudioVersion
)
2014-10-02 20:17:24 +10:00
2021-10-13 20:50:45 +10:00
Write-Diagnostic " Begin compiling targeting $Toolchain using configuration $Configuration for platform $Platform "
2014-10-02 20:17:24 +10:00
2021-10-10 06:42:02 -07:00
$Arch = $Platform
2021-10-13 20:50:45 +10:00
if ( ! $IsNetCoreBuild -and $Arch -eq " x86 " )
2021-10-13 13:18:56 +10:00
{
2021-10-10 06:42:02 -07:00
$Arch = " win32 " ;
}
2025-07-27 02:40:58 +02:00
# Restore Nuget packages
& msbuild / nologo / verbosity : minimal / t: restore / p: Platform = $Arch / p: Configuration = Release $CefSln
2014-10-02 20:17:24 +10:00
$Arguments = @ (
" $CefSln " ,
" /t:rebuild " ,
" /p:VisualStudioVersion= $VisualStudioVersion " ,
" /p:Configuration= $Configuration " ,
2014-12-29 14:01:50 +10:00
" /p:Platform= $Arch " ,
2014-12-29 15:42:45 +10:00
" /verbosity:normal "
2014-10-02 20:17:24 +10:00
)
$StartInfo = New-Object System . Diagnostics . ProcessStartInfo
2021-10-13 20:50:45 +10:00
$StartInfo . FileName = " msbuild.exe "
2014-10-02 20:17:24 +10:00
$StartInfo . Arguments = $Arguments
$StartInfo . EnvironmentVariables . Clear ( )
Get-ChildItem -Path env : * | ForEach-Object {
$StartInfo . EnvironmentVariables . Add ( $_ . Name , $_ . Value )
}
$StartInfo . UseShellExecute = $false
$StartInfo . CreateNoWindow = $false
2014-12-29 15:42:45 +10:00
$StartInfo . RedirectStandardError = $true
$StartInfo . RedirectStandardOutput = $true
2014-10-02 20:17:24 +10:00
$Process = New-Object System . Diagnostics . Process
$Process . StartInfo = $startInfo
2014-12-29 15:42:45 +10:00
$Process . Start ( )
$stdout = $Process . StandardOutput . ReadToEnd ( )
$stderr = $Process . StandardError . ReadToEnd ( )
2014-10-02 20:17:24 +10:00
$Process . WaitForExit ( )
2014-12-29 15:18:00 +10:00
if ( $Process . ExitCode -ne 0 )
2014-12-29 15:42:45 +10:00
{
Write-Host " stdout: $stdout "
Write-Host " stderr: $stderr "
2014-10-02 20:17:24 +10:00
Die " Build failed "
}
2021-10-13 20:50:45 +10:00
Write-Diagnostic " Compile succeeded targeting $Toolchain using configuration $Configuration for platform $Platform "
2014-10-02 20:17:24 +10:00
}
function VSX
{
param (
2021-10-13 13:18:56 +10:00
[ ValidateSet ( 'v142' , 'v143' ) ]
2014-10-02 20:17:24 +10:00
[ Parameter ( Position = 0 , ValueFromPipeline = $true ) ]
[ string ] $Toolchain
)
Write-Diagnostic " Starting to build targeting toolchain $Toolchain "
2021-10-13 20:50:45 +10:00
$VisualStudioVersion = $null
$VXXCommonTools = $null
$VS_VER = -1
$VS_OFFICIAL_VER = -1
$VS_PRE = " "
switch -Exact ( $Toolchain )
2025-07-27 02:40:58 +02:00
{
2021-10-13 20:50:45 +10:00
'v142'
2025-07-27 02:40:58 +02:00
{
2021-10-13 20:50:45 +10:00
$VS_VER = 16 ;
$VS_OFFICIAL_VER = 2019 ;
}
'v143'
{
$VS_VER = 17 ;
$VS_OFFICIAL_VER = 2022 ;
$VS_PRE = " -prerelease " ;
}
}
$versionSearchStr = " [ $VS_VER .0, " + ( $VS_VER + 1 ) + " .0) "
2024-01-17 01:07:32 -08:00
$ErrorActionPreference = " SilentlyContinue "
2024-09-27 14:39:03 -07:00
$VSInstallPath = & $VSWherePath -version $versionSearchStr -latest -property installationPath $VS_PRE
2024-01-17 01:07:32 -08:00
$ErrorActionPreference = " Stop "
2021-10-13 20:50:45 +10:00
Write-Diagnostic " $( $VS_OFFICIAL_VER ) InstallPath: $VSInstallPath "
if ( -not $VSInstallPath -or -not ( Test-Path $VSInstallPath ) )
{
2024-01-17 01:07:32 -08:00
$ErrorActionPreference = " SilentlyContinue "
2022-12-19 03:33:35 +01:00
$VSInstallPath = & $VSwherePath -version $versionSearchStr -property installationPath $VS_PRE -products 'Microsoft.VisualStudio.Product.BuildTools'
2024-01-17 01:07:32 -08:00
$ErrorActionPreference = " Stop "
2025-07-27 02:40:58 +02:00
Write-Diagnostic " BuildTools $( $VS_OFFICIAL_VER ) InstallPath: $VSInstallPath "
2022-12-19 03:33:35 +01:00
if ( -not $VSInstallPath -or -not ( Test-Path $VSInstallPath ) )
{
Die " Visual Studio $VS_OFFICIAL_VER is not installed on your development machine, unable to continue, ran command: $VSWherePath -version $versionSearchStr -property installationPath "
}
2021-10-13 20:50:45 +10:00
}
$VisualStudioVersion = " $VS_VER .0 "
$VXXCommonTools = Join-Path $VSInstallPath VC \ Auxiliary \ Build
if ( $null -eq $VXXCommonTools -or ( -not ( Test-Path ( $VXXCommonTools ) ) ) )
{
Die 'Error unable to find any visual studio environment'
}
$VCVarsAll = Join-Path $VXXCommonTools vcvarsall . bat
if ( -not ( Test-Path $VCVarsAll ) )
{
Die " Unable to find $VCVarsAll "
}
# Only configure build environment once
if ( $null -eq $env:CEFSHARP_BUILD_IS_BOOTSTRAPPED )
{
$VCVarsAllArch = $ARCHES [ 0 ]
if ( $VCVarsAllArch -eq " arm64 " )
{
#TODO: Add support for compiling from an arm64 host
# Detect host and determine if we are native or cross compile
# currently only cross compiling arm64 from x64 host
$VCVarsAllArch = 'x64_arm64'
}
Invoke-BatchFile $VCVarsAll $VCVarsAllArch
$env:CEFSHARP_BUILD_IS_BOOTSTRAPPED = $true
}
2021-10-13 13:18:56 +10:00
foreach ( $arch in $ARCHES )
{
2021-10-13 20:50:45 +10:00
BuildSolution " $Toolchain " 'Release' $arch $VisualStudioVersion
2021-10-10 06:42:02 -07:00
}
2014-10-02 20:17:24 +10:00
Write-Diagnostic " Finished build targeting toolchain $Toolchain "
}
2014-10-02 20:24:49 +10:00
function NugetPackageRestore
{
2021-10-13 13:18:56 +10:00
param (
[ Parameter ( Position = 0 , ValueFromPipeline = $true ) ]
[ string[] ] $ConfigFiles
)
2014-10-02 20:24:49 +10:00
Write-Diagnostic " Restore Nuget Packages "
2021-10-10 06:42:02 -07:00
2021-10-13 13:18:56 +10:00
foreach ( $file in $ConfigFiles )
{
. $nuget restore $file -PackagesDirectory packages
2021-10-10 06:42:02 -07:00
}
2014-10-02 20:24:49 +10:00
}
2014-10-02 20:17:24 +10:00
function Nupkg
{
2021-10-13 13:18:56 +10:00
param (
[ Parameter ( Position = 0 , ValueFromPipeline = $true ) ]
[ string[] ] $Files
)
2014-11-18 14:20:37 +10:00
if ( Test-Path Env : \ APPVEYOR_PULL_REQUEST_NUMBER )
2014-11-18 12:22:21 +10:00
{
2014-11-18 14:20:37 +10:00
Write-Diagnostic " Pr Number: $env:APPVEYOR_PULL_REQUEST_NUMBER "
2014-11-18 14:21:43 +10:00
Write-Diagnostic " Skipping Nupkg "
return
2014-11-18 12:22:21 +10:00
}
2014-10-02 20:17:24 +10:00
2024-03-19 09:49:56 +01:00
$gitBranch = git rev-parse - -abbrev -ref HEAD
$gitCommit = git rev-parse HEAD
2024-03-23 22:38:04 +01:00
if ( Test-Path Env : \ APPVEYOR_REPO_BRANCH ) # https://github.com/appveyor/ci/issues/1606
{
$gitBranch = $env:APPVEYOR_REPO_BRANCH
}
2024-03-19 09:49:56 +01:00
Write-Diagnostic " Building nuget package for $gitCommit on $gitBranch "
2014-10-02 20:17:24 +10:00
2021-10-10 06:42:02 -07:00
# Build packages
2021-10-13 13:18:56 +10:00
foreach ( $file in $Files )
{
2021-10-13 20:50:45 +10:00
$filePath = Join-Path $WorkingDir " $NugetPackagePath \ $file "
$tempFile = $filePath + " .backup "
try
{
# We need to rewrite the CefSharp.Common nupkg file if we are building a subset of architectures
if ( $file . StartsWith ( " CefSharp.Common " ) -and $ARCHES . Count -lt $SupportedArches . Count )
{
Copy-Item $filePath $tempFile
$removeArches = $SupportedArches | Where-Object { $_ -notin $ARCHES }
$NupkgXml = [ xml ] ( Get-Content ( $filePath ) -Encoding UTF8 )
foreach ( $a in $removeArches )
{
$targetFolder = " CefSharp\ $a "
if ( $IsNetCoreBuild )
{
$targetFolder = " runtimes\win- $a "
}
2022-04-19 19:22:32 +10:00
else
{
2025-07-03 00:51:31 -07:00
# Remove chromiumembeddedframework.runtime.win* dependency for arches we are not including
$depNode = $NupkgXml . package . metadata . dependencies . group . dependency | Where-Object { $_ . Attributes [ " id " ] . Value . Equals ( " chromiumembeddedframework.runtime.win- " + $a ) } ;
2022-04-19 19:22:32 +10:00
$depNode . ParentNode . RemoveChild ( $depNode ) | Out-Null
}
2021-10-13 20:50:45 +10:00
2022-04-19 19:22:32 +10:00
#Remove files
2021-10-13 20:50:45 +10:00
$nodes = $NupkgXml . package . files . file | Where-Object { $_ . Attributes [ " target " ] . Value . StartsWith ( $targetFolder ) } ;
$nodes | ForEach-Object { $_ . ParentNode . RemoveChild ( $_ ) } | Out-Null
}
$NupkgXml . Save ( $filePath )
}
#Only show package analysis for newer packages
if ( $IsNetCoreBuild )
{
2024-03-19 09:49:56 +01:00
. $nuget pack $filePath -Version $Version -OutputDirectory $NugetPackagePath -Properties " RedistVersion= $RedistVersion ;Branch= $gitBranch ;CommitSha= $gitCommit ; "
2021-10-13 20:50:45 +10:00
}
else
{
2024-03-19 09:49:56 +01:00
. $nuget pack $filePath -NoPackageAnalysis -Version $Version -OutputDirectory $NugetPackagePath -Properties " RedistVersion= $RedistVersion ;Branch= $gitBranch ;CommitSha= $gitCommit ; "
2021-10-13 20:50:45 +10:00
}
}
finally
{
if ( Test-Path ( $tempFile ) )
{
Copy-Item $tempFile $filePath
Remove-Item $tempFile
}
}
2021-10-13 13:18:56 +10:00
}
2014-10-14 10:58:16 +02:00
2014-11-03 18:19:39 +10:00
# Invoke `AfterBuild` script if available (ie. upload packages to myget)
2021-10-13 13:18:56 +10:00
if ( -not ( Test-Path $WorkingDir \ AfterBuild . ps1 ) )
{
2014-11-03 18:19:39 +10:00
return
}
2014-10-14 10:58:16 +02:00
2014-11-03 18:19:39 +10:00
. $WorkingDir \ AfterBuild . ps1 -Version $Version
2014-10-02 20:17:24 +10:00
}
2014-10-04 12:36:24 +10:00
function DownloadNuget ( )
{
if ( -not ( Test-Path $nuget ) )
2014-11-03 18:19:39 +10:00
{
$client = New-Object System . Net . WebClient ;
2017-11-29 21:47:39 +01:00
$client . DownloadFile ( 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' , $nuget ) ;
2014-11-03 18:19:39 +10:00
}
2021-10-13 13:18:56 +10:00
2021-10-10 06:42:02 -07:00
if ( -not ( Test-Path $nuget ) )
{
Die " Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget "
}
2014-10-04 12:36:24 +10:00
}
2014-10-14 10:10:37 +02:00
function WriteAssemblyVersion
{
2014-11-03 18:19:39 +10:00
param ( )
$Filename = Join-Path $WorkingDir CefSharp \ Properties \ AssemblyInfo . cs
$Regex = 'public const string AssemblyVersion = "(.*)"' ;
2017-02-22 01:56:40 +01:00
$Regex2 = 'public const string AssemblyFileVersion = "(.*)"'
2019-02-15 21:40:25 +01:00
$Regex3 = 'public const string AssemblyCopyright = "Copyright © .* The CefSharp Authors"'
$AssemblyInfo = Get-Content -Encoding UTF8 $Filename
$CurrentYear = Get-Date -Format yyyy
2014-11-03 18:19:39 +10:00
2014-11-06 14:30:27 +10:00
$NewString = $AssemblyInfo -replace $Regex , " public const string AssemblyVersion = "" $AssemblyVersion "" "
2019-04-11 05:45:32 +10:00
$NewString = $NewString -replace $Regex2 , " public const string AssemblyFileVersion = "" $AssemblyVersion .0 "" "
2019-02-15 21:40:25 +01:00
$NewString = $NewString -replace $Regex3 , " public const string AssemblyCopyright = "" Copyright © $CurrentYear The CefSharp Authors "" "
2017-02-22 01:56:40 +01:00
2019-02-15 21:40:25 +01:00
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
2017-02-22 01:56:40 +01:00
}
function WriteVersionToManifest($manifest )
{
$Filename = Join-Path $WorkingDir $manifest
$Regex = 'assemblyIdentity version="(.*?)"' ;
2019-02-15 21:40:25 +01:00
$ManifestData = Get-Content -Encoding UTF8 $Filename
2019-04-11 05:45:32 +10:00
$NewString = $ManifestData -replace $Regex , " assemblyIdentity version= "" $AssemblyVersion .0 "" "
2017-02-22 01:56:40 +01:00
2019-02-15 21:40:25 +01:00
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
2017-02-22 01:56:40 +01:00
}
2020-12-16 10:47:34 +10:00
function WriteVersionToTransform($transform )
{
$Filename = Join-Path $WorkingDir $transform
$Regex = 'codeBase version="(.*?)"' ;
$TransformData = Get-Content -Encoding UTF8 $Filename
$NewString = $TransformData -replace $Regex , " codeBase version= "" $AssemblyVersion .0 "" "
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
}
2017-02-22 01:56:40 +01:00
function WriteVersionToResourceFile($resourceFile )
{
$Filename = Join-Path $WorkingDir $resourceFile
$Regex1 = 'VERSION .*' ;
$Regex2 = 'Version", ".*?"' ;
2019-02-15 21:40:25 +01:00
$Regex3 = 'Copyright © .* The CefSharp Authors'
$ResourceData = Get-Content -Encoding UTF8 $Filename
$CurrentYear = Get-Date -Format yyyy
2020-04-18 08:49:04 +10:00
#Assembly version with comma instead of dot
$CppAssemblyVersion = $AssemblyVersion -replace '\.' , ','
2017-02-22 01:56:40 +01:00
2019-11-16 06:08:47 +10:00
$NewString = $ResourceData -replace $Regex1 , " VERSION $CppAssemblyVersion "
2017-02-22 01:56:40 +01:00
$NewString = $NewString -replace $Regex2 , " Version "" , "" $AssemblyVersion "" "
2019-02-15 21:40:25 +01:00
$NewString = $NewString -replace $Regex3 , " Copyright © $CurrentYear The CefSharp Authors "
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
}
function WriteVersionToShfbproj
{
$Filename = Join-Path $WorkingDir CefSharp . shfbproj
$Regex1 = '<HelpFileVersion>.*<\/HelpFileVersion>' ;
$Regex2 = '<HeaderText>Version .*<\/HeaderText>' ;
$ShfbprojData = Get-Content -Encoding UTF8 $Filename
$NewString = $ShfbprojData -replace $Regex1 , " <HelpFileVersion> $AssemblyVersion </HelpFileVersion> "
$NewString = $NewString -replace $Regex2 , " <HeaderText>Version $AssemblyVersion </HeaderText> "
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
}
function WriteVersionToAppveyor
{
$Filename = Join-Path $WorkingDir appveyor . yml
$Regex1 = 'version: .*-CI{build}' ;
$AppveyorData = Get-Content -Encoding UTF8 $Filename
$NewString = $AppveyorData -replace $Regex1 , " version: $AssemblyVersion -CI{build} "
2014-11-03 18:19:39 +10:00
2019-02-15 21:40:25 +01:00
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
2014-10-14 10:10:37 +02:00
}
2021-10-13 13:18:56 +10:00
2021-10-10 06:42:02 -07:00
function WriteVersionToNugetTargets
{
$Filename = Join-Path $WorkingDir NuGet \ PackageReference \ CefSharp . Common . NETCore . targets
Write-Diagnostic " Write Version ( $RedistVersion ) to $Filename "
2025-07-27 02:40:58 +02:00
$RunTimeJsonData = Get-Content -Encoding UTF8 $Filename
2023-03-07 11:07:44 +10:00
2021-10-10 06:42:02 -07:00
$Regex1 = '" Version=".*"' ;
$Replace = '" Version="' + $RedistVersion + '"' ;
$NewString = $RunTimeJsonData -replace $Regex1 , $Replace
2025-07-27 02:40:58 +02:00
$Regex1 = '" VersionOverride=".*"' ;
2023-03-07 11:07:44 +10:00
$Replace = '" VersionOverride="' + $RedistVersion + '"' ;
$NewString = $NewString -replace $Regex1 , $Replace
2021-10-10 06:42:02 -07:00
$Utf8NoBomEncoding = New-Object System . Text . UTF8Encoding $False
[ System.IO.File ] :: WriteAllLines ( $Filename , $NewString , $Utf8NoBomEncoding )
}
2014-10-14 10:10:37 +02:00
2021-10-13 13:18:56 +10:00
$WorkingDir = split-path -parent $MyInvocation . MyCommand . Definition
Write-Diagnostic " pushd $WorkingDir "
Push-Location $WorkingDir
2021-10-13 20:50:45 +10:00
$IsNetCoreBuild = $TargetFramework . ToLower ( ) . Contains ( " netcore " )
$ARCHES = [ System.Collections.ArrayList ] $BuildArches . ToLower ( ) . Split ( " " ) ;
2021-10-13 13:18:56 +10:00
$CefSln = $null
$NugetPackagePath = $null
$NupkgFiles = $null
$VCXProjPackageConfigFiles = $null
2021-10-13 20:50:45 +10:00
$SupportedArches = [ System.Collections.ArrayList ] @ ( ) ;
2021-10-13 12:08:59 +10:00
2021-10-13 13:18:56 +10:00
if ( $IsNetCoreBuild )
{
$CefSln = Join-Path $WorkingDir 'CefSharp3.netcore.sln'
$NugetPackagePath = " nuget\PackageReference " ;
2025-01-18 06:40:48 +10:00
$NupkgFiles = @ ( 'CefSharp.Common.NETCore.nuspec' , 'CefSharp.WinForms.NETCore.nuspec' , 'CefSharp.Wpf.NETCore.nuspec' , 'CefSharp.OffScreen.NETCore.nuspec' , 'CefSharp.Wpf.HwndHost.nuspec' )
2021-10-13 13:18:56 +10:00
$VCXProjPackageConfigFiles = @ ( 'CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.netcore.config' , 'CefSharp.BrowserSubprocess.Core\packages.CefSharp.BrowserSubprocess.Core.netcore.config' ) ;
2021-10-13 20:50:45 +10:00
$SupportedArches . AddRange ( @ ( " x86 " , " x64 " , " arm64 " ) ) ;
2021-10-13 13:18:56 +10:00
}
else
{
$ARCHES . Remove ( " arm64 " )
$CefSln = Join-Path $WorkingDir 'CefSharp3.sln'
$NugetPackagePath = " nuget " ;
$NupkgFiles = @ ( 'CefSharp.Common.nuspec' , 'CefSharp.WinForms.nuspec' , 'CefSharp.Wpf.nuspec' , 'CefSharp.OffScreen.nuspec' )
$VCXProjPackageConfigFiles = @ ( 'CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.config' , 'CefSharp.BrowserSubprocess.Core\packages.CefSharp.BrowserSubprocess.Core.config' ) ;
2021-10-13 20:50:45 +10:00
$SupportedArches . AddRange ( @ ( " x86 " , " x64 " ) ) ;
2021-10-13 12:08:59 +10:00
}
# 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
2021-10-13 13:18:56 +10:00
$CefSharpCorePackagesXml = [ xml ] ( Get-Content ( $VCXProjPackageConfigFiles [ 0 ] ) )
2021-10-13 12:08:59 +10:00
$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 "
}
2016-06-07 08:14:49 +10:00
Write-Diagnostic " CEF Redist Version = $RedistVersion "
2014-10-04 12:36:24 +10:00
DownloadNuget
2021-10-13 13:18:56 +10:00
NugetPackageRestore $VCXProjPackageConfigFiles
2021-10-14 12:43:35 +10:00
$VSWherePath = Join-Path $ { env : ProgramFiles } 'Microsoft Visual Studio\Installer\vswhere.exe'
if ( -not ( Test-Path $VSWherePath ) )
{
$VSWherePath = Join-Path $ { env : ProgramFiles ( x86 ) } 'Microsoft Visual Studio\Installer\vswhere.exe'
}
2021-10-13 13:18:56 +10:00
#Check if we already have vswhere which is included in newer versions of VS2017/VS2019
if ( -not ( Test-Path $VSWherePath ) )
{
Write-Diagnostic " Downloading VSWhere as no install found at $VSWherePath "
# Check if we already have a local copy and download if required
$VSWherePath = Join-Path $WorkingDir \ vswhere . exe
# TODO: Check hash and download if hash differs
if ( -not ( Test-Path $VSWherePath ) )
{
$client = New-Object System . Net . WebClient ;
$client . DownloadFile ( 'https://github.com/Microsoft/vswhere/releases/download/2.2.11/vswhere.exe' , $VSWherePath ) ;
}
}
Write-Diagnostic " VSWhere path $VSWherePath "
2014-10-02 20:24:49 +10:00
2014-10-14 10:10:37 +02:00
WriteAssemblyVersion
2019-02-15 21:40:25 +01:00
WriteVersionToShfbproj
WriteVersionToAppveyor
2021-10-10 06:42:02 -07:00
WriteVersionToNugetTargets
2014-10-14 10:10:37 +02:00
2017-02-22 01:56:40 +01:00
WriteVersionToManifest " CefSharp.BrowserSubprocess\app.manifest "
WriteVersionToManifest " CefSharp.OffScreen.Example\app.manifest "
WriteVersionToManifest " CefSharp.WinForms.Example\app.manifest "
WriteVersionToManifest " CefSharp.Wpf.Example\app.manifest "
2020-12-16 10:47:34 +10:00
WriteVersionToTransform " NuGet\CefSharp.Common.app.config.x64.transform "
WriteVersionToTransform " NuGet\CefSharp.Common.app.config.x86.transform "
2017-02-22 01:56:40 +01:00
WriteVersionToResourceFile " CefSharp.BrowserSubprocess.Core\Resource.rc "
2020-12-16 10:47:34 +10:00
WriteVersionToResourceFile " CefSharp.Core.Runtime\Resource.rc "
2017-02-22 01:56:40 +01:00
2015-05-19 19:15:44 +10:00
switch -Exact ( $Target )
{
2014-11-03 18:19:39 +10:00
" nupkg-only "
{
2021-10-13 13:18:56 +10:00
Nupkg $NupkgFiles
2017-01-06 15:01:39 +10:00
}
2019-10-06 14:14:54 -07:00
" vs2019 "
{
VSX v142
2021-10-13 13:18:56 +10:00
Nupkg $NupkgFiles
2019-10-06 14:14:54 -07:00
}
2021-10-11 01:51:53 -07:00
" vs2022 "
{
VSX v143
2021-10-13 13:18:56 +10:00
Nupkg $NupkgFiles
2021-10-10 06:42:02 -07:00
}
2025-07-27 02:40:58 +02:00
" update-build-version "
{
Write-Diagnostic " Updated Version to $Version "
Write-Diagnostic " Updated AssemblyVersion to $AssemblyVersion "
}
2017-10-06 08:09:51 +01:00
}
2021-10-13 13:18:56 +10:00
2023-03-08 06:44:23 +10:00
Pop-Location