From 95f428829b5fda5a631dd070043f1dfc16f11180 Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Wed, 3 Feb 2021 12:06:58 +1100 Subject: [PATCH] Upgrade to 87.1.132 (#130) * Upgrade to 87.1.12-CI3846 - Upgrade to Net Core 3.1 (Required to use new Net Core packages) - Migrate to NetCore specific pages * Upgrade to 87.1.130-pre * OffScreen - Remove UseWindowsForms from csproj file No longer required as we use the Drawing nuget package Also causes a problem with Console.ReadLine * README.md - Update Net Core Section * WinForms - Add new SdkStyle .Net 4.7.2 project and solution TODO: Add OffScreen and WPF project files * Upgrade to 87.1.131-pre * Upgrade to 87.1.132 --- .gitignore | 2 + .../CefSharp.MinimalExample.OffScreen.csproj | 22 ++++-- ...rp.MinimalExample.OffScreen.netcore.csproj | 41 +----------- CefSharp.MinimalExample.OffScreen/Program.cs | 25 ++----- .../packages.config | 8 +-- .../CefSharp.MinimalExample.WinForms.csproj | 22 ++++-- ...harp.MinimalExample.WinForms.net472.csproj | 37 ++++++++++ ...arp.MinimalExample.WinForms.netcore.csproj | 40 +---------- CefSharp.MinimalExample.WinForms/Program.cs | 27 ++------ .../packages.config | 8 +-- CefSharp.MinimalExample.Wpf/App.xaml.cs | 11 ++- .../CefSharp.MinimalExample.Wpf.csproj | 22 ++++-- ...CefSharp.MinimalExample.Wpf.netcore.csproj | 41 +----------- .../Program.netcore.cs | 50 -------------- CefSharp.MinimalExample.Wpf/packages.config | 8 +-- CefSharp.MinimalExample.net472.sln | 31 +++++++++ README.md | 67 ++++--------------- UpdateNugetPackages.bat | 12 ++-- 18 files changed, 176 insertions(+), 298 deletions(-) create mode 100644 CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.net472.csproj delete mode 100644 CefSharp.MinimalExample.Wpf/Program.netcore.cs create mode 100644 CefSharp.MinimalExample.net472.sln diff --git a/.gitignore b/.gitignore index 9a80d66..ee79c21 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ [Oo]bj/ [Bb]in.netcore/ [Oo]bj.netcore/ +[Bb]in.net472/ +[Oo]bj.net472/ # mstest test results TestResults diff --git a/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj b/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj index 1ea72a5..8fe117a 100644 --- a/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj +++ b/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.csproj @@ -1,9 +1,8 @@  - - - - + + + Debug @@ -65,6 +64,18 @@ app.manifest + + ..\packages\CefSharp.Common.87.1.132\lib\net452\CefSharp.dll + True + + + ..\packages\CefSharp.Common.87.1.132\lib\net452\CefSharp.Core.dll + True + + + ..\packages\CefSharp.OffScreen.87.1.132\lib\net452\CefSharp.OffScreen.dll + True + @@ -83,6 +94,5 @@ - - + \ No newline at end of file diff --git a/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.netcore.csproj b/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.netcore.csproj index 210213b..c61c807 100644 --- a/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.netcore.csproj +++ b/CefSharp.MinimalExample.OffScreen/CefSharp.MinimalExample.OffScreen.netcore.csproj @@ -11,8 +11,7 @@ Exe - netcoreapp3.0 - true + netcoreapp3.1 CefSharp.MinimalExample.OffScreen app.manifest false @@ -29,44 +28,8 @@ - + - - - - - true - - - true - - - true - - - - - - - - - $(CefSharpBrowserProcessCore64) - true - - - - - - - - $(CefSharpBrowserProcessCore32) - true - - - - diff --git a/CefSharp.MinimalExample.OffScreen/Program.cs b/CefSharp.MinimalExample.OffScreen/Program.cs index a76cd9a..bf34850 100644 --- a/CefSharp.MinimalExample.OffScreen/Program.cs +++ b/CefSharp.MinimalExample.OffScreen/Program.cs @@ -23,36 +23,21 @@ namespace CefSharp.MinimalExample.OffScreen Console.WriteLine("You may see Chromium debugging output, please wait..."); Console.WriteLine(); -#if NETCOREAPP - //We are using our current exe as the BrowserSubProcess - //Multiple instances will be spawned to handle all the - //Chromium proceses, render, gpu, network, plugin, etc. - var subProcessExe = new CefSharp.BrowserSubprocess.BrowserSubprocessExecutable(); - var result = subProcessExe.Main(args); - if (result > 0) - { - return result; - } -#endif - var settings = new CefSettings() { //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") }; + var dependencyCheck = true; + #if NETCOREAPP - //We use our Applications exe as the BrowserSubProcess, multiple copies - //will be spawned - //TODO: The OffScreen implementation is crashing on Exit (WPF/WinForms are working fine). - //So for now this is commented out and the old .Net CefSharp.BrowserSubProcess.exe - //is used. - //var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; - //settings.BrowserSubprocessPath = exePath; + //This should be fixed shortly. + dependencyCheck = false; #endif //Perform dependency check to make sure all relevant resources are in our output directory. - Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); + Cef.Initialize(settings, performDependencyCheck: dependencyCheck, browserProcessHandler: null); // Create the offscreen Chromium browser. browser = new ChromiumWebBrowser(testUrl); diff --git a/CefSharp.MinimalExample.OffScreen/packages.config b/CefSharp.MinimalExample.OffScreen/packages.config index d3b34df..bad575c 100644 --- a/CefSharp.MinimalExample.OffScreen/packages.config +++ b/CefSharp.MinimalExample.OffScreen/packages.config @@ -1,7 +1,7 @@  - - - - + + + + \ No newline at end of file diff --git a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj index 412f311..7287128 100644 --- a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj +++ b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.csproj @@ -1,9 +1,8 @@  - - - - + + + Debug AnyCPU @@ -56,6 +55,18 @@ app.manifest + + ..\packages\CefSharp.Common.87.1.132\lib\net452\CefSharp.dll + True + + + ..\packages\CefSharp.Common.87.1.132\lib\net452\CefSharp.Core.dll + True + + + ..\packages\CefSharp.WinForms.87.1.132\lib\net452\CefSharp.WinForms.dll + True + 3.5 @@ -113,6 +124,5 @@ - - + \ No newline at end of file diff --git a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.net472.csproj b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.net472.csproj new file mode 100644 index 0000000..84b638e --- /dev/null +++ b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.net472.csproj @@ -0,0 +1,37 @@ + + + + + obj.net472\ + bin.net472\ + + + + + + WinExe + net472 + true + CefSharp.MinimalExample.WinForms + app.manifest + false + x86;x64 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB} + + + + + + + + + + + + + + + + + diff --git a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.netcore.csproj b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.netcore.csproj index 3ac8264..c23404b 100644 --- a/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.netcore.csproj +++ b/CefSharp.MinimalExample.WinForms/CefSharp.MinimalExample.WinForms.netcore.csproj @@ -11,7 +11,7 @@ WinExe - netcoreapp3.0 + netcoreapp3.1 true CefSharp.MinimalExample.WinForms app.manifest @@ -29,44 +29,8 @@ - + - - - - - true - - - true - - - true - - - - - - - - - $(CefSharpBrowserProcessCore64) - true - - - - - - - - $(CefSharpBrowserProcessCore32) - true - - - - diff --git a/CefSharp.MinimalExample.WinForms/Program.cs b/CefSharp.MinimalExample.WinForms/Program.cs index a70a0ad..b74f530 100644 --- a/CefSharp.MinimalExample.WinForms/Program.cs +++ b/CefSharp.MinimalExample.WinForms/Program.cs @@ -17,31 +17,12 @@ namespace CefSharp.MinimalExample.WinForms //For Windows 7 and above, best to include relevant app.manifest entries as well Cef.EnableHighDPISupport(); -#if NETCOREAPP - //We are using our current exe as the BrowserSubProcess - //Multiple instances will be spawned to handle all the - //Chromium proceses, render, gpu, network, plugin, etc. - var subProcessExe = new CefSharp.BrowserSubprocess.BrowserSubprocessExecutable(); - var result = subProcessExe.Main(args); - if (result > 0) - { - return result; - } -#endif - var settings = new CefSettings() { //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") }; -#if NETCOREAPP - //We use our Applications exe as the BrowserSubProcess, multiple copies - //will be spawned - var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; - settings.BrowserSubprocessPath = exePath; -#endif - //Example of setting a command line argument //Enables WebRTC // - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access @@ -54,9 +35,15 @@ namespace CefSharp.MinimalExample.WinForms //For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180) settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing"); + var dependencyCheck = true; + +#if NETCOREAPP + //This should be fixed shortly. + dependencyCheck = false; +#endif //Perform dependency check to make sure all relevant resources are in our output directory. - Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); + Cef.Initialize(settings, performDependencyCheck: dependencyCheck, browserProcessHandler: null); var browser = new BrowserForm(); Application.Run(browser); diff --git a/CefSharp.MinimalExample.WinForms/packages.config b/CefSharp.MinimalExample.WinForms/packages.config index 8263d2d..b074a73 100644 --- a/CefSharp.MinimalExample.WinForms/packages.config +++ b/CefSharp.MinimalExample.WinForms/packages.config @@ -1,7 +1,7 @@  - - - - + + + + \ No newline at end of file diff --git a/CefSharp.MinimalExample.Wpf/App.xaml.cs b/CefSharp.MinimalExample.Wpf/App.xaml.cs index 208b02c..b8b484e 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml.cs +++ b/CefSharp.MinimalExample.Wpf/App.xaml.cs @@ -9,7 +9,6 @@ namespace CefSharp.MinimalExample.Wpf { public App() { -#if !NETCOREAPP var settings = new CefSettings() { //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data @@ -28,9 +27,15 @@ namespace CefSharp.MinimalExample.Wpf //For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180) settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing"); - //Perform dependency check to make sure all relevant resources are in our output directory. - Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); + var dependencyCheck = true; + +#if NETCOREAPP + //This should be fixed shortly. + dependencyCheck = false; #endif + + //Perform dependency check to make sure all relevant resources are in our output directory. + Cef.Initialize(settings, performDependencyCheck: dependencyCheck, browserProcessHandler: null); } } } diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj index 897348a..64b4838 100644 --- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj +++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj @@ -1,9 +1,8 @@  - - - - + + + Debug @@ -70,6 +69,18 @@ app.manifest + + ..\packages\CefSharp.Common.87.1.132\lib\net452\CefSharp.dll + True + + + ..\packages\CefSharp.Common.87.1.132\lib\net452\CefSharp.Core.dll + True + + + ..\packages\CefSharp.Wpf.87.1.132\lib\net452\CefSharp.Wpf.dll + True + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll @@ -143,8 +154,7 @@ - - + - - true - - - true - - - true - - - - - - - - - $(CefSharpBrowserProcessCore64) - true - - - - - - - - $(CefSharpBrowserProcessCore32) - true - - - - \ No newline at end of file diff --git a/CefSharp.MinimalExample.Wpf/Program.netcore.cs b/CefSharp.MinimalExample.Wpf/Program.netcore.cs deleted file mode 100644 index 87104d1..0000000 --- a/CefSharp.MinimalExample.Wpf/Program.netcore.cs +++ /dev/null @@ -1,50 +0,0 @@ -using CefSharp.Wpf; -using System; -using System.IO; - -namespace CefSharp.MinimalExample.Wpf -{ - public static class Program - { - /// - /// Application Entry Point. - /// - [STAThread] - public static int Main(string[] args) - { - //For Windows 7 and above, app.manifest entries will take precedences of this call - Cef.EnableHighDPISupport(); - - //We are using our current exe as the BrowserSubProcess - //Multiple instances will be spawned to handle all the - //Chromium proceses, render, gpu, network, plugin, etc. - var subProcessExe = new CefSharp.BrowserSubprocess.BrowserSubprocessExecutable(); - var result = subProcessExe.Main(args); - if (result > 0) - { - return result; - } - - //We use our current exe as the BrowserSubProcess - var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; - - var settings = new CefSettings() - { - //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data - CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), - BrowserSubprocessPath = exePath - }; - - //Example of setting a command line argument - //Enables WebRTC - settings.CefCommandLineArgs.Add("enable-media-stream"); - - //Perform dependency check to make sure all relevant resources are in our output directory. - Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); - - var app = new App(); - app.InitializeComponent(); - return app.Run(); - } - } -} \ No newline at end of file diff --git a/CefSharp.MinimalExample.Wpf/packages.config b/CefSharp.MinimalExample.Wpf/packages.config index a9b8fe9..a188ccd 100644 --- a/CefSharp.MinimalExample.Wpf/packages.config +++ b/CefSharp.MinimalExample.Wpf/packages.config @@ -1,8 +1,8 @@  - - - - + + + + \ No newline at end of file diff --git a/CefSharp.MinimalExample.net472.sln b/CefSharp.MinimalExample.net472.sln new file mode 100644 index 0000000..0aa8811 --- /dev/null +++ b/CefSharp.MinimalExample.net472.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.MinimalExample.WinForms.net472", "CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.net472.csproj", "{1D1D63D1-5257-4AA0-A284-7EF4574878CB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Debug|x64.ActiveCfg = Debug|x64 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Debug|x64.Build.0 = Debug|x64 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Debug|x86.ActiveCfg = Debug|x86 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Debug|x86.Build.0 = Debug|x86 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Release|x64.ActiveCfg = Release|x64 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Release|x64.Build.0 = Release|x64 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Release|x86.ActiveCfg = Release|x86 + {1D1D63D1-5257-4AA0-A284-7EF4574878CB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {112012F9-E248-466E-BC28-B36C15B0C4BF} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md index 952d982..574e817 100644 --- a/README.md +++ b/README.md @@ -12,63 +12,20 @@ Includes examples for For a more complete example of each project see the main `CefSharp` repository. ## .NET Core support -As of version `75.1.142`, the CefSharp NuGet packages can be used with .NET Core 3.x projects (as shown by the examples). However, the current versions have some limitations that you should be aware of: -- Chromium [multi-process architecure](https://github.com/cefsharp/CefSharp/wiki/General-Usage#processes) launches multiple BrowserSubProcess instances for rendering, gpu acceleration, networking, plugins, etc. - - By default `CefSharp` provides a default BrowserSubProcess (`CefSharp.BrowserSubprocess.exe`) which requires the .NET Framework 4.5.2 or higher installed. - - It is possible to `self host` the BrowserSubProcess using your application exe this example was updated to demonstrate this in commit https://github.com/cefsharp/CefSharp.MinimalExample/commit/898eb755c6bb7f504f9b5bdc889ff9142e105848 - - A new `.Net Core` BrowserSubProcess is in the works at https://github.com/cefsharp/CefSharp.BrowserSubProcess.NetCore -- Additional entires to your csproj/vbproj are required for the CoreCLR to load the `CefSharp.*` libraries (They would not be specified in the `.deps.json` file otherwise). See example below, the netcore.csproj files contained in this example provide a working demo. -- When publishing a self-contained app using a runtime identifier `win-x64` or `win-x86`, you need to set the `Platform` property to `x64` or `x86`; as otherwise it would be `AnyCPU` and the check in the `.targets` file of the NuGet package would fail.
- Example: - - x86: `dotnet publish -f netcoreapp3.0 -r win-x86 -p:Platform=x86` - - x64: `dotnet publish -f netcoreapp3.0 -r win-x64 -p:Platform=x64` + +The first `-pre` set of `NETCore/Net 5` packages are now on Nuget.org +- https://www.nuget.org/packages/CefSharp.WinForms.NETCore/87.1.130-pre +- https://www.nuget.org/packages/CefSharp.Wpf.NETCore/87.1.130-pre +- https://www.nuget.org/packages/CefSharp.OffScreen.NETCore/87.1.130-pre +- Publish Example + - x86: `dotnet publish -f netcoreapp3.1 -r win-x86 + - x64: `dotnet publish -f netcoreapp3.1 -r win-x64 It is possible to publish the application as single EXE file by adding `-p:PublishSingleFile=true`. -### .Net Core csproj/vbproj WPF -```xml - - - - true - - - true - - - true - - -``` +Any problems please report them on https://github.com/cefsharp/CefSharp/issues/3197 -### .Net Core csproj/vbproj WinForms -```xml - - - - true - - - true - - - true - - -``` +## .NET 5 Support + +The same packages listed above in the .Net Core section should be used for .Net 5.0 -### .Net Core csproj/vbproj OffScreen -```xml - - - - true - - - true - - - true - - -``` diff --git a/UpdateNugetPackages.bat b/UpdateNugetPackages.bat index 1e4920c..e7133c2 100644 --- a/UpdateNugetPackages.bat +++ b/UpdateNugetPackages.bat @@ -1,4 +1,4 @@ -SET cefsharpversion=86.0.241 +SET cefsharpversion=87.1.132 ..\nuget restore CefSharp.MinimalExample.sln @@ -6,8 +6,12 @@ SET cefsharpversion=86.0.241 ..\nuget update CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.csproj -Id CefSharp.WinForms -Version %cefsharpversion% ..\nuget update CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.csproj -Id CefSharp.Wpf -Version %cefsharpversion% -dotnet add CefSharp.MinimalExample.OffScreen\CefSharp.MinimalExample.OffScreen.netcore.csproj package CefSharp.OffScreen -v %cefsharpversion% -dotnet add CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.netcore.csproj package CefSharp.WinForms -v %cefsharpversion% -dotnet add CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.netcore.csproj package CefSharp.Wpf -v %cefsharpversion% +rem #dotnet add CefSharp.MinimalExample.OffScreen\CefSharp.MinimalExample.OffScreen.netcore.csproj package CefSharp.OffScreen.NetCore -v %cefsharpversion% +dotnet add CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.net472.csproj package CefSharp.WinForms -v %cefsharpversion% +rem dotnet add CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.netcore.csproj package CefSharp.Wpf.NetCore -v %cefsharpversion% + +dotnet add CefSharp.MinimalExample.OffScreen\CefSharp.MinimalExample.OffScreen.netcore.csproj package CefSharp.OffScreen.NetCore -v %cefsharpversion% +dotnet add CefSharp.MinimalExample.WinForms\CefSharp.MinimalExample.WinForms.netcore.csproj package CefSharp.WinForms.NetCore -v %cefsharpversion% +dotnet add CefSharp.MinimalExample.Wpf\CefSharp.MinimalExample.Wpf.netcore.csproj package CefSharp.Wpf.NetCore -v %cefsharpversion% pause \ No newline at end of file