Skip to content

Commit 462bc74

Browse files
authored
Add support for Windows ARM64 to CefSharp.NETCore packages (#3359)
* 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 * PR feedback: Remove "WIN32" define as it is already defined by minwindef.h. * PR feedback: Switch the CefSharp.*.Example.netcore and CefSharp.Test.netcore projects from cef.redist to chromiumembeddedframework.runtime. Note: These projects are excluded for build when platform is 'arm64', as otherwise the build fails as WinForms and WPF are not yet available for ARM64 in .NET 5.0. * Follow-Up: Update path to CefSharp.Test.dll. * PR feedback: Also use RuntimeInformation for the .NET Framework example projects. * PR feedback: - Remove copying of CefRedist files in CefSharp.AfterBuild.targets which is no longer needed. - Update .vsconfig to include the VC ARM64 build tools.
1 parent aabdb68 commit 462bc74

21 files changed

+372
-53
lines changed

.vsconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"Microsoft.VisualStudio.Component.VC.CoreIde",
1818
"Microsoft.VisualStudio.Component.Windows10SDK",
1919
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
20+
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
2021
"Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites",
2122
"Microsoft.ComponentGroup.Blend",
2223
"Microsoft.VisualStudio.Workload.ManagedDesktop",

CefSharp.AfterBuild.targets

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,4 @@
1515
<Message Importance="high" Text="Copying $(SolutionDir)CefSharp.BrowserSubprocess\bin.netcore\$(Platform)\$(Configuration)\$(TargetFramework)\CefSharp.BrowserSubprocess.* to $(TargetDir)" />
1616
<Copy SourceFiles="@(SubProcessFiles)" DestinationFolder="$(TargetDir)" />
1717
</Target>
18-
19-
<Target Name="CefSharpCopyLibs86" BeforeTargets="AfterBuild" Condition="'$(Platform)' == 'x86'">
20-
<Message Importance="high" Text="Copying cef.redist x86 files to $(TargetDir)" />
21-
<Copy SourceFiles="@(CefRedist32)" DestinationFiles="@(CefRedist32->'$(TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
22-
</Target>
23-
24-
<Target Name="CefSharpCopyLibs64" BeforeTargets="AfterBuild" Condition="'$(Platform)' == 'x64'">
25-
<Message Importance="high" Text="Copying cef.redist x64 files to $(TargetDir)" />
26-
<Copy SourceFiles="@(CefRedist64)" DestinationFiles="@(CefRedist64->'$(TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
27-
</Target>
2818
</Project>

CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.netcore.vcxproj

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<Configuration>Debug</Configuration>
1414
<Platform>x64</Platform>
1515
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Debug|arm64">
17+
<Configuration>Debug</Configuration>
18+
<Platform>arm64</Platform>
19+
</ProjectConfiguration>
1620
<ProjectConfiguration Include="Release|Win32">
1721
<Configuration>Release</Configuration>
1822
<Platform>Win32</Platform>
@@ -21,6 +25,10 @@
2125
<Configuration>Release</Configuration>
2226
<Platform>x64</Platform>
2327
</ProjectConfiguration>
28+
<ProjectConfiguration Include="Release|arm64">
29+
<Configuration>Release</Configuration>
30+
<Platform>arm64</Platform>
31+
</ProjectConfiguration>
2432
</ItemGroup>
2533
<PropertyGroup Label="Globals">
2634
<VCProjectVersion>16.0</VCProjectVersion>
@@ -44,6 +52,12 @@
4452
<CLRSupport>NetCore</CLRSupport>
4553
<CharacterSet>Unicode</CharacterSet>
4654
</PropertyGroup>
55+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'" Label="Configuration">
56+
<ConfigurationType>DynamicLibrary</ConfigurationType>
57+
<UseDebugLibraries>true</UseDebugLibraries>
58+
<CLRSupport>NetCore</CLRSupport>
59+
<CharacterSet>Unicode</CharacterSet>
60+
</PropertyGroup>
4761
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
4862
<ConfigurationType>DynamicLibrary</ConfigurationType>
4963
<UseDebugLibraries>false</UseDebugLibraries>
@@ -56,6 +70,12 @@
5670
<CLRSupport>NetCore</CLRSupport>
5771
<CharacterSet>Unicode</CharacterSet>
5872
</PropertyGroup>
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'" Label="Configuration">
74+
<ConfigurationType>DynamicLibrary</ConfigurationType>
75+
<UseDebugLibraries>false</UseDebugLibraries>
76+
<CLRSupport>NetCore</CLRSupport>
77+
<CharacterSet>Unicode</CharacterSet>
78+
</PropertyGroup>
5979
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
6080
<ImportGroup Label="ExtensionSettings">
6181
</ImportGroup>
@@ -65,12 +85,18 @@
6585
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
6686
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
6787
</ImportGroup>
88+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'" Label="PropertySheets">
89+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
90+
</ImportGroup>
6891
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
6992
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
7093
</ImportGroup>
7194
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
7295
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
7396
</ImportGroup>
97+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'" Label="PropertySheets">
98+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
99+
</ImportGroup>
74100
<PropertyGroup Label="UserMacros" />
75101
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
76102
<LinkIncremental>true</LinkIncremental>
@@ -88,6 +114,14 @@
88114
<IntDir>obj.netcore\$(Platform)\$(Configuration)\</IntDir>
89115
<SourcePath>$(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath)</SourcePath>
90116
</PropertyGroup>
117+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">
118+
<LinkIncremental>true</LinkIncremental>
119+
<LinkKeyFile>..\CefSharp.snk</LinkKeyFile>
120+
<IgnoreImportLibrary>true</IgnoreImportLibrary>
121+
<OutDir>bin.netcore\$(Platform)\$(Configuration)\</OutDir>
122+
<IntDir>obj.netcore\$(Platform)\$(Configuration)\</IntDir>
123+
<SourcePath>$(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath)</SourcePath>
124+
</PropertyGroup>
91125
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
92126
<LinkIncremental>false</LinkIncremental>
93127
<LinkKeyFile>..\CefSharp.snk</LinkKeyFile>
@@ -102,12 +136,19 @@
102136
<IntDir>obj.netcore\$(Platform)\$(Configuration)\</IntDir>
103137
<SourcePath>$(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath)</SourcePath>
104138
</PropertyGroup>
139+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">
140+
<LinkIncremental>false</LinkIncremental>
141+
<LinkKeyFile>..\CefSharp.snk</LinkKeyFile>
142+
<OutDir>bin.netcore\$(Platform)\$(Configuration)\</OutDir>
143+
<IntDir>obj.netcore\$(Platform)\$(Configuration)\</IntDir>
144+
<SourcePath>$(SolutionDir)packages\$(CefSdkVer)\CEF;$(SourcePath)</SourcePath>
145+
</PropertyGroup>
105146
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
106147
<ClCompile>
107148
<WarningLevel>Level3</WarningLevel>
108149
<AdditionalIncludeDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir)</AdditionalIncludeDirectories>
109150
<Optimization>Disabled</Optimization>
110-
<PreprocessorDefinitions>WIN32;_DEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
151+
<PreprocessorDefinitions>_DEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
111152
<PrecompiledHeader>Use</PrecompiledHeader>
112153
<BrowseInformation>true</BrowseInformation>
113154
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -127,7 +168,26 @@
127168
<WarningLevel>Level3</WarningLevel>
128169
<AdditionalIncludeDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir)</AdditionalIncludeDirectories>
129170
<Optimization>Disabled</Optimization>
130-
<PreprocessorDefinitions>WIN32;_DEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
171+
<PreprocessorDefinitions>_DEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
172+
<PrecompiledHeader>Use</PrecompiledHeader>
173+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
174+
</ClCompile>
175+
<Link>
176+
<GenerateDebugInformation>true</GenerateDebugInformation>
177+
<AdditionalDependencies>libcef.lib;libcef_dll_wrapper.lib</AdditionalDependencies>
178+
<AdditionalLibraryDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration);$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration)\VS$(VisualStudioProductVersion);</AdditionalLibraryDirectories>
179+
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
180+
</Link>
181+
<Manifest>
182+
<AdditionalManifestFiles>Assembly.manifest</AdditionalManifestFiles>
183+
</Manifest>
184+
</ItemDefinitionGroup>
185+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">
186+
<ClCompile>
187+
<WarningLevel>Level3</WarningLevel>
188+
<AdditionalIncludeDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir)</AdditionalIncludeDirectories>
189+
<Optimization>Disabled</Optimization>
190+
<PreprocessorDefinitions>_DEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
131191
<PrecompiledHeader>Use</PrecompiledHeader>
132192
<MultiProcessorCompilation>true</MultiProcessorCompilation>
133193
</ClCompile>
@@ -145,7 +205,7 @@
145205
<ClCompile>
146206
<WarningLevel>Level3</WarningLevel>
147207
<AdditionalIncludeDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir)</AdditionalIncludeDirectories>
148-
<PreprocessorDefinitions>WIN32;NDEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
208+
<PreprocessorDefinitions>NDEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
149209
<PrecompiledHeader>Use</PrecompiledHeader>
150210
<BrowseInformation>true</BrowseInformation>
151211
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -163,7 +223,24 @@
163223
<ClCompile>
164224
<WarningLevel>Level3</WarningLevel>
165225
<AdditionalIncludeDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir)</AdditionalIncludeDirectories>
166-
<PreprocessorDefinitions>WIN32;NDEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
226+
<PreprocessorDefinitions>NDEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
227+
<PrecompiledHeader>Use</PrecompiledHeader>
228+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
229+
</ClCompile>
230+
<Link>
231+
<GenerateDebugInformation>true</GenerateDebugInformation>
232+
<AdditionalDependencies>libcef.lib;libcef_dll_wrapper.lib</AdditionalDependencies>
233+
<AdditionalLibraryDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration);$(SolutionDir)packages\$(CefSdkVer)\CEF\$(Platform)\$(Configuration)\VS$(VisualStudioProductVersion)</AdditionalLibraryDirectories>
234+
</Link>
235+
<Manifest>
236+
<AdditionalManifestFiles>Assembly.manifest</AdditionalManifestFiles>
237+
</Manifest>
238+
</ItemDefinitionGroup>
239+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">
240+
<ClCompile>
241+
<WarningLevel>Level3</WarningLevel>
242+
<AdditionalIncludeDirectories>$(SolutionDir)packages\$(CefSdkVer)\CEF;%(AdditionalIncludeDirectories);$(ProjectDir)</AdditionalIncludeDirectories>
243+
<PreprocessorDefinitions>NDEBUG;EXPORT;NETCOREAPP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
167244
<PrecompiledHeader>Use</PrecompiledHeader>
168245
<MultiProcessorCompilation>true</MultiProcessorCompilation>
169246
</ClCompile>
@@ -226,8 +303,10 @@
226303
<ClCompile Include="Stdafx.cpp">
227304
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
228305
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
306+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">Create</PrecompiledHeader>
229307
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
230308
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
309+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">Create</PrecompiledHeader>
231310
</ClCompile>
232311
<ClCompile Include="TypeUtils.cpp" />
233312
<ClCompile Include="Serialization\V8Serialization.cpp" />

CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.netcore.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<PropertyGroup>
1414
<OutputType>WinExe</OutputType>
15-
<TargetFramework>netcoreapp3.1</TargetFramework>
15+
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
1616
<RootNamespace>CefSharp.BrowserSubprocess</RootNamespace>
1717
<AssemblyName>CefSharp.BrowserSubprocess</AssemblyName>
1818
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
@@ -21,7 +21,9 @@
2121
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
2222
<ApplicationManifest>app.manifest</ApplicationManifest>
2323
<StartupObject>CefSharp.BrowserSubprocess.Program</StartupObject>
24-
<Platforms>x86;x64</Platforms>
24+
<Platforms>x86;x64;arm64</Platforms>
25+
<!-- Explicitly set the PlatformTarget for arm64, see: https://github.com/dotnet/sdk/issues/15434 -->
26+
<PlatformTarget Condition="'$(Platform)' == 'arm64'">arm64</PlatformTarget>
2527
<!--
2628
Run on a newer version of .Net if the specified version (.Net Core 3.1) is not installed
2729
https://github.com/dotnet/docs/issues/12237

CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.RefAssembly.netcore.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
<!--
5252
Ugly hack to make sure we have an assembly to use as our source dll for GenAPI
53-
If the x64 version exists we'll use that, otherwise we'll use the win32
53+
If the x64 or arm64 version exists we'll use that, otherwise we'll use the win32
5454
Haven't found a nice way to determine the Platform (resolves as AnyCPU)
5555
-->
5656
<Choose>
@@ -59,6 +59,11 @@
5959
<IntermediateTargetPath>$(SolutionDir)CefSharp.Core.Runtime\bin.netcore\x64\$(Configuration)\CefSharp.Core.Runtime.dll</IntermediateTargetPath>
6060
</PropertyGroup>
6161
</When>
62+
<When Condition="Exists('$(SolutionDir)CefSharp.Core.Runtime\bin.netcore\arm64\$(Configuration)\CefSharp.Core.Runtime.dll')">
63+
<PropertyGroup>
64+
<IntermediateTargetPath>$(SolutionDir)CefSharp.Core.Runtime\bin.netcore\arm64\$(Configuration)\CefSharp.Core.Runtime.dll</IntermediateTargetPath>
65+
</PropertyGroup>
66+
</When>
6267
<Otherwise>
6368
<PropertyGroup>
6469
<IntermediateTargetPath>$(SolutionDir)CefSharp.Core.Runtime\bin.netcore\win32\$(Configuration)\CefSharp.Core.Runtime.dll</IntermediateTargetPath>

0 commit comments

Comments
 (0)