Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Side by side installation #3161

Closed
deAtog opened this issue Jun 29, 2020 · 2 comments
Closed

Feature Request - Side by side installation #3161

deAtog opened this issue Jun 29, 2020 · 2 comments

Comments

@deAtog
Copy link

deAtog commented Jun 29, 2020

#1714 includes instructions for using CefSharp with an AnyCPU application. However, it is currently impossible to deploy the CefSharp libraries side by side (i.e. in the same directory) as the x86 and x64 versions of the libraries have the same name. Building on the instructions given in #1714 I suggest this project do the following:

  1. Move platform dependent libraries to x86/x64 folders respectively.
  2. Add appropriate transformation files to the nuget packages to add the following to app.config;
    a. <dependentAssembly> section for each CefSharp library containing:
    1. <assemblyIdentity> with name and processorArchitecture attributes specified.
    2. <codeBase> relative path to the library in x86/x64 folders respectively.

This allows developers using this library to generate platform specific executables such as app.x86.exe and app.x64.exe and deploy them in the same directory. It also eliminates having to do anything special for AnyCPU based applications as it provides all the information needed to locate the appropriate platform specific library.

@amaitland
Copy link
Member

However, it is currently impossible to deploy the CefSharp libraries side by side (i.e. in the same directory) as the x86 and x64 versions of the libraries have the same name

This should be possible with the current packages, set CefSharpTargetDir to PlatformTarget in your project file to copy the files into a sub directory.

https://github.com/cefsharp/CefSharp/blob/cefsharp/81/NuGet/CefSharp.Common.targets#L12

You can then try your proposed app.config solution.

Suggestion sounds interesting, you are welcome to submit a PR.

@amaitland
Copy link
Member

Now that #3319 is complete the CefSharp.dll/CefSharp.Core.dll/CefSharp.Wpf.dll/CefSharp.WinForms.dll/CefSharp.OffScreen.dll files are now AnyCPU.

You can <CefSharpTargetDir>$(PlatformTarget)</CefSharpTargetDir> to your project file, for the older Non SDK Style this would look like the following.

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <CefSharpTargetDir>x64</CefSharpTargetDir>
  </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <Prefer32Bit>false</Prefer32Bit>
    <CefSharpTargetDir>x86</CefSharpTargetDir>
</PropertyGroup>

Then to load the arch specific files at compile time you can use something like the following in your proj file (written in notepad so might need some tweaks, based off https://github.com/cefsharp/CefSharp/blob/cefsharp/87/NuGet/CefSharp.Common.targets#L301)

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
  
<Target Name="CefSharpAppConfigTransform" AfterTargets="_CopyAppConfigFile">
	<TransformXml Source="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')" Transform="$(CefSharpCommonTransform32)" Destination="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')"/>
	<TransformXml Source="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')" Transform="$(CefSharpCommonTransform64)" Destination="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')"/>
</Target>

To load the arch specific files are runtime you can use Option 2 from #1714 to detect and load the dll at runtime. There are a few other options for this you could also use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants