Skip to content

Conversation

@kpreisser
Copy link
Contributor

@kpreisser kpreisser commented Aug 28, 2019

Add a WinForms, WPF and OffScreen example using .NET Core 3.0. For this, I added new .netcore.csproj files in the existing project folders, and (for WinForms) adjusted the output of the status bar to display the .NET Core version.
See cefsharp/CefSharp#2796

Current limitations of using CefSharp.WinForms, CefSharp.Wpf and CefSharp.OffScreen with .NET Core 3.0:

  • You still need to have .NET Framework 4.5.2 or higher installed, as the CefSharp.BrowserSubprocess.exe is still used.
  • The project file needs to update the references of CefSharp.WinForms/CefSharp.WPF/CefSharp.OffScreen, as well as CefSharp.Core and CefSharp to use <Private>true</Private>, as otherwise the CoreCLR would not load these libraries as they would not be specified in the .deps.json file.
  • 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 application can also be published as single EXE file by adding -p:PublishSingleFile=true.

Thank you!

@kpreisser kpreisser changed the title Add a .NET Core 3.0 WinForms sample Add a .NET Core 3.0 WinForms example Aug 28, 2019
@kpreisser kpreisser changed the title Add a .NET Core 3.0 WinForms example Add a .NET Core 3.0 WinForms/WPF examples Sep 4, 2019
@amaitland
Copy link
Member

Please add the examples to their own solution as we still need to support older versions of VS.

CefSharp.MinimalExample.netcore.sln appears to be a convention that I've seen MS use, open to other suggestions.

@kpreisser
Copy link
Contributor Author

OK, I reverted the changes to CefSharp.MinimalExample.sln and created a new CefSharp.MinimalExample.netcore.sln.

@amaitland
Copy link
Member

Great, thanks 👍

How practical do you think it is to reuse the code files? By this I mean just using a different .csproj file for the .Net Core projects?

I see examples of this in https://github.com/microsoft/WPF-Samples/tree/master/Input%20and%20Commands/CaptureUnCaptureMouse

Thoughts?

@kpreisser
Copy link
Contributor Author

kpreisser commented Sep 7, 2019

How practical do you think it is to reuse the code files? By this I mean just using a different .csproj file for the .Net Core projects?

I see examples of this in https://github.com/microsoft/WPF-Samples/tree/master/Input%20and%20Commands/CaptureUnCaptureMouse

Thanks, I applied this by creating new .netcore.csproj files in the existing CefSharp.MinimalExample.WinForms and CefSharp.MinimalExample.Wpf folders, so that the code files are reused.

A minor drawback of this approach is that when you want to switch between the .NET Core and .NET Framework solutions, you might have to delete the existing obj folder to avoid errors from the build system.

@amaitland
Copy link
Member

Great, thanks 👍 Will merge this after 75.1.142 has been released and the WPF P/Invoke issue has been resolved.

@kpreisser
Copy link
Contributor Author

kpreisser commented Sep 8, 2019

I have also added a .NET Core project file for CefSharp.MinimalExample.OffScreen.

Note: The change to Process.Start is needed because UseShellExecute is false by default in .NET Core.

Will merge this after 75.1.142 has been released and the WPF P/Invoke issue has been resolved.

Once this is released, we can remove the <PackageReference Include="CefSharp.Common" ... /> in the .netcore.csproj files.

Thanks!

@kpreisser kpreisser changed the title Add a .NET Core 3.0 WinForms/WPF examples Add .NET Core 3.0 WinForms/WPF/OffScreen examples Sep 8, 2019
@amaitland
Copy link
Member

Version 75.1.142 should appear on Nuget.org shortly.

@kpreisser
Copy link
Contributor Author

Thanks, I upgraded the .NET Core examples to 75.1.142. The WPF example is working now.

I also updated the README.md to mention support for .NET Core and the current limitations, is this OK?

Thanks!

@amaitland
Copy link
Member

I also updated the README.md to mention support for .NET Core and the current limitations, is this OK?

Excellent start, thanks 👍

@amaitland
Copy link
Member

Thanks for your hard work on this 👍 Merging now.

@amaitland amaitland merged commit 9632e10 into cefsharp:master Sep 10, 2019
@kpreisser kpreisser deleted the dotnetcore3.0 branch September 10, 2019 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants