From 8d1900362ed330db39cfa801a82b4f9d3b765c2c Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Fri, 29 Jun 2018 17:05:53 +0200 Subject: [PATCH] Update PostCefUpdate script to remove invalid build configurations (x64, AnyCPU) --- README.md | 2 + Resources/PostCefUpdate.ps1 | 74 +++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index fa2ca8cf..b9408677 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ After the window closes, three installers will be generated inside the `bld/Outp #### Notes +> When opening **Batch Build**, you will also see `x64` and `AnyCPU` configurations. These are visible due to what I consider a Visual Studio bug, and will not work without significant changes to the project. Manually running the `Resources/PostCefUpdate.ps1` PowerShell script modifies the downloaded CefSharp packages, and removes the invalid configurations. + > There is a small chance running `RUN BUILD.bat` immediately shows a resource error. If that happens, close the console window (which terminates all Inno Setup processes and leaves corrupted installers in the output folder), and run it again. > Running `RUN BUILD.bat` uses about 400 MB of RAM due to high compression. You can lower this to about 140 MB by opening `gen_full.iss` and `gen_port.iss`, and changing `LZMADictionarySize=15360` to `LZMADictionarySize=4096`. diff --git a/Resources/PostCefUpdate.ps1 b/Resources/PostCefUpdate.ps1 index c8c217e2..62f41012 100644 --- a/Resources/PostCefUpdate.ps1 +++ b/Resources/PostCefUpdate.ps1 @@ -1,18 +1,60 @@ $ErrorActionPreference = "Stop" -$MainProj = "..\TweetDuck.csproj" -$BrowserProj = "..\subprocess\TweetDuck.Browser.csproj" - -$Match = Select-String -Path $MainProj '<Import Project="packages\\cef\.redist\.x86\.(.*?)\\' -$Version = $Match.Matches[0].Groups[1].Value - -Copy-Item "..\packages\cef.redist.x86.${Version}\CEF\devtools_resources.pak" -Destination "..\bld\Resources\" -Force - -$Match = Select-String -Path $MainProj '<Import Project="packages\\CefSharp\.Common\.(.*?)\\' -$Version = $Match.Matches[0].Groups[1].Value - -$Contents = [IO.File]::ReadAllText($BrowserProj) -$Contents = $Contents -Replace '(?<=<HintPath>\.\.\\packages\\CefSharp\.Common\.)(.*?)(?=\\)', $Version -$Contents = $Contents -Replace '(?<=<Reference Include="CefSharp\.BrowserSubprocess\.Core, Version=)(\d+)', $Version.Split(".")[0] - -[IO.File]::WriteAllText($BrowserProj, $Contents) +try{ + $mainProj = "..\TweetDuck.csproj" + $browserProj = "..\subprocess\TweetDuck.Browser.csproj" + + $cefMatch = Select-String -Path $mainProj '<Import Project="packages\\cef\.redist\.x86\.(.*?)\\' + $cefVersion = $cefMatch.Matches[0].Groups[1].Value + + $sharpMatch = Select-String -Path $mainProj '<Import Project="packages\\CefSharp\.Common\.(.*?)\\' + $sharpVersion = $sharpMatch.Matches[0].Groups[1].Value + + $propsFiles = "..\packages\CefSharp.Common.${sharpVersion}\build\CefSharp.Common.props", + "..\packages\CefSharp.WinForms.${sharpVersion}\build\CefSharp.WinForms.props" + + # Greetings + + $title = "CEF ${cefVersion}, CefSharp ${sharpVersion}" + + Write-Host ("-" * $title.Length) + Write-Host $title + Write-Host ("-" * $title.Length) + + # Perform update + + Write-Host "Copying dev tools to repository..." + + Copy-Item "..\packages\cef.redist.x86.${cefVersion}\CEF\devtools_resources.pak" -Destination "..\bld\Resources\" -Force + + Write-Host "Updating browser subprocess reference..." + + $contents = [IO.File]::ReadAllText($browserProj) + $contents = $contents -Replace '(?<=<HintPath>\.\.\\packages\\CefSharp\.Common\.)(.*?)(?=\\)', $sharpVersion + $contents = $contents -Replace '(?<=<Reference Include="CefSharp\.BrowserSubprocess\.Core, Version=)(\d+)', $sharpVersion.Split(".")[0] + + [IO.File]::WriteAllText($browserProj, $contents) + + Write-Host "Removing x64 and AnyCPU from CefSharp props..." + + foreach($file in $propsFiles){ + $contents = [IO.File]::ReadAllText($file) + $contents = $contents -Replace '(?<=<When Condition=")(''\$\(Platform\)'' == ''(AnyCPU|x64)'')(?=">)', 'false' + + [IO.File]::WriteAllText($file, $contents) + } + + # Finished + + Write-Host "" + Write-Host "Finished. Exiting in 6 seconds..." + Start-Sleep -Seconds 6 + +}catch{ + Write-Host "" + Write-Host "Encountered an error while running PostBuild.ps1 on line" $_.InvocationInfo.ScriptLineNumber + Write-Host $_ + + $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + Exit 1 +}