Skip to content

Commit 325c083

Browse files
committed
Nuget - Exclude CefSharp.Core.Runtime.dll from bin when CefSharpTargetDir and targeting x64
See comments for details Fix formatting Issue #3319
1 parent fdea682 commit 325c083

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

NuGet/CefSharp.Common.targets

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="CefSharpTransformXmlDllPath">
33
<!--
4-
MSBuild is finding CefSharp.Core.Runtime.dll from the x86 folder and copying it to the bin folder which is a problem for AnyCPU
5-
and when CefSharpTargetDir is used to move the files into a sub folder.
4+
MSBuild is finding CefSharp.Core.Runtime.dll from the x86/x64 folders and copying it to the bin folder which is a problem
5+
for targeting AnyCPU and when CefSharpTargetDir is used to move the files into a sub folder.
6+
AnyCPU/x86:
7+
- CefSharp.Core.Runtime.dll is copied from the x86 folder into the bin folder
8+
x64:
9+
- CefSharp.Core.Runtime.dll is copied from the x64 folder into the bin folder
610
We manually remove CefSharp.Core.Runtime.dll from ReferenceCopyLocalPaths
711
https://thomasfreudenberg.com/archive/2012/11/21/dont-copy-my-referenced-assemblies/
812
-->
913
<Target Name="CefSharpExcludeCoreRuntimeAfterResolveAssemblyReferences" AfterTargets="ResolveAssemblyReferences" Condition="('$(CefSharpPlatformTarget)' == 'AnyCPU' OR '$(CefSharpTargetDir)' != '') AND $(TargetFrameworkVersion.StartsWith('v4.'))">
14+
<PropertyGroup>
15+
<_CefSharpCoreRuntimeExclude>$(CefSharpPlatformTarget)</_CefSharpCoreRuntimeExclude>
16+
<_CefSharpCoreRuntimeExclude Condition="'$(CefSharpPlatformTarget)' == 'AnyCPU'">x86</_CefSharpCoreRuntimeExclude>
17+
</PropertyGroup>
1018
<ItemGroup>
11-
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\x86\CefSharp.Core.Runtime.dll" />
12-
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\x86\CefSharp.Core.Runtime.pdb" />
13-
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\x86\CefSharp.Core.Runtime.xml" />
19+
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\$(_CefSharpCoreRuntimeExclude)\CefSharp.Core.Runtime.dll" />
20+
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\$(_CefSharpCoreRuntimeExclude)\CefSharp.Core.Runtime.pdb" />
21+
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\$(_CefSharpCoreRuntimeExclude)\CefSharp.Core.Runtime.xml" />
1422
</ItemGroup>
1523
</Target>
1624

@@ -29,6 +37,8 @@
2937
<!--
3038
For AnyCPU ClickOnce Publish Remove CefSharp.Core.Runtime.dll for being included in the bin folder
3139
TODO: Publish AnyCPU still not working, requires some tweaking as CefSharp.dll file isn't being copied to the x64 folder.
40+
TODO: Combine CefSharpAnyCPUExcludeCoreRuntimeBeforeGenerateApplicationManifest and CefSharpExcludeCoreRuntimeBeforeGenerateApplicationManifest
41+
use a property instead of two different targets
3242
-->
3343
<Target Name="CefSharpAnyCPUExcludeCoreRuntimeBeforeGenerateApplicationManifest" BeforeTargets="GenerateApplicationManifest" Condition="'$(CefSharpPlatformTarget)' == 'AnyCPU' AND $(TargetFrameworkVersion.StartsWith('v4.'))">
3444
<ItemGroup>
@@ -104,15 +114,15 @@
104114
<!--
105115
For Sdk Projects the PlatformTarget is unreliable (https://github.com/dotnet/sdk/issues/1560)
106116
When our targets file is imported $(PlatformTarget) will be x86 when the Platform is infact AnyCPU.
107-
By time the AfterBuilds target runs it's correctly set to AnyCPU as the GetDefaultPlatformTargetForNetFramework
108-
Task correctly sets the build to AnyCPU, unfortunately it's too late. Previous attempt to hack around this failed,
109-
relying on user to manually specify $(PlatformTarget) until the SDK issue is fixed.
117+
By time the AfterBuilds target runs it's correctly set to AnyCPU as the GetDefaultPlatformTargetForNetFramework
118+
Task correctly sets the build to AnyCPU, unfortunately it's too late. Previous attempt to hack around this failed,
119+
relying on user to manually specify $(PlatformTarget) until the SDK issue is fixed.
110120
When AnyCPU and Prefer32Bit we just set the PlatformTarget to x86 (only when CefSharpAnyCpuSupport is empty)
111121
-->
112122
<CefSharpPlatformTarget>$(PlatformTarget)</CefSharpPlatformTarget>
113123
<CefSharpPlatformTarget Condition="'$(CefSharpPlatformTarget)' == ''">$(Platform)</CefSharpPlatformTarget>
114-
<CefSharpPlatformTarget Condition="'$(CefSharpPlatformTarget)' == 'Win32'">x86</CefSharpPlatformTarget>
115-
<CefSharpPlatformTarget Condition="'$(CefSharpPlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' == 'true' AND '$(CefSharpAnyCpuSupport)' == ''">x86</CefSharpPlatformTarget>
124+
<CefSharpPlatformTarget Condition="'$(CefSharpPlatformTarget)' == 'Win32'">x86</CefSharpPlatformTarget>
125+
<CefSharpPlatformTarget Condition="'$(CefSharpPlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' == 'true' AND '$(CefSharpAnyCpuSupport)' == ''">x86</CefSharpPlatformTarget>
116126
<CefSharpPlatformTarget Condition="'$(CefSharpPlatformTargetOverride)' != ''">$(CefSharpPlatformTargetOverride)</CefSharpPlatformTarget>
117127

118128
</PropertyGroup>

0 commit comments

Comments
 (0)