From 9e5577388e66966f8b09712999b4565c71acf828 Mon Sep 17 00:00:00 2001 From: Olivier Doneau Date: Fri, 15 Oct 2021 16:29:07 +0200 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit aac5439a5cd07d8eee79667bca4329236e1c4336 Author: Alex Maitland Date: Thu Oct 14 19:37:15 2021 +1000 Test - Fix compile error commit 439970d8cc4a2f2069ba9550689ff123278e9bf0 Author: Alex Maitland Date: Thu Oct 14 19:28:44 2021 +1000 Test - Fix NetCore test case commit 1a854192e5069b181b5cc8847b53481689156aad Author: Alex Maitland Date: Thu Oct 14 13:00:08 2021 +1000 Test - Output QUnit results if tests failed commit db9e041a3e4b609842d140b56b6cf5345e976cad Author: Alex Maitland Date: Thu Oct 14 12:58:42 2021 +1000 build.ps1 - Remove TernaryReturn as no longer used commit f904b88387f7dc41ab540f0c032519460094d3fc Author: Alex Maitland Date: Thu Oct 14 12:43:35 2021 +1000 build.ps1 - Improve vswhere programfiles check commit 221185bf28b8cd4654e6ab1eb59897d372bf41c0 Author: Alex Maitland Date: Thu Oct 14 10:16:27 2021 +1000 WinForms/WPF/OffScreen - Enable Chromium Site Isolation by default Previously was disabled by default Can still be disabled via disable-site-isolation-trials command line argument Issue #2967 commit fd78c0cffc18e20749121686d73e4bf2ce58bc95 Author: Alex Maitland Date: Thu Oct 14 10:11:33 2021 +1000 Test - CanLoadRequestWithPostData now navigates to domain of same origin first When Chromium Site Isolation is enabled we must first navigate to a web page of the same origin to use LoadRequest When Site Isolation is disabled we can navigate to any web page https://magpcss.org/ceforum/viewtopic.php?f=10&t=18672&p=50266#p50249 Issue #2967 commit c72e21cb360499420afdf044e30188ef51053129 Author: Alex Maitland Date: Wed Oct 13 20:50:45 2021 +1000 build.ps1 - Nuget Package only a subset of architectures - Can now build/package only a subset of architectures - Remove file elements from nuspec if arch wasn't specified - Reorder and simplify script .\build.ps1 -BuildArches "x64" Issue #3706 commit 7c2226caff598254c20cf23be87b6ab06d19679c Author: Alex Maitland Date: Wed Oct 13 13:32:38 2021 +1000 Nuget - Update dependency groups Resolves nuget pack warning commit 8aa0ee5e9f1980a7b5de3cdbbf7e5b7833a1cb0d Author: Alex Maitland Date: Wed Oct 13 13:18:56 2021 +1000 build.ps1 - Cleanup - Fail fast if nuget.exe not found - Check for VSWhere at build start (should always be installed as it's included in VS2019 and above) - Remove netcore31 from $Target valid set, we'll just rely on the $TargetFramework - Push-Location to working directory for easier debugging commit 13c725c1ce27870772f99232cff4b9f557f8dc5e Author: Alex Maitland Date: Wed Oct 13 12:08:59 2021 +1000 build.ps1 - Reorder scripts so functions are declared first commit 7c57c106e512a25fa57db6b7ac9eef338f51e11e Author: Mitch Capper Date: Mon Oct 11 02:12:26 2021 -0700 Add netcore to toolchain (it uses same VS version) commit da0f33bf981b0fcc5d2fe5af94c9192672d52d06 Author: Mitch Capper Date: Mon Oct 11 01:51:53 2021 -0700 Added vs2022 support and v143 targetting. VS2022 can also build V142 but requires some additions to the project files to indicate targeting it instead. This should not change behavior for anyone as you must specific specify the 2022 target for it to work. commit 2af10bfd8f1d5662181e0f0b291fbf10d43fd0ed Author: Mitch Capper Date: Sun Oct 10 06:42:02 2021 -0700 build.ps1 and build.netcore.ps1 merge and architecture target added commit 66bb6c0f681072512c804ae1b1d397f20e3acb75 Author: Alex Maitland Date: Wed Oct 13 11:50:00 2021 +1000 Nuget - Remove netcoreapp3.0 hacks For those unable to upgrade to .Net Core 3.1 then the old packages should still be usable by specifying AssetTargetFallback as detailed in https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#assettargetfallback Resolves #3444 commit 42e7b902b3141eb06e9bfddf5e9870d05c94fe21 Author: Alex Maitland Date: Wed Oct 13 09:14:22 2021 +1000 appveyor.yml - Update CefSharp.Test.dll path Runtime identifier was changed to win7-x64 so the path changed commit bd88019327f81f4f98526d190ca16d8775ef8847 Author: Alex Maitland Date: Wed Oct 13 08:59:03 2021 +1000 Test - Add RuntimeIdentifiers and fix build.ps1 - Seems the Nuget restore doesn't work correctly without having RuntimeIdentifiers set Must also set RuntimeIdentifier manually so the files are copied correctly. - Move the msbuild restore after the vcvarsall.bat call so the script runs successfully commit ee431d7add26f30048087d00772faa8d8e59dd78 Author: Alex Maitland Date: Wed Oct 13 06:45:58 2021 +1000 Test - Add RuntimeIdentifiers so libcef.dll etc copied to output folder - Adding didn't work as expected so set RuntimeIdentifier based on PlatformTarget - Updated appveyor.yml as output path for CefSharp.Test.dll changed commit 5356e1b89eff8d432b2598492af9d2a38b00da4c Author: Alex Maitland Date: Wed Oct 13 05:15:34 2021 +1000 Test - Update Nuget PackageReferences - Forgot to change to the chromiumembeddedframework.runtime package - Simplify references Follow up to https://github.com/cefsharp/CefSharp/commit/67a08c47eedf0bb76493a63e99a467f23cf7cf73 Issue #3706 commit 67a08c47eedf0bb76493a63e99a467f23cf7cf73 Author: Alex Maitland Date: Sun Oct 10 15:44:47 2021 +1000 BrowserSubProcess/Examples/Tests - Migrate to newer SDK Style projects - Migrate to new SDK style projects - Migrate to chromiumembeddedframework.runtime packages - Remove old packages.config files - Update post build event for BrowserSubprocess to set TSAware/LargeAddressAware - Change project build order Issue #3706 commit 6953d82f250f420ad6cb5d79bbad0285b0fe26f6 Author: Alex Maitland Date: Mon Oct 11 10:26:35 2021 +1000 Net Core - Nupkg Include xml files Issue #3843 commit bfa8ccf24c7694a80ec42b8f3d6d1683b144ec68 Author: Andrew Smith Date: Sun Oct 10 20:16:07 2021 -0400 WPF - IME Only use GCS_CURSORPOS if an adjacent character is new input (#3846) * Change Wpf IME handling to only use the cursor pos when an adjacent character is new input * Meant to change both character before and after * Ensure the cursor pos is > 0 when checking the character before commit 544abc68d1b047763634e4d0f3fb8b11b415775c Author: Alex Maitland Date: Mon Oct 11 10:13:55 2021 +1000 Revert "WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync" Tests started failing so will revisit later. This reverts commit 08e51400608da637615142308faa8163575c88e5. commit 8bbe6a45ef9b1c80a7fd6d1f6c879b36ff9eadca Author: Alex Maitland Date: Sun Oct 10 15:01:15 2021 +1000 WPF - Fix Address Load being called multiple times after browser created commit 0812ea938ab8525e9b9d4ec3066b15ff935813fc Author: Konstantin Preißer Date: Sun Oct 10 11:56:50 2021 +0200 Don't check for presence of "d3dcompiler_47.dll" when running as ARM64, because that file isn't present in the CEF Redist for this architecture. (#3841) Issue #2944 commit 08e51400608da637615142308faa8163575c88e5 Author: Alex Maitland Date: Sun Oct 10 14:41:04 2021 +1000 WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync Change all the tests to use WaitForBrowserInitialLoadAsync instead of LoadUrlAsync as LoadUrlAsync will require a Url as part of #3842 commit 15cf58c273c90107745056e02158b3f9d7eba55d Author: Alex Maitland Date: Fri Oct 8 13:05:27 2021 +1000 Core - Add IRequestContext.GetCookieManagerAsync extension method - Will return the cookie manager when the backing store has loaded otherwise returns null commit b82fa05291e03ee22f69ba1babd0e44eef3021c7 Author: Alex Maitland Date: Fri Oct 8 12:40:54 2021 +1000 WinForms/WPF/OffScreen - Update Load(string url) behaviour - All three implementations updated to include an IsDisposed check which will simply return immediately - OffScreen updated to match the WinForms behaviour - WPF is more complex because of the initialAddress and Address properties initialAddress will be set if the browser hasn't been created, if the browserCreated has been created and OnAfterBrowserCreated hasn't been called then we'll set the Address dependency property. NOTE: For WinForms/OffScreen there's a small window here between CreateBrowser and OnAfterBrowserCreated where the Address prop will be updated, though LoadUrl won't be called. commit c226d344b1541796bd1093f6c1cefd0626ad755b Author: Alex Maitland Date: Fri Oct 8 10:21:31 2021 +1000 WinForms/WPF/OffScreen - Add LoadUrl method (Same as Load(string)). A more meaningful name for the method, matches the LoadUrlAsync method that was added recently. --- .../CefSharp.BrowserSubprocess.csproj | 162 ++----- CefSharp.Core.Runtime/CefSettingsBase.h | 5 - CefSharp.Core/packages.config | 6 - CefSharp.Example/CefSharp.Example.csproj | 175 +------- CefSharp.Example/packages.config | 4 - CefSharp.Native.props | 66 ++- .../CefSharp.OffScreen.Example.csproj | 144 ++---- CefSharp.OffScreen.Example/packages.config | 5 - CefSharp.OffScreen/ChromiumWebBrowser.cs | 25 +- CefSharp.Test/CefSharp.Test.csproj | 289 +++--------- .../Framework/RequestContextExtensionFacts.cs | 18 + .../JavascriptBinding/IntegrationTestFacts.cs | 36 +- .../OffScreen/OffScreenBrowserBasicFacts.cs | 7 +- CefSharp.Test/QUnitTestResult.cs | 17 + CefSharp.Test/WebBrowserTestExtensions.cs | 6 +- CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs | 37 ++ CefSharp.Test/packages.config | 30 -- .../CefSharp.WinForms.Example.csproj | 242 ++--------- CefSharp.WinForms.Example/packages.config | 5 - CefSharp.WinForms/ChromiumWebBrowser.cs | 13 +- .../CefSharp.Wpf.Example.csproj | 250 ++--------- CefSharp.Wpf.Example/packages.config | 5 - CefSharp.Wpf/ChromiumWebBrowser.cs | 57 ++- CefSharp.Wpf/Internals/IMEHandler.cs | 24 +- CefSharp.Wpf/Internals/ImeNative.cs | 1 + CefSharp.props | 13 +- CefSharp/DependencyChecker.cs | 25 +- CefSharp/IWebBrowser.cs | 16 +- .../Partial/ChromiumWebBrowser.Partial.cs | 6 + CefSharp/RequestContextExtensions.cs | 23 + CefSharp/packages.config | 6 - CefSharp3.sln | 33 +- NuGet/CefSharp.Common.nuspec | 32 +- NuGet/CefSharp.Common.targets | 24 - NuGet/CefSharp.OffScreen.nuspec | 2 +- NuGet/CefSharp.WinForms.nuspec | 2 +- NuGet/CefSharp.Wpf.nuspec | 2 +- .../CefSharp.Common.NETCore.nuspec | 6 + .../CefSharp.Common.NETCore.targets | 6 +- .../CefSharp.OffScreen.NETCore.nuspec | 1 + .../CefSharp.WinForms.NETCore.nuspec | 1 + .../CefSharp.Wpf.NETCore.nuspec | 1 + UpdateNugetPackages.ps1 | 14 +- appveyor.yml | 4 +- build.netcore.ps1 | 337 -------------- build.ps1 | 410 ++++++++++++------ 46 files changed, 879 insertions(+), 1714 deletions(-) delete mode 100644 CefSharp.Core/packages.config delete mode 100644 CefSharp.Example/packages.config delete mode 100644 CefSharp.OffScreen.Example/packages.config create mode 100644 CefSharp.Test/QUnitTestResult.cs delete mode 100644 CefSharp.Test/packages.config delete mode 100644 CefSharp.WinForms.Example/packages.config delete mode 100644 CefSharp.Wpf.Example/packages.config delete mode 100644 CefSharp/packages.config delete mode 100644 build.netcore.ps1 diff --git a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj index e602d36625..41d9abf1d9 100644 --- a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj +++ b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj @@ -1,124 +1,40 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} - WinExe - Properties - CefSharp.BrowserSubprocess - CefSharp.BrowserSubprocess - v4.5.2 - - - 512 - - - x86 - true - full - false - bin\x86\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - x86 - pdbonly - true - bin\x86\Release\ - TRACE - prompt - 4 - false - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - bin\Debug\CefSharp.BrowserSubprocess.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - true - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - true - false - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - bin\Release\CefSharp.BrowserSubprocess.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - false - - - - - - true - - - ..\CefSharp.snk - - - app.manifest - - - OnOutputUpdated - - - - - - - - - - - - - - - - - - - - {6c4bb501-2f8e-48ac-9ab5-8cfb2d74185c} - CefSharp.BrowserSubprocess.Core - - - {a55848cc-10e7-40cb-addb-04740b16dd43} - CefSharp - - - - - - $(CefSharpBrowserSubprocessPostBuildEvent) - - + + + net452 + WinExe + x86;x64 + false + false + true + ..\CefSharp.snk + app.manifest + CefSharp.BrowserSubprocess.Program + win7-x86;win7-x64 + + + + full + + + true + true + pdbonly + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CefSharp.Core.Runtime/CefSettingsBase.h b/CefSharp.Core.Runtime/CefSettingsBase.h index 4e443cc183..36a220bd30 100644 --- a/CefSharp.Core.Runtime/CefSettingsBase.h +++ b/CefSharp.Core.Runtime/CefSettingsBase.h @@ -49,11 +49,6 @@ namespace CefSharp _cefCustomSchemes = gcnew List(); _cefCommandLineArgs = gcnew CommandLineArgDictionary(); - //Disable site isolation trials as this causes problems with frames - //being hosted in different render processes. - //https://github.com/cefsharp/CefSharp/issues/2967 - _cefCommandLineArgs->Add("disable-site-isolation-trials"); - //Disable Windows Spellchecker as CEF doesn't support yet //https://bitbucket.org/chromiumembedded/cef/issues/3055/windows-spell-checker-not-working-add _cefCommandLineArgs->Add("disable-features", "CalculateNativeWinOcclusion,WinUseBrowserSpellChecker"); diff --git a/CefSharp.Core/packages.config b/CefSharp.Core/packages.config deleted file mode 100644 index 29b036a9a5..0000000000 --- a/CefSharp.Core/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CefSharp.Example/CefSharp.Example.csproj b/CefSharp.Example/CefSharp.Example.csproj index 78a46abc8b..6a8530ed37 100644 --- a/CefSharp.Example/CefSharp.Example.csproj +++ b/CefSharp.Example/CefSharp.Example.csproj @@ -1,145 +1,20 @@ - - + - Debug - AnyCPU - 9.0.30729 - 2.0 - {A4394E7B-1155-43A6-989E-8AB72DDDC9E4} + net472 Library - Properties - CefSharp.Example - CefSharp.Example - v4.7.2 - 512 - - - - - 3.5 - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - AllRules.ruleset - false - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - AllRules.ruleset - false - true - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - AllRules.ruleset - false - true - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt + false AllRules.ruleset - false true - - - ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - - 3.5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + True True Resources.resx - - - - - + PublicResXFileCodeGenerator Resources.Designer.cs Designer @@ -152,13 +27,9 @@ - - - - @@ -192,25 +63,21 @@ - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - - - {b760b002-d277-4525-9f63-67ed2065034a} - CefSharp.Core - - - {a55848cc-10e7-40cb-addb-04740b16dd43} - CefSharp - + + + + + + + + + + + + + + + + - - \ No newline at end of file diff --git a/CefSharp.Example/packages.config b/CefSharp.Example/packages.config deleted file mode 100644 index 7c080311d6..0000000000 --- a/CefSharp.Example/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/CefSharp.Native.props b/CefSharp.Native.props index c7f1b65fbb..460c6c03e8 100644 --- a/CefSharp.Native.props +++ b/CefSharp.Native.props @@ -1,20 +1,52 @@ - - - - - - - - - - - + + + + + + - - - - - - \ No newline at end of file + + + + + + + locales\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + swiftshader\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + + + + + locales\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + swiftshader\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + + + diff --git a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj index 4ae511849b..f1c5f8e109 100644 --- a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj +++ b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj @@ -1,107 +1,39 @@ - - - - - - - Debug - x86 - {A4DEB90C-A529-4A93-ACE3-226A39EFCB00} - Exe - Properties - CefSharp.OffScreen.Example - CefSharp.OffScreen.Example - v4.7.2 - 512 - - - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - false - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - app.manifest - - - - - - - - - - - - - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - - - {b760b002-d277-4525-9f63-67ed2065034a} - CefSharp.Core - - - {a4394e7b-1155-43a6-989e-8ab72dddc9e4} - CefSharp.Example - - - {483b158d-f57d-49d9-9046-31e6a73f8a53} - CefSharp.OffScreen - - - {a55848cc-10e7-40cb-addb-04740b16dd43} - CefSharp - - - - - - - PreserveNewest - - - - - - + + + net472 + Exe + x86;x64 + MinimumRecommendedRules.ruleset + app.manifest + false + false + win7-x86;win7-x64 + + + + + + + + + + + + PreserveNewest + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CefSharp.OffScreen.Example/packages.config b/CefSharp.OffScreen.Example/packages.config deleted file mode 100644 index 4d66555dcf..0000000000 --- a/CefSharp.OffScreen.Example/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CefSharp.OffScreen/ChromiumWebBrowser.cs b/CefSharp.OffScreen/ChromiumWebBrowser.cs index 705fbf456a..961e6e7a24 100644 --- a/CefSharp.OffScreen/ChromiumWebBrowser.cs +++ b/CefSharp.OffScreen/ChromiumWebBrowser.cs @@ -510,18 +510,27 @@ public Task ScreenshotAsync(bool ignoreExistingScreenshot = false, Popup return completionSource.Task; } - /// - /// Loads the specified URL. - /// - /// The URL to be loaded. + /// public void Load(string url) { - Address = url; + if (IsDisposed) + { + return; + } - //Destroy the frame wrapper when we're done - using (var frame = this.GetMainFrame()) + //There's a small window here between CreateBrowser + //and OnAfterBrowserCreated where the Address prop + //will be updated, though LoadUrl won't be called. + if (IsBrowserInitialized) + { + using (var frame = this.GetMainFrame()) + { + frame.LoadUrl(url); + } + } + else { - frame.LoadUrl(url); + Address = url; } } diff --git a/CefSharp.Test/CefSharp.Test.csproj b/CefSharp.Test/CefSharp.Test.csproj index 39c0f01b52..43341ff645 100644 --- a/CefSharp.Test/CefSharp.Test.csproj +++ b/CefSharp.Test/CefSharp.Test.csproj @@ -1,230 +1,61 @@ - - - - - - - Debug - x86 - 9.0.30729 - 2.0 - {7A4D5447-183B-4A11-8E63-9848991B46FF} - Library - Properties - CefSharp.Test - CefSharp.Test - v4.7.2 - 512 - 7.3 - Client - - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - AllRules.ruleset - false - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - AllRules.ruleset - false - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - AllRules.ruleset - false - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - AllRules.ruleset - false - - - - ..\packages\Portable.BouncyCastle.1.8.5.2\lib\net40\BouncyCastle.Crypto.dll - - - ..\packages\BrotliSharpLib.0.3.3\lib\net451\BrotliSharpLib.dll - - - ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - - - ..\packages\Microsoft.Win32.Registry.4.7.0\lib\net461\Microsoft.Win32.Registry.dll - - - ..\packages\Moq.4.13.0\lib\net45\Moq.dll - - - - ..\packages\Nito.AsyncEx.Context.5.0.0\lib\netstandard2.0\Nito.AsyncEx.Context.dll - - - ..\packages\Nito.AsyncEx.Coordination.5.0.0\lib\netstandard2.0\Nito.AsyncEx.Coordination.dll - - - ..\packages\Nito.AsyncEx.Tasks.5.0.0\lib\netstandard2.0\Nito.AsyncEx.Tasks.dll - - - ..\packages\Nito.Collections.Deque.1.0.4\lib\netstandard2.0\Nito.Collections.Deque.dll - - - ..\packages\Nito.Disposables.2.0.0\lib\netstandard2.0\Nito.Disposables.dll - - - - - - ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll - - - - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - - - ..\packages\System.Security.AccessControl.4.7.0\lib\net461\System.Security.AccessControl.dll - - - ..\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll - - - - ..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll - - - - - ..\packages\Titanium.Web.Proxy.3.1.1301\lib\net461\Titanium.Web.Proxy.dll - - - - ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll - - - ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll - - - ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll - - - ..\packages\Xunit.StaFact.0.3.18\lib\net452\Xunit.StaFact.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - - - {b760b002-d277-4525-9f63-67ed2065034a} - CefSharp.Core - - - {a4394e7b-1155-43a6-989e-8ab72dddc9e4} - CefSharp.Example - - - {483b158d-f57d-49d9-9046-31e6a73f8a53} - CefSharp.OffScreen - True - - - {882505ad-246d-402a-8414-347efb8e2c8d} - CefSharp.WinForms - - - {e6cb3790-f267-4ac7-892c-2620737682ca} - CefSharp.Wpf - - - {a55848cc-10e7-40cb-addb-04740b16dd43} - CefSharp - True - - - - - - - - - - - - - - + + + net472 + Library + x86;x64 + win7-x86;win7-x64 + false + true + true + AllRules.ruleset + false + + + + win7-x86 + + + + win7-x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CefSharp.Test/Framework/RequestContextExtensionFacts.cs b/CefSharp.Test/Framework/RequestContextExtensionFacts.cs index a174c114b0..5531f64dd1 100644 --- a/CefSharp.Test/Framework/RequestContextExtensionFacts.cs +++ b/CefSharp.Test/Framework/RequestContextExtensionFacts.cs @@ -4,12 +4,15 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Moq; using Xunit; using Xunit.Abstractions; namespace CefSharp.Test.Framework { + //NOTE: All Test classes must be part of this collection as it manages the Cef Initialize/Shutdown lifecycle + [Collection(CefSharpFixtureCollection.Key)] public class RequestContextExtensionFacts { private const string ProxyPreferenceKey = "proxy"; @@ -70,5 +73,20 @@ public void SetProxyThrowsExceptionOnInvalidScheme() mockRequestContext.Object.SetProxy("myscheme", "localhost", 0, out msg); }); } + + [Fact] + public async Task CanGetCookieManagerForRequestContextAsync() + { + var requestContext = RequestContext + .Configure() + .Create(); + + var cookieManager = await requestContext.GetCookieManagerAsync(); + + var cookies = await cookieManager.VisitAllCookiesAsync(); + + Assert.NotNull(cookies); + output.WriteLine("Cookie Count {0}", cookies.Count); + } } } diff --git a/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs b/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs index 87753d95b3..769974a758 100644 --- a/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs +++ b/CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs @@ -48,11 +48,17 @@ public async Task LoadJavaScriptBindingQunitTestsSuccessfulCompletion() repo.Register("boundAsync2", new AsyncBoundObject(), options: bindingOptions); browser.CreateBrowser(); - var success = await browser.WaitForQUnitTestExeuctionToComplete(); + var response = await browser.WaitForQUnitTestExeuctionToComplete(); - Assert.True(success); + if (!response.Success) + { + output.WriteLine("QUnit Passed : {0}", response.Total); + output.WriteLine("QUnit Total : {0}", response.Passed); + } + + Assert.True(response.Success); - output.WriteLine("QUnit Tests result: {0}", success); + output.WriteLine("QUnit Tests result: {0}", response.Success); } } #else @@ -70,11 +76,17 @@ public async Task LoadJavaScriptBindingQunitTestsSuccessfulCompletion() repo.Register("boundAsync2", new AsyncBoundObject(), isAsync: true, options: bindingOptions); browser.CreateBrowser(); - var success = await browser.WaitForQUnitTestExeuctionToComplete(); + var response = await browser.WaitForQUnitTestExeuctionToComplete(); + + if (!response.Success) + { + output.WriteLine("QUnit Passed : {0}", response.Total); + output.WriteLine("QUnit Total : {0}", response.Passed); + } - Assert.True(success); + Assert.True(response.Success); - output.WriteLine("QUnit Tests result: {0}", success); + output.WriteLine("QUnit Tests result: {0}", response.Success); } } @@ -92,11 +104,17 @@ public async Task LoadLegacyJavaScriptBindingQunitTestsSuccessfulCompletion() repo.Register("boundAsync", new AsyncBoundObject(), isAsync: true, options: bindingOptions); browser.CreateBrowser(); - var success = await browser.WaitForQUnitTestExeuctionToComplete(); + var response = await browser.WaitForQUnitTestExeuctionToComplete(); + + if(!response.Success) + { + output.WriteLine("QUnit Passed : {0}", response.Total); + output.WriteLine("QUnit Total : {0}", response.Passed); + } - Assert.True(success); + Assert.True(response.Success); - output.WriteLine("QUnit Tests result: {0}", success); + output.WriteLine("QUnit Tests result: {0}", response.Success); } } #endif diff --git a/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs b/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs index ba9345dd5d..16b1689d98 100644 --- a/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs +++ b/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs @@ -572,8 +572,11 @@ public async Task CanExecuteJavascriptInMainFrameAfterNavigatingToDifferentOrigi public async Task CanLoadRequestWithPostData(string url) { const string data = "Testing123"; - //To use LoadRequest we must first load a web page - using (var browser = new ChromiumWebBrowser(new HtmlString("Testing"))) + //When Chromium Site Isolation is enabled we must first navigate to + //a web page of the same origin to use LoadRequest + //When Site Isolation is disabled we can navigate to any web page + //https://magpcss.org/ceforum/viewtopic.php?f=10&t=18672&p=50266#p50249 + using (var browser = new ChromiumWebBrowser("http://httpbin.org/")) { var response = await browser.LoadUrlAsync(); diff --git a/CefSharp.Test/QUnitTestResult.cs b/CefSharp.Test/QUnitTestResult.cs new file mode 100644 index 0000000000..9160b0e17a --- /dev/null +++ b/CefSharp.Test/QUnitTestResult.cs @@ -0,0 +1,17 @@ +// Copyright © 2021 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +namespace CefSharp.Test +{ + public class QUnitTestResult + { + public bool Success + { + get { return Passed == Total; } + } + + public int Passed { get; set; } + public int Total { get; set; } + } +} diff --git a/CefSharp.Test/WebBrowserTestExtensions.cs b/CefSharp.Test/WebBrowserTestExtensions.cs index ad2ccfcd5c..76b9d57b6e 100644 --- a/CefSharp.Test/WebBrowserTestExtensions.cs +++ b/CefSharp.Test/WebBrowserTestExtensions.cs @@ -76,11 +76,11 @@ public static Task LoadRequestAsync(this IWebBrowser brows return tcs.Task; } - public static Task WaitForQUnitTestExeuctionToComplete(this IWebBrowser browser) + public static Task WaitForQUnitTestExeuctionToComplete(this IWebBrowser browser) { //If using .Net 4.6 then use TaskCreationOptions.RunContinuationsAsynchronously //and switch to tcs.TrySetResult below - no need for the custom extension method - var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); EventHandler handler = null; handler = (sender, args) => @@ -95,7 +95,7 @@ public static Task WaitForQUnitTestExeuctionToComplete(this IWebBrowser br var total = (int)details.total; var passed = (int)details.passed; - tcs.TrySetResult(total == passed); + tcs.TrySetResult(new QUnitTestResult { Passed = passed, Total = total }); } else { diff --git a/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs b/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs index cecaa99ea3..82909b0de2 100644 --- a/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs +++ b/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs @@ -38,6 +38,43 @@ public async Task CanLoadGoogle() } } + [WpfFact] + public async Task CanCallLoadUrlAsyncImmediately() + { + using (var browser = new ChromiumWebBrowser(null, string.Empty, new Size(1024, 786))) + { + var response = await browser.LoadUrlAsync("www.google.com"); + + Assert.True(response.Success); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + Assert.Contains("www.google", mainFrame.Url); + + output.WriteLine("Url {0}", mainFrame.Url); + } + } + + [WpfFact] + public async Task CanCallLoadUrlImmediately() + { + using (var browser = new ChromiumWebBrowser()) + { + browser.Load("www.google.com"); + browser.CreateBrowser(null, new Size(1024, 786)); + + var response = await browser.LoadUrlAsync(); + + Assert.True(response.Success); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + Assert.Contains("www.google", mainFrame.Url); + + output.WriteLine("Url {0}", mainFrame.Url); + } + } + [WpfFact] public async Task CanSetRequestContext() { diff --git a/CefSharp.Test/packages.config b/CefSharp.Test/packages.config deleted file mode 100644 index 2412ed401a..0000000000 --- a/CefSharp.Test/packages.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index 41ee4fbcdc..33c36223ac 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -1,195 +1,49 @@ - - - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {C043FFF7-5F71-4FFC-989A-E09E18548589} - WinExe - Properties - CefSharp.WinForms.Example - CefSharp.WinForms.Example - v4.7.2 - 512 - - - - - - - 3.5 - Client - - - - - - x64 - bin\x64\Debug\ - false - - - x64 - bin\x64\Release\ - false - - - true - bin\x86\Debug\ - x86 - MinimumRecommendedRules.ruleset - false - DEBUG - - - bin\x86\Release\ - x86 - MinimumRecommendedRules.ruleset - false - - - app.manifest - - - - - 3.5 - - - - - - - - - - Form - - - AboutBox.cs - - - Form - - - BrowserForm.cs - - - UserControl - - - BrowserTabUserControl.cs - - - - - - - - - - Form - - - InputBox.cs - - - - Form - - - SimpleBrowserForm.cs - - - Form - - - TabulationDemoForm.cs - - - - - - True - True - Resources.resx - - - - - AboutBox.cs - Designer - - - BrowserForm.cs - Designer - - - BrowserTabUserControl.cs - Designer - - - InputBox.cs - - - SimpleBrowserForm.cs - - - TabulationDemoForm.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - - - - - PreserveNewest - - - - - - - - - - - - - - - - - - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - - - {b760b002-d277-4525-9f63-67ed2065034a} - CefSharp.Core - - - {a4394e7b-1155-43a6-989e-8ab72dddc9e4} - CefSharp.Example - - - {882505ad-246d-402a-8414-347efb8e2c8d} - CefSharp.WinForms - - - {a55848cc-10e7-40cb-addb-04740b16dd43} - CefSharp - - - - - + + + net472 + WinExe + x86;x64 + false + true + MinimumRecommendedRules.ruleset + app.manifest + CefSharp.WinForms.Example.Program + false + win7-x86;win7-x64 + + + + + + + + UserControl + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CefSharp.WinForms.Example/packages.config b/CefSharp.WinForms.Example/packages.config deleted file mode 100644 index 4d66555dcf..0000000000 --- a/CefSharp.WinForms.Example/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CefSharp.WinForms/ChromiumWebBrowser.cs b/CefSharp.WinForms/ChromiumWebBrowser.cs index 65c02006e9..960a438fe6 100644 --- a/CefSharp.WinForms/ChromiumWebBrowser.cs +++ b/CefSharp.WinForms/ChromiumWebBrowser.cs @@ -446,12 +446,17 @@ private void InternalDispose(bool disposing) Cef.RemoveDisposable(this); } - /// - /// Loads the specified URL. - /// - /// The URL to be loaded. + /// public void Load(string url) { + if (IsDisposed) + { + return; + } + + //There's a small window here between CreateBrowser + //and OnAfterBrowserCreated where the Address prop + //will be updated, though LoadUrl won't be called. if (IsBrowserInitialized) { using (var frame = this.GetMainFrame()) diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index fa933eca9c..931a5c3696 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -1,205 +1,47 @@ - - - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {4828DAEC-EF99-4553-B674-4374F77C6D66} - WinExe - Properties - CefSharp.Wpf.Example - CefSharp.Wpf.Example - v4.7.2 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - - - 3.5 - Client - - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - AllRules.ruleset - false - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - AllRules.ruleset - false - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - AllRules.ruleset - false - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - AllRules.ruleset - false - - - app.manifest - - - CefSharp.Wpf.Example.Program - - - - - - 3.5 - - - - - - - - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - - - - - - - - - - - - JavascriptCallbackMainWindow.xaml - - - - StandardTabControlWindow.xaml - - - TouchKeyboardWin10MainWindow.xaml - - - SimpleMainWindow.xaml - - - SpawnBrowsersWindow.xaml - - - BrowserTabView.xaml - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - - - Code - - - - - - - - - PreserveNewest - - - - - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - - - {b760b002-d277-4525-9f63-67ed2065034a} - CefSharp.Core - - - {a4394e7b-1155-43a6-989e-8ab72dddc9e4} - CefSharp.Example - - - {e6cb3790-f267-4ac7-892c-2620737682ca} - CefSharp.Wpf - - - {a55848cc-10e7-40cb-addb-04740b16dd43} - CefSharp - - - - - - - - + + + net472 + WinExe + x86;x64 + false + true + AllRules.ruleset + app.manifest + CefSharp.Wpf.Example.Program + false + win7-x86;win7-x64 + + + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CefSharp.Wpf.Example/packages.config b/CefSharp.Wpf.Example/packages.config deleted file mode 100644 index 4d66555dcf..0000000000 --- a/CefSharp.Wpf.Example/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index b19984ea85..a6740abca0 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -89,7 +89,12 @@ public partial class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBro /// /// Initial address /// - private readonly string initialAddress; + private string initialAddress; + /// + /// Used to stop multiple threads trying to load the initial Url multiple times. + /// If the Address property is bound after the browser is initialized + /// + private bool initialLoadCalled; /// /// Has the underlying Cef Browser been created (slightly different to initialized in that /// the browser is initialized in an async fashion) @@ -1109,7 +1114,7 @@ partial void OnAfterBrowserCreated(IBrowser browser) SetCurrentValue(IsBrowserInitializedProperty, true); // Only call Load if initialAddress is null and Address is not empty - if (string.IsNullOrEmpty(initialAddress) && !string.IsNullOrEmpty(Address)) + if (string.IsNullOrEmpty(initialAddress) && !string.IsNullOrEmpty(Address) && !initialLoadCalled) { Load(Address); } @@ -1794,8 +1799,9 @@ protected virtual bool CreateOffscreenBrowser(Size size) if (!webBrowserInternal.HasParent) { var windowInfo = CreateOffscreenBrowserWindowInfo(source == null ? IntPtr.Zero : source.Handle); - //Pass null in for Address and rely on Load being called in OnAfterBrowserCreated - //Workaround for issue https://github.com/cefsharp/CefSharp/issues/2300 + //If initialAddress is set then we use that value, later in OnAfterBrowserCreated then we will + //call Load(url) if initial address was empty. + //Issue https://github.com/cefsharp/CefSharp/issues/2300 managedCefBrowserAdapter.CreateBrowser(windowInfo, browserSettings, requestContext, address: initialAddress); //Dispose of BrowserSettings if we created it, if user created then they're responsible @@ -2414,27 +2420,46 @@ protected override AutomationPeer OnCreateAutomationPeer() } - /// - /// Loads the specified URL. - /// - /// The URL to be loaded. + /// public void Load(string url) { - if (!InternalIsBrowserInitialized()) + if(IsDisposed) { - throw new Exception("The browser has not been initialized. Load can only be called " + - "after the underlying CEF browser is initialized (CefLifeSpanHandler::OnAfterCreated)."); + return; } - // Added null check -> binding-triggered changes of Address will lead to a nullref after Dispose has been called - // or before OnApplyTemplate has been called - if (browser != null) + //If the browser is already initialized then we can call LoadUrl directly + if (InternalIsBrowserInitialized()) { - using (var frame = browser.MainFrame) + // Added null check -> binding-triggered changes of Address will lead to a nullref after Dispose has been called + // or before OnApplyTemplate has been called + if (browser != null) { - frame.LoadUrl(url); + initialLoadCalled = true; + + using (var frame = browser.MainFrame) + { + frame.LoadUrl(url); + } } } + //If CreateBrowser was called and InternalIsBrowserInitialized() == false then we need to set the Address + //property so in OnAfterBrowserCreated the Url is loaded. If initialAddress was + //set then the Url set here will be ignored. If we called Load(url) then historically + //an aborted error would be raised as per https://github.com/cefsharp/CefSharp/issues/2300 + //So we ignore the call for now. + else if (browserCreated) + { + UiThreadRunAsync(() => + { + Address = url; + }); + } + //Before browser created, set the intialAddress + else + { + initialAddress = url; + } } /// diff --git a/CefSharp.Wpf/Internals/IMEHandler.cs b/CefSharp.Wpf/Internals/IMEHandler.cs index 168d1313ff..1bcfdb8799 100644 --- a/CefSharp.Wpf/Internals/IMEHandler.cs +++ b/CefSharp.Wpf/Internals/IMEHandler.cs @@ -75,11 +75,12 @@ private static void GetCompositionInfo(IntPtr hwnd, uint lParam, string text, Li underlines.Clear(); + byte[] attributes = null; int targetStart = text.Length; int targetEnd = text.Length; if (IsParam(lParam, ImeNative.GCS_COMPATTR)) { - GetCompositionSelectionRange(hIMC, ref targetStart, ref targetEnd); + attributes = GetCompositionSelectionRange(hIMC, ref targetStart, ref targetEnd); } // Retrieve the selection range information. If CS_NOMOVECARET is specified @@ -98,6 +99,22 @@ private static void GetCompositionInfo(IntPtr hwnd, uint lParam, string text, Li compositionStart = 0; } + if (attributes != null && + // character before + ((compositionStart > 0 && (compositionStart - 1) < attributes.Length && attributes[compositionStart - 1] == ImeNative.ATTR_INPUT) + || + // character after + (compositionStart >= 0 && compositionStart < attributes.Length && attributes[compositionStart] == ImeNative.ATTR_INPUT))) + { + // as MS does with their ime implementation we should only use the GCS_CURSORPOS if the character + // before or after is new input. + // https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/windows/Documents/ImmComposition.cs,1079 + } + else + { + compositionStart = text.Length; + } + if (IsParam(lParam, ImeNative.GCS_COMPCLAUSE)) { GetCompositionUnderlines(hIMC, targetStart, targetEnd, underlines); @@ -158,12 +175,12 @@ private static void GetCompositionUnderlines(IntPtr hIMC, int targetStart, int t } } - private static void GetCompositionSelectionRange(IntPtr hIMC, ref int targetStart, ref int targetEnd) + private static byte[] GetCompositionSelectionRange(IntPtr hIMC, ref int targetStart, ref int targetEnd) { var attributeSize = ImeNative.ImmGetCompositionString(hIMC, ImeNative.GCS_COMPATTR, null, 0); if (attributeSize <= 0) { - return; + return null; } int start = 0; @@ -191,6 +208,7 @@ private static void GetCompositionSelectionRange(IntPtr hIMC, ref int targetStar targetStart = start; targetEnd = end; + return attributeData; } private static bool IsSelectionAttribute(byte attribute) diff --git a/CefSharp.Wpf/Internals/ImeNative.cs b/CefSharp.Wpf/Internals/ImeNative.cs index 14e9bbbdf6..3d1045a5ac 100644 --- a/CefSharp.Wpf/Internals/ImeNative.cs +++ b/CefSharp.Wpf/Internals/ImeNative.cs @@ -19,6 +19,7 @@ public static class ImeNative internal const uint CS_NOMOVECARET = 0x4000; internal const uint NI_COMPOSITIONSTR = 0x0015; + internal const uint ATTR_INPUT = 0x00; internal const uint ATTR_TARGET_CONVERTED = 0x01; internal const uint ATTR_TARGET_NOTCONVERTED = 0x03; diff --git a/CefSharp.props b/CefSharp.props index 5c6685b810..0ac7a333a2 100644 --- a/CefSharp.props +++ b/CefSharp.props @@ -13,19 +13,8 @@ v142--> 10.0 - - - - + public const string LocalesPackFile = @"locales\en-US.pak"; + /// + /// File name of the Direct3D Compiler DLL. + /// + private const string D3DCompilerDll = "d3dcompiler_47.dll"; + /// /// List of Cef Dependencies /// @@ -60,7 +71,8 @@ public static class DependencyChecker // Note: Without these components HTML5 accelerated content like 2D canvas, 3D CSS and WebGL will not function. "libEGL.dll", "libGLESv2.dll", - "d3dcompiler_47.dll", + // The D3D Compiler isn't included in the win-arm64 redist; we remove it in the static constructor. + D3DCompilerDll, //Crashpad support "chrome_elf.dll" }; @@ -99,6 +111,17 @@ public static class DependencyChecker #endif }; +#if NETCOREAPP + static DependencyChecker() + { + // win-arm64 doesn't ship with a copy of the D3D Compiler, it's included with the OS. + if (RuntimeInformation.ProcessArchitecture is Architecture.Arm64) + { + CefOptionalDependencies = CefOptionalDependencies.Where(x => x != D3DCompilerDll).ToArray(); + } + } +#endif + /// /// CheckDependencies iterates through the list of Cef and CefSharp dependencines /// relative to the path provided and returns a list of missing ones diff --git a/CefSharp/IWebBrowser.cs b/CefSharp/IWebBrowser.cs index eb5866a91f..3ac4b1aa81 100644 --- a/CefSharp/IWebBrowser.cs +++ b/CefSharp/IWebBrowser.cs @@ -81,11 +81,25 @@ public interface IWebBrowser : IDisposable event EventHandler JavascriptMessageReceived; /// - /// Loads the specified in the Main Frame + /// Loads the specified in the Main Frame. + /// If is true then the method call will be ignored. + /// Same as calling /// /// The URL to be loaded. void Load(string url); + /// + /// Loads the specified in the Main Frame. + /// Same as calling + /// + /// The URL to be loaded. + /// + /// This is exactly the same as calling Load(string), it was added + /// as the method name is more meaningful and easier to discover + /// via Intellisense. + /// + void LoadUrl(string url); + /// /// Load the in the main frame of the browser /// diff --git a/CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs b/CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs index 100a3686be..0bd3692738 100644 --- a/CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs +++ b/CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs @@ -320,6 +320,12 @@ void IWebBrowserInternal.OnAfterBrowserCreated(IBrowser browser) OnAfterBrowserCreated(browser); } + /// + public void LoadUrl(string url) + { + Load(url); + } + /// public Task LoadUrlAsync(string url = null, SynchronizationContext ctx = null) { diff --git a/CefSharp/RequestContextExtensions.cs b/CefSharp/RequestContextExtensions.cs index 78d8e694ef..b3f3cef55a 100644 --- a/CefSharp/RequestContextExtensions.cs +++ b/CefSharp/RequestContextExtensions.cs @@ -59,6 +59,29 @@ public static void LoadExtensionsFromDirectory(this IRequestContext requestConte } } + /// + /// Gets the cookie manager associated with the . Once the cookie manager + /// storage has been initialized the method will return. + /// + /// Thrown when an exception error condition occurs. + /// The instance this method extends. + /// returns if the store was successfully loaded otherwise null. + public static async Task GetCookieManagerAsync(this IRequestContext requestContext) + { + if (requestContext == null) + { + throw new Exception("RequestContext is null, unable to obtain cookie manager"); + } + + var callback = new TaskCompletionCallback(); + + var cookieManager = requestContext.GetCookieManager(callback); + + var success = await callback.Task; + + return success ? cookieManager : null; + } + /// /// Set the value associated with preference name. If value is null the /// preference will be restored to its default value. If setting the preference diff --git a/CefSharp/packages.config b/CefSharp/packages.config deleted file mode 100644 index 29b036a9a5..0000000000 --- a/CefSharp/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CefSharp3.sln b/CefSharp3.sln index cf405b38aa..b24e35d67d 100644 --- a/CefSharp3.sln +++ b/CefSharp3.sln @@ -3,9 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30804.86 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Example", "CefSharp.Example\CefSharp.Example.csproj", "{A4394E7B-1155-43A6-989E-8AB72DDDC9E4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Example", "CefSharp.Example\CefSharp.Example.csproj", "{A4394E7B-1155-43A6-989E-8AB72DDDC9E4}" + ProjectSection(ProjectDependencies) = postProject + {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} = {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} + EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Wpf.Example", "CefSharp.Wpf.Example\CefSharp.Wpf.Example.csproj", "{4828DAEC-EF99-4553-B674-4374F77C6D66}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Wpf.Example", "CefSharp.Wpf.Example\CefSharp.Wpf.Example.csproj", "{4828DAEC-EF99-4553-B674-4374F77C6D66}" ProjectSection(ProjectDependencies) = postProject {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} = {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} {E6CB3790-F267-4AC7-892C-2620737682CA} = {E6CB3790-F267-4AC7-892C-2620737682CA} @@ -23,22 +26,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Wpf", "CefSharp.Wpf\CefSharp.Wpf.csproj", "{E6CB3790-F267-4AC7-892C-2620737682CA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Wpf", "CefSharp.Wpf\CefSharp.Wpf.csproj", "{E6CB3790-F267-4AC7-892C-2620737682CA}" ProjectSection(ProjectDependencies) = postProject {7B495581-2271-4F41-9476-ACB86E8C864F} = {7B495581-2271-4F41-9476-ACB86E8C864F} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.BrowserSubprocess", "CefSharp.BrowserSubprocess\CefSharp.BrowserSubprocess.csproj", "{23EE5140-2C2C-4B53-A954-10B08DCA6BD6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.BrowserSubprocess", "CefSharp.BrowserSubprocess\CefSharp.BrowserSubprocess.csproj", "{23EE5140-2C2C-4B53-A954-10B08DCA6BD6}" ProjectSection(ProjectDependencies) = postProject {6C4BB501-2F8E-48AC-9AB5-8CFB2D74185C} = {6C4BB501-2F8E-48AC-9AB5-8CFB2D74185C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.WinForms", "CefSharp.WinForms\CefSharp.WinForms.csproj", "{882505AD-246D-402A-8414-347EFB8E2C8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.WinForms", "CefSharp.WinForms\CefSharp.WinForms.csproj", "{882505AD-246D-402A-8414-347EFB8E2C8D}" ProjectSection(ProjectDependencies) = postProject {7B495581-2271-4F41-9476-ACB86E8C864F} = {7B495581-2271-4F41-9476-ACB86E8C864F} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.WinForms.Example", "CefSharp.WinForms.Example\CefSharp.WinForms.Example.csproj", "{C043FFF7-5F71-4FFC-989A-E09E18548589}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.WinForms.Example", "CefSharp.WinForms.Example\CefSharp.WinForms.Example.csproj", "{C043FFF7-5F71-4FFC-989A-E09E18548589}" ProjectSection(ProjectDependencies) = postProject {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} = {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} EndProjectSection @@ -59,7 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{A23AA466 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CefSharp.Core.Runtime", "CefSharp.Core.Runtime\CefSharp.Core.Runtime.vcxproj", "{7B495581-2271-4F41-9476-ACB86E8C864F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp", "CefSharp\CefSharp.csproj", "{A55848CC-10E7-40CB-ADDB-04740B16DD43}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp", "CefSharp\CefSharp.csproj", "{A55848CC-10E7-40CB-ADDB-04740B16DD43}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CefSharp.BrowserSubprocess.Core", "CefSharp.BrowserSubprocess.Core\CefSharp.BrowserSubprocess.Core.vcxproj", "{6C4BB501-2F8E-48AC-9AB5-8CFB2D74185C}" EndProject @@ -68,19 +71,19 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{9AD9C469 build.ps1 = build.ps1 EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.OffScreen", "CefSharp.OffScreen\CefSharp.OffScreen.csproj", "{483B158D-F57D-49D9-9046-31E6A73F8A53}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.OffScreen", "CefSharp.OffScreen\CefSharp.OffScreen.csproj", "{483B158D-F57D-49D9-9046-31E6A73F8A53}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.OffScreen.Example", "CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.csproj", "{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.OffScreen.Example", "CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.csproj", "{A4DEB90C-A529-4A93-ACE3-226A39EFCB00}" ProjectSection(ProjectDependencies) = postProject {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} = {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Test", "CefSharp.Test\CefSharp.Test.csproj", "{7A4D5447-183B-4A11-8E63-9848991B46FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Test", "CefSharp.Test\CefSharp.Test.csproj", "{7A4D5447-183B-4A11-8E63-9848991B46FF}" ProjectSection(ProjectDependencies) = postProject {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} = {23EE5140-2C2C-4B53-A954-10B08DCA6BD6} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Core", "CefSharp.Core\CefSharp.Core.csproj", "{B760B002-D277-4525-9F63-67ED2065034A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Core", "CefSharp.Core\CefSharp.Core.csproj", "{B760B002-D277-4525-9F63-67ED2065034A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -90,10 +93,10 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|Win32.ActiveCfg = Debug|x86 - {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|Win32.Build.0 = Debug|x86 - {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|x64.ActiveCfg = Debug|x64 - {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|x64.Build.0 = Debug|x64 + {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|Win32.ActiveCfg = Debug|Any CPU + {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|Win32.Build.0 = Debug|Any CPU + {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|x64.ActiveCfg = Debug|Any CPU + {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Debug|x64.Build.0 = Debug|Any CPU {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Release|Win32.ActiveCfg = Release|x86 {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Release|Win32.Build.0 = Release|x86 {A4394E7B-1155-43A6-989E-8AB72DDDC9E4}.Release|x64.ActiveCfg = Release|x64 diff --git a/NuGet/CefSharp.Common.nuspec b/NuGet/CefSharp.Common.nuspec index c4c268dd67..de89adceff 100644 --- a/NuGet/CefSharp.Common.nuspec +++ b/NuGet/CefSharp.Common.nuspec @@ -12,8 +12,10 @@ chrome browser Copyright © The CefSharp Authors - - + + + + @@ -24,32 +26,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/NuGet/CefSharp.Common.targets b/NuGet/CefSharp.Common.targets index b13edcbfce..4c8e627859 100644 --- a/NuGet/CefSharp.Common.targets +++ b/NuGet/CefSharp.Common.targets @@ -147,30 +147,6 @@ - - - - - - runtimes\win-x64\lib\netcoreapp3.0\ - - - - - runtimes\win-x86\lib\netcoreapp3.0\ - - - - - runtimes\win-x86\lib\netcoreapp3.0\ - runtimes\win-x64\lib\netcoreapp3.0\ - - - - + + + + + + diff --git a/NuGet/PackageReference/CefSharp.Common.NETCore.targets b/NuGet/PackageReference/CefSharp.Common.NETCore.targets index 887a122d4d..7bf7c4ebcc 100644 --- a/NuGet/PackageReference/CefSharp.Common.NETCore.targets +++ b/NuGet/PackageReference/CefSharp.Common.NETCore.targets @@ -147,9 +147,9 @@ - - - + + + runtimes\win-x86\native\locales\%(RecursiveDir)%(FileName)%(Extension) PreserveNewest diff --git a/NuGet/PackageReference/CefSharp.OffScreen.NETCore.nuspec b/NuGet/PackageReference/CefSharp.OffScreen.NETCore.nuspec index f88654af55..f2f8d6458c 100644 --- a/NuGet/PackageReference/CefSharp.OffScreen.NETCore.nuspec +++ b/NuGet/PackageReference/CefSharp.OffScreen.NETCore.nuspec @@ -28,6 +28,7 @@ + diff --git a/NuGet/PackageReference/CefSharp.WinForms.NETCore.nuspec b/NuGet/PackageReference/CefSharp.WinForms.NETCore.nuspec index 43cc826e52..ad7c9db58e 100644 --- a/NuGet/PackageReference/CefSharp.WinForms.NETCore.nuspec +++ b/NuGet/PackageReference/CefSharp.WinForms.NETCore.nuspec @@ -27,6 +27,7 @@ + diff --git a/NuGet/PackageReference/CefSharp.Wpf.NETCore.nuspec b/NuGet/PackageReference/CefSharp.Wpf.NETCore.nuspec index 5e631c557a..58831ddd14 100644 --- a/NuGet/PackageReference/CefSharp.Wpf.NETCore.nuspec +++ b/NuGet/PackageReference/CefSharp.Wpf.NETCore.nuspec @@ -27,6 +27,7 @@ + diff --git a/UpdateNugetPackages.ps1 b/UpdateNugetPackages.ps1 index b47ea25c8b..88dfafd7c9 100644 --- a/UpdateNugetPackages.ps1 +++ b/UpdateNugetPackages.ps1 @@ -41,26 +41,16 @@ foreach($file in $vcxprojFiles) RemoveEnsureNuGetPackageBuildImports (Resolve-Path $file) } -$csprojFiles = @('CefSharp.WinForms.Example\CefSharp.WinForms.Example.csproj','CefSharp.Wpf.Example\CefSharp.Wpf.Example.csproj','CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.csproj', 'CefSharp.Test\CefSharp.Test.csproj') - -foreach($file in $csprojFiles) -{ - ..\nuget update $file -Id cef.redist.x64 -Version $CefVersion - ..\nuget update $file -Id cef.redist.x86 -Version $CefVersion - - RemoveEnsureNuGetPackageBuildImports (Resolve-Path $file) -} - #Read the newly updated version number from the packages.CefSharp.Core.Runtime.config $CefSharpCorePackagesXml = [xml](Get-Content (Resolve-Path 'CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.config')) $RedistVersion = $CefSharpCorePackagesXml.SelectSingleNode("//packages/package[@id='cef.sdk']/@version").value -$netcorecsprojFiles = @('CefSharp.WinForms.Example\CefSharp.WinForms.Example.netcore.csproj','CefSharp.Wpf.Example\CefSharp.Wpf.Example.netcore.csproj','CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.netcore.csproj', 'CefSharp.Test\CefSharp.Test.netcore.csproj') +$csprojFiles = @('CefSharp.WinForms.Example\CefSharp.WinForms.Example.netcore.csproj','CefSharp.Wpf.Example\CefSharp.Wpf.Example.netcore.csproj','CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.netcore.csproj', 'CefSharp.Test\CefSharp.Test.netcore.csproj', 'CefSharp.WinForms.Example\CefSharp.WinForms.Example.csproj','CefSharp.Wpf.Example\CefSharp.Wpf.Example.csproj','CefSharp.OffScreen.Example\CefSharp.OffScreen.Example.csproj', 'CefSharp.Test\CefSharp.Test.csproj') #Loop through the net core example projects and update the package version number -foreach($file in $netcorecsprojFiles) +foreach($file in $csprojFiles) { $file = Resolve-Path $file $xml = New-Object xml diff --git a/appveyor.yml b/appveyor.yml index b6cbec9559..afc054a7e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,11 +8,11 @@ configuration: Release build_script: - ps: .\build.ps1 - - ps: .\build.netcore.ps1 + - ps: .\build.ps1 -TargetFramework NetCore test_script: # Test our Release x64 build - - dotnet test CefSharp.Test\bin\x64\Release\CefSharp.Test.dll + - dotnet test CefSharp.Test\bin\x64\Release\win7-x64\CefSharp.Test.dll - dotnet test CefSharp.Test\bin.netcore\x64\Release\netcoreapp3.1\win-x64\CefSharp.Test.dll artifacts: diff --git a/build.netcore.ps1 b/build.netcore.ps1 deleted file mode 100644 index c2f7ab6474..0000000000 --- a/build.netcore.ps1 +++ /dev/null @@ -1,337 +0,0 @@ -param( - [ValidateSet("netcore31", "nupkg-only")] - [Parameter(Position = 0)] - [string] $Target = "netcore31", - [Parameter(Position = 1)] - [string] $Version = "94.4.20", - [Parameter(Position = 2)] - [string] $AssemblyVersion = "94.4.20" -) - -$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition -$CefSln = Join-Path $WorkingDir 'CefSharp3.netcore.sln' -$nuget = Join-Path $WorkingDir .\nuget\NuGet.exe - -# Extract the current CEF Redist version from the CefSharp.Runtime.Core\packages.CefSharp.Core.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.netcore.config')) -$RedistVersion = $CefSharpCorePackagesXml.SelectSingleNode("//packages/package[@id='cef.sdk']/@version").value - -function Write-Diagnostic -{ - param( - [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] - [string] $Message - ) - - Write-Host - Write-Host $Message -ForegroundColor Green - 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" -} - -function Die -{ - param( - [Parameter(Position = 0, ValueFromPipeline = $true)] - [string] $Message - ) - - Write-Host - Write-Error $Message - exit 1 -} - -# https://github.com/jbake/Powershell_scripts/blob/master/Invoke-BatchFile.ps1 -function Invoke-BatchFile -{ - param( - [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] - [string]$Path, - [Parameter(Position = 1, Mandatory = $true, ValueFromPipeline = $true)] - [string]$Parameters - ) - - $tempFile = [IO.Path]::GetTempFileName() - - cmd.exe /c " `"$Path`" $Parameters && set > `"$tempFile`" " - - Get-Content $tempFile | Foreach-Object { - if ($_ -match "^(.*?)=(.*)$") - { - Set-Content "env:\$($matches[1])" $matches[2] - } - } - - Remove-Item $tempFile -} - -function Msvs -{ - param( - [Parameter(Position = 0, ValueFromPipeline = $true)] - [ValidateSet('Debug', 'Release')] - [string] $Configuration, - - [Parameter(Position = 1, ValueFromPipeline = $true)] - [ValidateSet('x86', 'x64', 'arm64')] - [string] $Platform - ) - - Write-Diagnostic "Targeting configuration $Configuration on platform $Platform" - - $Arguments = @( - "$CefSln", - "/t:build", - "/p:Configuration=$Configuration", - "/p:Platform=$Platform", - "/verbosity:m" - ) - - &msbuild $Arguments - - if ($LastExitCode -ne 0) - { - Die "Build failed" - } -} - -function Compile -{ - Write-Diagnostic "Attempting to load vcvarsall.bat" - - $VS_VER=16; - $VS_OFFICIAL_VER=2019; - $programFilesDir = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0] - - $vswherePath = Join-Path $programFilesDir 'Microsoft Visual Studio\Installer\vswhere.exe' - #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" - - $versionSearchStr = "[$VS_VER.0," + ($VS_VER+1) + ".0)" - $VS2019InstallPath = & $vswherePath -version $versionSearchStr -property installationPath - - if(-not (Test-Path $VS2019InstallPath)) - { - Die "Visual Studio $VS_OFFICIAL_VER is not installed on your development machine, unable to continue." - } - - $VXXCommonTools = Join-Path $VS2019InstallPath VC\Auxiliary\Build - - if ($VXXCommonTools -eq $null -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($env:CEFSHARP_BUILD_IS_BOOTSTRAPPED -eq $null) - { - Invoke-BatchFile $VCVarsAll 'x86' - $env:CEFSHARP_BUILD_IS_BOOTSTRAPPED = $true - } - - Write-Diagnostic "Restore Nuget Packages" - - # Restore packages - . $nuget restore CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.netcore.config -PackagesDirectory packages - . $nuget restore CefSharp.BrowserSubprocess.Core\packages.CefSharp.BrowserSubprocess.Core.netcore.config -PackagesDirectory packages - &msbuild /t:restore CefSharp3.netcore.sln - - Write-Diagnostic "Compile Packages" - - # Compile - Msvs 'Release' 'x64' - Msvs 'Release' 'x86' - Msvs 'Release' 'arm64' -} - -function Nupkg -{ - if (Test-Path Env:\APPVEYOR_PULL_REQUEST_NUMBER) - { - Write-Diagnostic "Pr Number: $env:APPVEYOR_PULL_REQUEST_NUMBER" - Write-Diagnostic "Skipping Nupkg" - return - } - - Write-Diagnostic "Building nuget package" - - # Build newer style packages - . $nuget pack nuget\PackageReference\CefSharp.Common.NETCore.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget\PackageReference -Properties "RedistVersion=$RedistVersion;" - . $nuget pack nuget\PackageReference\CefSharp.OffScreen.NETCore.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget\PackageReference - . $nuget pack nuget\PackageReference\CefSharp.Wpf.NETCore.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget\PackageReference - . $nuget pack nuget\PackageReference\CefSharp.WinForms.NETCore.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget\PackageReference -} - -function DownloadNuget() -{ - if(-not (Test-Path $nuget)) - { - $client = New-Object System.Net.WebClient; - $client.DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', $nuget); - } - - if(-not (Test-Path $nuget)) - { - Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget" - } -} - -function WriteAssemblyVersion -{ - param() - - $Filename = Join-Path $WorkingDir CefSharp\Properties\AssemblyInfo.cs - $Regex = 'public const string AssemblyVersion = "(.*)"'; - $Regex2 = 'public const string AssemblyFileVersion = "(.*)"' - $Regex3 = 'public const string AssemblyCopyright = "Copyright © .* The CefSharp Authors"' - - $AssemblyInfo = Get-Content -Encoding UTF8 $Filename - $CurrentYear = Get-Date -Format yyyy - - $NewString = $AssemblyInfo -replace $Regex, "public const string AssemblyVersion = ""$AssemblyVersion""" - $NewString = $NewString -replace $Regex2, "public const string AssemblyFileVersion = ""$AssemblyVersion.0""" - $NewString = $NewString -replace $Regex3, "public const string AssemblyCopyright = ""Copyright © $CurrentYear The CefSharp Authors""" - - $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False - [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) -} - -function WriteVersionToManifest($manifest) -{ - $Filename = Join-Path $WorkingDir $manifest - $Regex = 'assemblyIdentity version="(.*?)"'; - - $ManifestData = Get-Content -Encoding UTF8 $Filename - $NewString = $ManifestData -replace $Regex, "assemblyIdentity version=""$AssemblyVersion.0""" - - $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False - [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) -} - -function WriteVersionToResourceFile($resourceFile) -{ - $Filename = Join-Path $WorkingDir $resourceFile - $Regex1 = 'VERSION .*'; - $Regex2 = 'Version", ".*?"'; - $Regex3 = 'Copyright © .* The CefSharp Authors' - - $ResourceData = Get-Content -Encoding UTF8 $Filename - $CurrentYear = Get-Date -Format yyyy - #Assembly version with comma instead of dot - $CppAssemblyVersion = $AssemblyVersion -replace '\.', ',' - - $NewString = $ResourceData -replace $Regex1, "VERSION $CppAssemblyVersion" - $NewString = $NewString -replace $Regex2, "Version"", ""$AssemblyVersion""" - $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>'; - $Regex2 = 'Version .*<\/HeaderText>'; - - $ShfbprojData = Get-Content -Encoding UTF8 $Filename - $NewString = $ShfbprojData -replace $Regex1, "$AssemblyVersion" - $NewString = $NewString -replace $Regex2, "Version $AssemblyVersion" - - $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}" - - $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False - [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) -} - -function WriteVersionToNugetTargets -{ - $Filename = Join-Path $WorkingDir NuGet\PackageReference\CefSharp.Common.NETCore.targets - - Write-Diagnostic "Write Version ($RedistVersion) to $Filename" - $Regex1 = '" Version=".*"'; - $Replace = '" Version="' + $RedistVersion + '"'; - - $RunTimeJsonData = Get-Content -Encoding UTF8 $Filename - $NewString = $RunTimeJsonData -replace $Regex1, $Replace - - $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False - [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) -} - -Write-Diagnostic "CEF Redist Version = $RedistVersion" - -DownloadNuget - -WriteAssemblyVersion -WriteVersionToShfbproj -WriteVersionToAppveyor -WriteVersionToNugetTargets - -WriteVersionToManifest "CefSharp.BrowserSubprocess\app.manifest" -WriteVersionToManifest "CefSharp.OffScreen.Example\app.manifest" -WriteVersionToManifest "CefSharp.WinForms.Example\app.manifest" -WriteVersionToManifest "CefSharp.Wpf.Example\app.manifest" - -WriteVersionToResourceFile "CefSharp.BrowserSubprocess.Core\Resource.rc" -WriteVersionToResourceFile "CefSharp.Core.Runtime\Resource.rc" - -switch -Exact ($Target) -{ - "nupkg-only" - { - Nupkg - } - "netcore31" - { - Compile - Nupkg - } -} diff --git a/build.ps1 b/build.ps1 index 5be5bc68e3..4cd70dd498 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,20 +1,21 @@ -param( - [ValidateSet("vs2019", "nupkg-only")] +#requires -Version 5 + +param( + [ValidateSet("vs2022","vs2019", "nupkg-only")] [Parameter(Position = 0)] [string] $Target = "vs2019", [Parameter(Position = 1)] [string] $Version = "94.4.20", [Parameter(Position = 2)] - [string] $AssemblyVersion = "94.4.20" + [string] $AssemblyVersion = "94.4.20", + [Parameter(Position = 3)] + [ValidateSet("NetFramework", "NetCore", "NetFramework452", "NetCore31")] + [string] $TargetFramework = "NetFramework", + [Parameter(Position = 4)] + [string] $BuildArches = "x86 x64 arm64" ) - -$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition -$CefSln = Join-Path $WorkingDir 'CefSharp3.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.config')) -$RedistVersion = $CefSharpCorePackagesXml.SelectSingleNode("//packages/package[@id='cef.sdk']/@version").value +Set-StrictMode -version latest; +$ErrorActionPreference = "Stop"; function Write-Diagnostic { @@ -28,24 +29,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 { @@ -94,28 +77,10 @@ function Warn Write-Host } -function TernaryReturn +function BuildSolution { param( - [Parameter(Position = 0, ValueFromPipeline = $true)] - [bool] $Yes, - [Parameter(Position = 1, ValueFromPipeline = $true)] - $Value, - [Parameter(Position = 2, ValueFromPipeline = $true)] - $Value2 - ) - - if($Yes) { - return $Value - } - - $Value2 -} - -function Msvs -{ - param( - [ValidateSet('v142')] + [ValidateSet('v142','v143')] [Parameter(Position = 0, ValueFromPipeline = $true)] [string] $Toolchain, @@ -124,74 +89,23 @@ function Msvs [string] $Configuration, [Parameter(Position = 2, ValueFromPipeline = $true)] - [ValidateSet('x86', 'x64')] - [string] $Platform - ) - - Write-Diagnostic "Targeting $Toolchain using configuration $Configuration on platform $Platform" - - $VisualStudioVersion = $null - $VXXCommonTools = $null - - switch -Exact ($Toolchain) - { - 'v142' - { - $VS_VER = 16; - $VS_OFFICIAL_VER = 2019; - $programFilesDir = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0] - - $vswherePath = Join-Path $programFilesDir 'Microsoft Visual Studio\Installer\vswhere.exe' - #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" - - $versionSearchStr = "[$VS_VER.0," + ($VS_VER+1) + ".0)" - $VS2017InstallPath = & $vswherePath -version $versionSearchStr -property installationPath - - Write-Diagnostic "$($VS_OFFICIAL_VER)InstallPath: $VS2017InstallPath" - - if(-not (Test-Path $VS2017InstallPath)) - { - Die "Visual Studio $VS_OFFICIAL_VER is not installed on your development machine, unable to continue." - } - - $MSBuildExe = "msbuild.exe" - $VisualStudioVersion = "$VS_VER.0" - $VXXCommonTools = Join-Path $VS2017InstallPath VC\Auxiliary\Build - } - } + [ValidateSet('x86', 'x64', 'arm64')] + [string] $Platform, - if ($VXXCommonTools -eq $null -or (-not (Test-Path($VXXCommonTools)))) { - Die 'Error unable to find any visual studio environment' - } + [Parameter(Position = 3, ValueFromPipeline = $true)] + [string] $VisualStudioVersion + ) - $VCVarsAll = Join-Path $VXXCommonTools vcvarsall.bat - if (-not (Test-Path $VCVarsAll)) { - Die "Unable to find $VCVarsAll" - } + Write-Diagnostic "Begin compiling targeting $Toolchain using configuration $Configuration for platform $Platform" - # Only configure build environment once - if($env:CEFSHARP_BUILD_IS_BOOTSTRAPPED -eq $null) { - Invoke-BatchFile $VCVarsAll $Platform - $env:CEFSHARP_BUILD_IS_BOOTSTRAPPED = $true + $Arch = $Platform + if (!$IsNetCoreBuild -and $Arch -eq "x86") + { + $Arch="win32"; } - $Arch = TernaryReturn ($Platform -eq 'x64') 'x64' 'win32' + # Restore Nuget packages + &msbuild /nologo /verbosity:minimal /t:restore /p:Platform=$Arch /p:Configuration=Release $CefSln $Arguments = @( "$CefSln", @@ -203,7 +117,7 @@ function Msvs ) $StartInfo = New-Object System.Diagnostics.ProcessStartInfo - $StartInfo.FileName = $MSBuildExe + $StartInfo.FileName = "msbuild.exe" $StartInfo.Arguments = $Arguments $StartInfo.EnvironmentVariables.Clear() @@ -232,61 +146,174 @@ function Msvs Write-Host "stderr: $stderr" Die "Build failed" } + + Write-Diagnostic "Compile succeeded targeting $Toolchain using configuration $Configuration for platform $Platform" } function VSX { param( - [ValidateSet('v142')] + [ValidateSet('v142','v143')] [Parameter(Position = 0, ValueFromPipeline = $true)] [string] $Toolchain ) Write-Diagnostic "Starting to build targeting toolchain $Toolchain" - Msvs "$Toolchain" 'Release' 'x86' - Msvs "$Toolchain" 'Release' 'x64' + $VisualStudioVersion = $null + $VXXCommonTools = $null + $VS_VER = -1 + $VS_OFFICIAL_VER = -1 + $VS_PRE = "" + + switch -Exact ($Toolchain) + { + 'v142' + { + $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)" + + $VSInstallPath = & $VSWherePath -version $versionSearchStr -property installationPath $VS_PRE + + Write-Diagnostic "$($VS_OFFICIAL_VER)InstallPath: $VSInstallPath" + + 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" + } + + $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 + } + + foreach ($arch in $ARCHES) + { + BuildSolution "$Toolchain" 'Release' $arch $VisualStudioVersion + } Write-Diagnostic "Finished build targeting toolchain $Toolchain" } function NugetPackageRestore { - $nuget = Join-Path $WorkingDir .\nuget\NuGet.exe - if(-not (Test-Path $nuget)) { - Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget" - } + param( + [Parameter(Position = 0, ValueFromPipeline = $true)] + [string[]] $ConfigFiles + ) Write-Diagnostic "Restore Nuget Packages" - # Restore packages - . $nuget restore $CefSln + foreach($file in $ConfigFiles) + { + . $nuget restore $file -PackagesDirectory packages + } } function Nupkg { + param( + [Parameter(Position = 0, ValueFromPipeline = $true)] + [string[]] $Files + ) + if (Test-Path Env:\APPVEYOR_PULL_REQUEST_NUMBER) { Write-Diagnostic "Pr Number: $env:APPVEYOR_PULL_REQUEST_NUMBER" Write-Diagnostic "Skipping Nupkg" return } - - $nuget = Join-Path $WorkingDir .\nuget\NuGet.exe - if(-not (Test-Path $nuget)) { - Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget" - } Write-Diagnostic "Building nuget package" - # Build old packages - . $nuget pack nuget\CefSharp.Common.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget -Properties "RedistVersion=$RedistVersion" - . $nuget pack nuget\CefSharp.Wpf.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget - . $nuget pack nuget\CefSharp.OffScreen.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget - . $nuget pack nuget\CefSharp.WinForms.nuspec -NoPackageAnalysis -Version $Version -OutputDirectory nuget + # Build packages + foreach($file in $Files) + { + $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" + } + + $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) + { + . $nuget pack $filePath -Version $Version -OutputDirectory $NugetPackagePath -Properties "RedistVersion=$RedistVersion;" + } + else + { + . $nuget pack $filePath -NoPackageAnalysis -Version $Version -OutputDirectory $NugetPackagePath -Properties "RedistVersion=$RedistVersion;" + } + } + finally + { + if(Test-Path($tempFile)) + { + Copy-Item $tempFile $filePath + Remove-Item $tempFile + } + } + } # Invoke `AfterBuild` script if available (ie. upload packages to myget) - if(-not (Test-Path $WorkingDir\AfterBuild.ps1)) { + if(-not (Test-Path $WorkingDir\AfterBuild.ps1)) + { return } @@ -295,12 +322,16 @@ function Nupkg function DownloadNuget() { - $nuget = Join-Path $WorkingDir .\nuget\NuGet.exe if(-not (Test-Path $nuget)) { $client = New-Object System.Net.WebClient; $client.DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', $nuget); } + + if(-not (Test-Path $nuget)) + { + Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget" + } } function WriteAssemblyVersion @@ -347,7 +378,6 @@ function WriteVersionToTransform($transform) [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) } - function WriteVersionToResourceFile($resourceFile) { $Filename = Join-Path $WorkingDir $resourceFile @@ -394,15 +424,111 @@ function WriteVersionToAppveyor [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) } +function WriteVersionToNugetTargets +{ + $Filename = Join-Path $WorkingDir NuGet\PackageReference\CefSharp.Common.NETCore.targets + + Write-Diagnostic "Write Version ($RedistVersion) to $Filename" + $Regex1 = '" Version=".*"'; + $Replace = '" Version="' + $RedistVersion + '"'; + + $RunTimeJsonData = Get-Content -Encoding UTF8 $Filename + $NewString = $RunTimeJsonData -replace $Regex1, $Replace + + $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False + [System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding) +} + +$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition + +Write-Diagnostic "pushd $WorkingDir" +Push-Location $WorkingDir + +$IsNetCoreBuild = $TargetFramework.ToLower().Contains("netcore") +$ARCHES = [System.Collections.ArrayList]$BuildArches.ToLower().Split(" "); +$CefSln = $null +$NugetPackagePath = $null +$NupkgFiles = $null +$VCXProjPackageConfigFiles = $null +$SupportedArches = [System.Collections.ArrayList]@(); + +if($IsNetCoreBuild) +{ + $CefSln = Join-Path $WorkingDir 'CefSharp3.netcore.sln' + $NugetPackagePath = "nuget\PackageReference"; + $NupkgFiles = @('CefSharp.Common.NETCore.nuspec', 'CefSharp.WinForms.NETCore.nuspec', 'CefSharp.Wpf.NETCore.nuspec','CefSharp.OffScreen.NETCore.nuspec') + $VCXProjPackageConfigFiles = @('CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.netcore.config', 'CefSharp.BrowserSubprocess.Core\packages.CefSharp.BrowserSubprocess.Core.netcore.config'); + $SupportedArches.AddRange(@("x86", "x64", "arm64")); +} +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'); + $SupportedArches.AddRange(@("x86", "x64")); +} + +# 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 ($VCXProjPackageConfigFiles[0])) +$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 -NugetPackageRestore +NugetPackageRestore $VCXProjPackageConfigFiles + +$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' +} + +#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" WriteAssemblyVersion WriteVersionToShfbproj WriteVersionToAppveyor +WriteVersionToNugetTargets WriteVersionToManifest "CefSharp.BrowserSubprocess\app.manifest" WriteVersionToManifest "CefSharp.OffScreen.Example\app.manifest" @@ -419,11 +545,19 @@ switch -Exact ($Target) { "nupkg-only" { - Nupkg + Nupkg $NupkgFiles } "vs2019" { VSX v142 - Nupkg + Nupkg $NupkgFiles + } + "vs2022" + { + + VSX v143 + Nupkg $NupkgFiles } } + +Pop-Location \ No newline at end of file