Skip to content

Commit

Permalink
Nuget - Exclude CefSharp.Core.Runtime.dll from bin when CefSharpTarge…
Browse files Browse the repository at this point in the history
…tDir and targeting x64

See comments for details

Fix formatting

Issue #3319
  • Loading branch information
amaitland committed Apr 8, 2021
1 parent fdea682 commit 325c083
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions NuGet/CefSharp.Common.targets
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="CefSharpTransformXmlDllPath">
<!--
MSBuild is finding CefSharp.Core.Runtime.dll from the x86 folder and copying it to the bin folder which is a problem for AnyCPU
and when CefSharpTargetDir is used to move the files into a sub folder.
MSBuild is finding CefSharp.Core.Runtime.dll from the x86/x64 folders and copying it to the bin folder which is a problem
for targeting AnyCPU and when CefSharpTargetDir is used to move the files into a sub folder.
AnyCPU/x86:
- CefSharp.Core.Runtime.dll is copied from the x86 folder into the bin folder
x64:
- CefSharp.Core.Runtime.dll is copied from the x64 folder into the bin folder
We manually remove CefSharp.Core.Runtime.dll from ReferenceCopyLocalPaths
https://thomasfreudenberg.com/archive/2012/11/21/dont-copy-my-referenced-assemblies/
-->
<Target Name="CefSharpExcludeCoreRuntimeAfterResolveAssemblyReferences" AfterTargets="ResolveAssemblyReferences" Condition="('$(CefSharpPlatformTarget)' == 'AnyCPU' OR '$(CefSharpTargetDir)' != '') AND $(TargetFrameworkVersion.StartsWith('v4.'))">
<PropertyGroup>
<_CefSharpCoreRuntimeExclude>$(CefSharpPlatformTarget)</_CefSharpCoreRuntimeExclude>
<_CefSharpCoreRuntimeExclude Condition="'$(CefSharpPlatformTarget)' == 'AnyCPU'">x86</_CefSharpCoreRuntimeExclude>
</PropertyGroup>
<ItemGroup>
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\x86\CefSharp.Core.Runtime.dll" />
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\x86\CefSharp.Core.Runtime.pdb" />
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\x86\CefSharp.Core.Runtime.xml" />
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\$(_CefSharpCoreRuntimeExclude)\CefSharp.Core.Runtime.dll" />
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\$(_CefSharpCoreRuntimeExclude)\CefSharp.Core.Runtime.pdb" />
<ReferenceCopyLocalPaths Remove="$(MSBuildThisFileDirectory)..\CefSharp\$(_CefSharpCoreRuntimeExclude)\CefSharp.Core.Runtime.xml" />
</ItemGroup>
</Target>

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

</PropertyGroup>
Expand Down

0 comments on commit 325c083

Please sign in to comment.