From 2b366d3ae6fcc3aa7f9b4892d1d3b849f908b9a3 Mon Sep 17 00:00:00 2001 From: kpreisser Date: Sat, 16 Jan 2021 17:17:50 +0100 Subject: [PATCH] Add support for Windows ARM64 for the NETCore packages. Note: .NET 5.0 or higher is required to build a WinForms/WPF application for win-arm64. Fixes #2944 --- ...arp.BrowserSubprocess.Core.netcore.vcxproj | 79 ++++++++++++++ .../CefSharp.BrowserSubprocess.netcore.csproj | 4 +- ...rp.Core.Runtime.RefAssembly.netcore.csproj | 7 +- .../CefSharp.Core.Runtime.netcore.vcxproj | 101 ++++++++++++++++++ CefSharp.Core/Initializer.cs | 3 +- .../CefSharp.OffScreen.Example.netcore.csproj | 7 +- CefSharp.Test/CefSharp.Test.netcore.csproj | 7 +- .../CefSharp.WinForms.Example.netcore.csproj | 7 +- .../CefSharp.Wpf.Example.netcore.csproj | 7 +- CefSharp3.netcore.sln | 58 ++++++++++ .../CefSharp.Common.NETCore.nuspec | 14 +++ .../CefSharp.Common.NETCore.targets | 56 +++++++++- build.netcore.ps1 | 3 +- 13 files changed, 336 insertions(+), 17 deletions(-) diff --git a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.netcore.vcxproj b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.netcore.vcxproj index ba368a5325..5a8761b35b 100644 --- a/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.netcore.vcxproj +++ b/CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.netcore.vcxproj @@ -10,6 +10,10 @@ Debug x64 + + Debug + arm64 + Release Win32 @@ -18,6 +22,10 @@ Release x64 + + Release + arm64 + 16.0 @@ -41,6 +49,12 @@ NetCore Unicode + + DynamicLibrary + true + NetCore + Unicode + DynamicLibrary false @@ -53,6 +67,12 @@ NetCore Unicode + + DynamicLibrary + false + NetCore + Unicode + @@ -62,12 +82,18 @@ + + + + + + true @@ -85,6 +111,14 @@ obj.netcore\$(Platform)\$(Configuration)\ $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + + true + ..\CefSharp.snk + true + bin.netcore\$(Platform)\$(Configuration)\ + obj.netcore\$(Platform)\$(Configuration)\ + $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + false ..\CefSharp.snk @@ -99,6 +133,13 @@ obj.netcore\$(Platform)\$(Configuration)\ $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + + false + ..\CefSharp.snk + bin.netcore\$(Platform)\$(Configuration)\ + obj.netcore\$(Platform)\$(Configuration)\ + $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + Level3 @@ -138,6 +179,25 @@ Assembly.manifest + + + Level3 + $(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir) + Disabled + WIN32;_DEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions) + Use + true + + + true + libcef.lib;libcef_dll_wrapper.lib + $(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration);$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration)\VS$(VisualStudioProductVersion); + /ignore:4099 %(AdditionalOptions) + + + Assembly.manifest + + Level3 @@ -173,6 +233,23 @@ Assembly.manifest + + + Level3 + $(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir) + WIN32;NDEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions) + Use + true + + + true + libcef.lib;libcef_dll_wrapper.lib + $(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration);$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration)\VS$(VisualStudioProductVersion) + + + Assembly.manifest + + @@ -223,8 +300,10 @@ Create Create + Create Create Create + Create diff --git a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.netcore.csproj b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.netcore.csproj index b66c10421c..858065d93d 100644 --- a/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.netcore.csproj +++ b/CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.netcore.csproj @@ -21,7 +21,9 @@ MinimumRecommendedRules.ruleset app.manifest CefSharp.BrowserSubprocess.Program - x86;x64 + x86;x64;arm64 + + arm64 @@ -59,6 +59,11 @@ $(SolutionDir)CefSharp.Core.Runtime\bin.netcore\x64\$(Configuration)\CefSharp.Core.Runtime.dll + + + $(SolutionDir)CefSharp.Core.Runtime\bin.netcore\arm64\$(Configuration)\CefSharp.Core.Runtime.dll + + $(SolutionDir)CefSharp.Core.Runtime\bin.netcore\win32\$(Configuration)\CefSharp.Core.Runtime.dll diff --git a/CefSharp.Core.Runtime/CefSharp.Core.Runtime.netcore.vcxproj b/CefSharp.Core.Runtime/CefSharp.Core.Runtime.netcore.vcxproj index f1eb3f939a..2c342caa5a 100644 --- a/CefSharp.Core.Runtime/CefSharp.Core.Runtime.netcore.vcxproj +++ b/CefSharp.Core.Runtime/CefSharp.Core.Runtime.netcore.vcxproj @@ -10,6 +10,10 @@ Debug x64 + + Debug + arm64 + Release Win32 @@ -18,6 +22,10 @@ Release x64 + + Release + arm64 + 16.0 @@ -41,6 +49,12 @@ NetCore true + + DynamicLibrary + Unicode + NetCore + true + DynamicLibrary Unicode @@ -51,6 +65,11 @@ Unicode NetCore + + DynamicLibrary + Unicode + NetCore + @@ -60,12 +79,18 @@ + + + + + + bin.netcore\$(Platform)\$(Configuration)\ @@ -91,6 +116,18 @@ obj.netcore\$(Platform)\$(Configuration)\ $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + + false + false + ..\CefSharp.snk + AllRules.ruleset + + + CefSharp.Core.Runtime + bin.netcore\$(Platform)\$(Configuration)\ + obj.netcore\$(Platform)\$(Configuration)\ + $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + bin.netcore\$(Platform)\$(Configuration)\ false @@ -113,6 +150,17 @@ obj.netcore\$(Platform)\$(Configuration)\ $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + + false + AllRules.ruleset + + + CefSharp.Core.Runtime + ..\CefSharp.snk + bin.netcore\$(Platform)\$(Configuration)\ + obj.netcore\$(Platform)\$(Configuration)\ + $(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath) + Disabled @@ -177,6 +225,36 @@ Assembly.manifest + + + Disabled + $(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir) + _DEBUG;_WIN32_WINNT=0x0600;WINVER=0x0600;WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;USING_CEF_SHARED;_CRT_SECURE_NO_WARNINGS;EXPORT;NETCOREAPP;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Use + true + Level3 + ProgramDatabase + Stdafx.h + true + + + false + + + libcef.lib;libcef_dll_wrapper.lib;%(AdditionalDependencies) + $(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration);$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration)\VS$(VisualStudioProductVersion) + false + true + true + false + false + $(LinkKeyFile) + + + Assembly.manifest + + $(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir) @@ -222,6 +300,27 @@ Assembly.manifest + + + $(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir) + _NDEBUG;_WIN32_WINNT=0x0600;WINVER=0x0600;WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;USING_CEF_SHARED;_CRT_SECURE_NO_WARNINGS;EXPORT;NETCOREAPP;%(PreprocessorDefinitions) + MultiThreadedDLL + Use + Level3 + ProgramDatabase + true + true + + + libcef.lib;libcef_dll_wrapper.lib;%(AdditionalDependencies) + $(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration);$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration)\VS$(VisualStudioProductVersion) + true + $(LinkKeyFile) + + + Assembly.manifest + + @@ -248,8 +347,10 @@ Create Create + Create Create Create + Create diff --git a/CefSharp.Core/Initializer.cs b/CefSharp.Core/Initializer.cs index d210853328..9cf843e166 100644 --- a/CefSharp.Core/Initializer.cs +++ b/CefSharp.Core/Initializer.cs @@ -39,8 +39,7 @@ internal static void ModuleInitializer() } else { - //TODO: This will need changing if we support ARM64 - var arch = Environment.Is64BitProcess ? "x64" : "x86"; + var arch = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); var archFolder = $"runtimes\\win-{arch}\\native"; libCefPath = Path.Combine(currentFolder, archFolder, "libcef.dll"); if (File.Exists(libCefPath)) diff --git a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.netcore.csproj b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.netcore.csproj index 2099be162c..78bd4a983c 100644 --- a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.netcore.csproj +++ b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.netcore.csproj @@ -1,4 +1,4 @@ - + @@ -17,7 +17,9 @@ false app.manifest MinimumRecommendedRules.ruleset - x86;x64 + x86;x64;arm64 + + arm64 CefSharp.OffScreen.Example.Program @@ -17,7 +17,9 @@ true false MinimumRecommendedRules.ruleset - x86;x64 + x86;x64;arm64 + + arm64 @@ -29,6 +31,7 @@ + diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj index a3b7c58733..f7fdea701b 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj @@ -1,4 +1,4 @@ - + @@ -18,7 +18,9 @@ false app.manifest MinimumRecommendedRules.ruleset - x86;x64 + x86;x64;arm64 + + arm64 @@ -18,7 +18,9 @@ false app.manifest MinimumRecommendedRules.ruleset - x86;x64 + x86;x64;arm64 + + arm64 CefSharp.Wpf.Example.Program + + @@ -46,6 +48,10 @@ + + + + @@ -55,6 +61,10 @@ + + + + @@ -63,5 +73,9 @@ + + + + \ No newline at end of file diff --git a/NuGet/PackageReference/CefSharp.Common.NETCore.targets b/NuGet/PackageReference/CefSharp.Common.NETCore.targets index 4bcd58b5ba..5e5a9f8bf6 100644 --- a/NuGet/PackageReference/CefSharp.Common.NETCore.targets +++ b/NuGet/PackageReference/CefSharp.Common.NETCore.targets @@ -37,10 +37,29 @@ - - - - + + + + locales\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + swiftshader\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + + + + + + runtimes\win-x86\native\locales\%(RecursiveDir)%(FileName)%(Extension) PreserveNewest @@ -98,6 +117,35 @@ false true + + + runtimes\win-arm64\native\locales\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + runtimes\win-arm64\native\swiftshader\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + runtimes\win-arm64\native\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + + + runtimes\win-arm64\native\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + Included + false + true + diff --git a/build.netcore.ps1 b/build.netcore.ps1 index ad384e2ad9..3191b0de92 100644 --- a/build.netcore.ps1 +++ b/build.netcore.ps1 @@ -91,7 +91,7 @@ function Msvs [string] $Configuration, [Parameter(Position = 1, ValueFromPipeline = $true)] - [ValidateSet('x86', 'x64')] + [ValidateSet('x86', 'x64', 'arm64')] [string] $Platform ) @@ -178,6 +178,7 @@ function Compile # Compile Msvs 'Release' 'x64' Msvs 'Release' 'x86' + Msvs 'Release' 'arm64' } function Nupkg