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

ClickOnce application not starting #1314

Closed
croemheld opened this issue Oct 7, 2015 · 43 comments
Closed

ClickOnce application not starting #1314

croemheld opened this issue Oct 7, 2015 · 43 comments

Comments

@croemheld
Copy link

I know, I know, there have been several issues and most of them were working for others but me.
I've seen [https://github.com//issues/500] and [https://github.com//issues/625].

Project: WPF application in Visual Studio 2013
CefSharp 3.2357.1287
Both x86 and x64 CPUs .
CefSharp.Wpf version: 43.0.0

When opening the folder with the published files, it looks like this:
Content of published folder

According to the other posted issues, especially by stepanets in issue 625 (at the very end), there would be missing a locales folder as well as libcef.dll and icudtl.dat. I don't know if the files CefSharp.BrowserSubprocess.Core.dll and CefSharp.BrowserSubprocess.exe are necessary for this build.

I tried to run the dependency checker on my projects .exe file, but nothing shows up on it's console (I'm using the dependency walker from http://www.dependencywalker.com).

And I have to admit, the "Getting started" section of CefSharp might be a little unclear on copying the files to some special places. (Maybe it's because English is not my native laguage... maybe I'm just too new in this place).

Running the .exe file in the debug and release folder in both CPUs (x86 and x64) is working fine. Even the locales folder and the missing .dll files are in the same folder as the projects .exe. But when publishing via ClickOnce, the files seem to get lost.

UPDATE:

I've also tried to follow the instructions mentioned on StackOverflow: The problem was, the missing files were copied to subfolders, not the folder the .exe file is located in. Result is the same: application does not start, neither do I find any folders the project has been installing in.

Thanks a lot! Really appreciate your work and help!

@taylorjonl
Copy link
Contributor

I own an application that is Click Once using CefSharp(version 39.0.2), you need the libcef.dll and icudtl.dat, along with cef.pak and the locales folder(only the locales you allow, otherwise you can disable PAK file loading in settings when you initialize). You also will need both the sub-process files, they are both critical.

We have a custom script to make our Click Once work, I had to make the native images deploy as data files otherwise the tools tried to load them as .NET assemblies and complained that they were invalid images. Not sure how you are generating the Click Once deployment though, you may not have the same issues.

@croemheld
Copy link
Author

@taylorjonl I'm right-clicking on my projects name in the solution folder on the top right -> publish...
Then after setting the serverpath and my ftp data, the files are on my server, which are exactly those files shown in the picture above. (the files in the picture are in the subfolder, in the parent folder there are the projects .exe file and an application file projectsname.application)

So basically I'm using the standard way to publish and build my project. No errors coming up, no entries in any debug.log file. Just an application which is not starting after "installing" it.

@taylorjonl
Copy link
Contributor

It isn't starting because it doesn't have the required files to load CefSharp.Core. You need to figure out how to get Click Once to deploy those files. In our application(using 39.0.2) we deploy the following:

locales/*.pak(too many to list)
cef.pak
cef_100_percent.pak
cef_200_percent.pak
CefSharp.BrowserSubprocess.Core.dll
CefSharp.BrowserSubProcess.exe
CefSharp.Core.dll
CefSharp.dll
CefSharp.Wpf.dll
d3dcompiler_43.dll
d3dcompiler_47.dll
devtools_resources.pak
ffmpegsumo.dll
icudtl.dat
libcef.dll
libEGL.dll
libGLESv2.dll
pdf.dll

In your listings of the *.deploy files I don't see any of them. You need to figure out how to get Click Once to deploy them or the application will never start.

@croemheld
Copy link
Author

@taylorjonl Okay, everything fine so far. As I mentioned, on the StackOverflow site an user tried to solve the deployment of the missing file with an xcopy command setting in the projects build events at "post-build event command line"

xcopy "$(SolutionDir)packages\CefSharp.Wpf.1.25.7\cef*" "$(TargetDir)" /s /y /i

Problem: This line just copies everything as it is from one folder to the target. This means the files you listed in your comment before are in some subfolders and _not_ in the projects root (the folder the .exe file lies in).

How did you manage to get those files deployed? Did you place them somewhere special before building and set up some build events?

@taylorjonl
Copy link
Contributor

We are talking different things, you are talking about getting them to the build output folder I am talking about getting Click Once to include them in the deployment.

We use MSBUILD tasks and targets to make our deployment since it is quite complex and the default publish mechanism didn't work well for us. First we have this target that determines which files will be packaged:

  <Target Name="DeterminePackageFiles">
    <ItemGroup>
      <ConfigFiles Include="$(OutDir)\*.exe.config"/>
      <DataFiles Include="$(OutDir)\icudtl.dat;$(OutDir)\ProfileCatalog.xml;$(OutDir)\**\*.pak;"/>
      <NativeDLLs Include="$(OutDir)\d3dcompiler_43.dll;$(OutDir)\d3dcompiler_47.dll;$(OutDir)\ffmpegsumo.dll;$(OutDir)\libEGL.dll;$(OutDir)\libGLESv2.dll;$(OutDir)\libcef.dll;$(OutDir)\pdf.dll"/>
      <ManagedDLLs Include="$(OutDir)\*.dll" Exclude="@(NativeDLLs)"/>
      <Tools Include="$(OutDir)\CefSharp.BrowserSubprocess.exe"/>
    </ItemGroup>
  </Target>

Then in another target we parts that will prepare the click once directory:

  <Target Name="PrepareClickOnceDir" DependsOnTargets="GetPackageVersion;DeterminePackageFiles">
    <MakeDir Directories="$(ClickOnceDir);$(ClickOnceDir)\$(PackageVersion)"/>

    <ItemGroup>
      <EntryPoint Include="$(OutDir)\$(ApplicationName).exe" />
      <IconFile Include="$(OutDir)\App.ico"/>
      <Dependency Include="@(ManagedDLLs)" Exclude="@(EntryPoint)">
        <AssemblyType>Managed</AssemblyType>
        <DependencyType>Install</DependencyType>
      </Dependency>
      <File Include="@(ConfigFiles);@(DataFiles);@(NativeDLLs);@(Tools)">
        <TargetPath>%(RecursiveDir)%(Filename)%(Extension)</TargetPath>
      </File>
    </ItemGroup>

    <Message Text="Creating Application Manifest: $(ApplicationName).exe.manifest" />
    <GenerateApplicationManifest AssemblyName="$(ApplicationName).exe"
                                 AssemblyVersion="$(PackageVersion)"
                                 Dependencies="@(Dependency)"
                                 Files="@(File)"
                                 EntryPoint="@(EntryPoint)"
                                 IconFile="@(IconFile)"
                                 ClrVersion="4.0.30319.1"
                                 TargetFrameworkVersion="v4.0"
                                 TargetFrameworkMoniker=".NETFramework,Version=v4.0"
                                 OutputManifest="$(ClickOnceDir)\$(PackageVersion)\$(ApplicationName).exe.manifest">
      <Output ItemName="ApplicationManifest" TaskParameter="OutputManifest"/>
    </GenerateApplicationManifest>

    <Message Text="Signing Application Manifest:@(ApplicationManifest)" />
    <Exec Command="$(MagePath) -Sign &quot;@(ApplicationManifest)&quot; -cf $(CertificatePath)"/>

    <CreateItem Include="@(ApplicationManifest)" AdditionalMetadata="TargetPath=$(PackageVersion)\$(ApplicationName).exe.manifest">
      <Output TaskParameter="Include" ItemName="ApplicationManifestWithPath"/>
    </CreateItem>

    <ItemGroup>
      <DeployFiles Include="$(OutDir)\App.ico;$(OutDir)\$(ApplicationName).exe;@(ConfigFiles);@(DataFiles);@(NativeDLLs);@(ManagedDLLs);@(Tools)"/>
    </ItemGroup>
    <Copy SourceFiles="@(DeployFiles)" DestinationFiles="@(DeployFiles->'$(ClickOnceDir)\$(PackageVersion)\%(RecursiveDir)%(Filename)%(Extension).deploy')"/>

    <Message Text="Creating Deployment Manifest: $(ApplicationName).application" />
    <GenerateDeploymentManifest AssemblyName="$(ApplicationTitle).application"
                                AssemblyVersion="$(PackageVersion)"
                                DeploymentUrl="$(ApplicationUrl)"
                                Description="$(ApplicationDescription)"
                                EntryPoint="@(ApplicationManifestWithPath)"
                                Install="true"
                                TargetFrameworkMoniker=".NETFramework,Version=v4.0"
                                OutputManifest="$(ClickOnceDir)\$(ApplicationName).application"
                                MapFileExtensions="true"
                                Product="$(ApplicationTitle)"
                                Publisher="$(Company)"
                                SupportUrl="$(SupportUrl)"
                                UpdateEnabled="true"
                                UpdateMode="Foreground"
                                TrustUrlParameters="true">
      <Output ItemName="DeployManifest" TaskParameter="OutputManifest"/>
    </GenerateDeploymentManifest>

    <Message Text="Setting Package Version: $(PackageVersion)" />
    <Exec Command="$(MagePath) -u &quot;@(DeployManifest)&quot; -v $(PackageVersion) -mv $(PackageVersion)" />

    <Message Text="Signing Deployment Manifest:@(DeployManifest)" />
    <Exec Command="$(MagePath) -Sign &quot;@(DeployManifest)&quot; -cf $(CertificatePath)"/>

    <ItemGroup>
      <ClickOnceWebFiles Include="ClickOnce\**\*.*"/>
    </ItemGroup>
    <Copy SourceFiles="@(ClickOnceWebFiles)" DestinationFolder="$(ClickOnceDir)"/>

    <MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace" RegexPattern="#VERSION#" Replacement="$(PackageVersion)" Files="$(ClickOnceDir)\publish.htm"/>
  </Target>

I don't have any understand on how to get it working with the default publish mechanism in Visual Studio though.

@croemheld
Copy link
Author

@taylorjonl Sorry, yes I was talking about the deployment, not the build (the build works perfect as mentioned in the opening post).
Your MSBUILD "code" is in the project.csproj file, is that correct? (Right click on projects name -> unload project -> edit project.csproj)
So this should be the place then to set up the deployment and link the files I need and put them in the same deployment "folder"?

UPDATE

After 2 days i finally managed to get the missing files into deployment. I added the following code at the end of the project.csproj file, just before the closing tag.
If there are any "cleaner" approaches, let me know :)

Thanks for your help @taylorjonl !

  <ItemGroup>
    <Content Include="$(SolutionDir)packages\cef.redist.x64.3.2357.1287\CEF\**\*" Exclude="$(SolutionDir)packages\cef.redist.x64.3.2357.1287\CEF\x64\**\*;$(SolutionDir)packages\cef.redist.x64.3.2357.1287\CEF\locales\**\*.pak">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Resource Include="icon.ico" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\cef.redist.x64.3.2357.1287\CEF\**\en-US.*;$(SolutionDir)packages\cef.redist.x64.3.2357.1287\CEF\**\de.*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\cef.redist.x64.3.2357.1287\CEF\x64\**\*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <Content Include="$(SolutionDir)packages\CefSharp.Common.43.0.0\CefSharp\x64\**\CefSharp.BrowserSubprocess.*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>

@davestevens
Copy link

@croemheld Thank you for this! I've been looking for what seems ages for this!

@OceanAirdrop
Copy link

+1 for @croemheld's clean and simple solution of modifying the .csproj file. Can confirm this works with my test ClickOnce deployment.

I am targeting build CEF 47.0.4 and x86. Here is my snipped project.csproj

<ItemGroup>
<Content Include="$(SolutionDir)packages\cef.redist.x86.3.2526.1362\CEF\**\*" Exclude="$(SolutionDir)packages\cef.redist.x86.3.2526.1362\CEF\x86\**\*;$(SolutionDir)packages\cef.redist.x86.3.2526.1362\CEF\locales\**\*.pak">
  <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
  <Visible>false</Visible>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="$(SolutionDir)packages\cef.redist.x86.3.2526.1362\CEF\**\en-GB.*;$(SolutionDir)packages\cef.redist.x86.3.2526.1362\CEF\**\en-US.*">
  <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
  <Visible>false</Visible>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="$(SolutionDir)packages\cef.redist.x86.3.2526.1362\CEF\x86\**\*">
  <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
  <Visible>false</Visible>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="$(SolutionDir)packages\CefSharp.Common.47.0.4\CefSharp\x86\**\CefSharp.BrowserSubprocess.*">
  <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
  <Visible>false</Visible>
</Content>
</ItemGroup>

Thank you @croemheld.

@tomwestwood
Copy link

Hi all,

We're experiencing what sound like identical problems to those that you guys have already overcome, however we can't seem to get this thing working in our project! I wonder if any of you could let us know what we're doing wrong!

In short, our application works fine in debug but not once published (click-once). We've gone through numerous suggested fixes across multiple threads and not got anywhere. The upshot is we're still not getting the required files (dll's etc) to copy across when publishing and we think the approach above is what we need to nail down.

We're currently targeting .NET 4.5.2, and have installed CefSharp.Wpf (version 57.0.0.0, run-time: v4.0.30319) via the package manager console. Also added what I believe are all of the pre-requisites in the project properties.

I've then gone onto add the following to my csproj client file, based on the versions we're using:

<ItemGroup> <Content Include="$(SolutionDir)packages\cef.redist.x86.4.0.30319\CEF\**\*" Exclude="$(SolutionDir)packages\cef.redist.x86.4.0.30319\CEF\x86\**\*;$(SolutionDir)packages\cef.redist.x86.4.0.30319\CEF\locales\**\*.pak"> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Visible>false</Visible> </Content> </ItemGroup> <ItemGroup> <Content Include="$(SolutionDir)packages\cef.redist.x86.4.0.30319\CEF\**\en-GB.*;$(SolutionDir)packages\cef.redist.x86.4.0.30319\CEF\**\en-US.*"> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Visible>false</Visible> </Content> </ItemGroup> <ItemGroup> <Content Include="$(SolutionDir)packages\cef.redist.x86.4.0.30319\CEF\x86\**\*"> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Visible>false</Visible> </Content> </ItemGroup> <ItemGroup> <Content Include="$(SolutionDir)packages\CefSharp.Common.57.0.0.0\CefSharp\x86\**\CefSharp.BrowserSubprocess.*"> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Visible>false</Visible> </Content> </ItemGroup>

And we've also got another entry in this csproj:

<PropertyGroup> <PostBuildEvent>xcopy "$(SolutionDir)packages\CefSharp.Wpf.4.0.30319\cef*" "$(TargetDir)" /s /y /i</PostBuildEvent> </PropertyGroup>

Can anyone see anything glaringly obviously incorrect about the information I've given above? Any simple steps I've neglected to undertake? Any help would be greatly appreciated!

Regards

Tom

@OceanAirdrop
Copy link

OceanAirdrop commented Jul 3, 2017

Hi Tom,

Been a while since this cropped up. From memory all I needed to do was modify the .csproj with that snip above and all worked!!

After my fix, I also answered this question on stack overflow. One other test to perform after you have made the modifications to the .csproj is to look at the "application files" in the publish tab. I have pictures on my stack overflow answer. This will show you all the files that will be bundled up with the ClickOnce deployment. If the cef files are not there perhaps you need to double check your paths in the .csproj file. Once you see them in that window you are good to go!

Here is the SO post: https://stackoverflow.com/questions/34225222/clickonceinstall-cefsharp-winforms-problems/39675335#39675335

@OceanAirdrop
Copy link

OceanAirdrop commented Jul 3, 2017

One other thing I have just remembered.... This might not be your issue but I thought I would mention it.

We had issues around the "Any CPU" setting of the solution. As you know all Dot-net solutions default to "Any CPU". My memory is a bit hazy on the reasons why, but we had to force our .net app to be x86 (change it from AnyCPU to x86).

Here's the thing. If you have previously deployed the ClickOnce as "Any CPU" you cant change the app half way though. This is a change to the signature of the app (stupid, I know). We had to deploy our app to a different location.

Now, I don't know what your situation is but if you can see the files that should be deployed via the "application files" button, try changing the project to an x86 project and deploy to a 2nd URL to test it works.

In the snip of your .csproj file above it looks like you are targeting the x86 version of the CEF binaries. Try changing your project to x86 and see what happens!

@tomwestwood
Copy link

Hi OceanAirdrop,

Just wanted to drop you a 'thank you' for the advice/resources; it wasn't actually any of the above but your post did give me the step-by-step reference to follow and subsequently identify where there were differences.

For anyone interested, we were referencing the Runtime Version of the CefSharp.Wpf.dll (4.0.30319) as opposed to the actual folder package name within the solution (3.2987.1601) - this was due to my lack of understanding of how the new entries within the csproj file worked and by delving into this a little this identified our problem. Doh!

Again, thanks for your help!

Tom

@OceanAirdrop
Copy link

Hi Tom. Cheers. Good to here you are up and running over there.

@brandonyoung
Copy link

@tomwestwood I would love to hear a bit more on the fix.. I have been fighting this for a couple of days now.

@tomwestwood
Copy link

Hi Brandon,

If you're having the same problem we were, I'd advise ensuring the ItemGroup entries you've added into the .csproj file match up with those in the packages folder of your solution (browse to the root of your solution with windows explorer). Also ensure you are targeting x86. We didn't require and pre/post build commands or anything like that in the end.

What steps have you taken so far? I can tell you the exact order we did things in if that would help?

Tom

@brandonyoung
Copy link

Yeah anything helps..

I added the csproj additions to the bottom. The build server is building targeting x86 and the mage.exe is being called with x86 as well. I am not totally sure what is missing.

Brandon

@brandonyoung
Copy link

@tomwestwood are you willing to share the final csproj inclusion and any other gotchas you hit? I know it has to be something small.

Thanks

Brandon

@tomwestwood
Copy link

tomwestwood commented Jul 13, 2017

Find attached the full .csproj file (shown when you right-click > unload your Client project and then edit the .csproj file in Visual Studio).

The info that I changed manually is right at the bottom.

csproj.txt

@mtayyab063
Copy link

i am having same issue, i have a clickonce setup that i execute through Task Scheduler. a very quick window appears and then suddenly disappears in no time. i am facing this issue only on windows 10, on windows 7, 8 its working perfect. anyone has any idea?

@amaitland

This comment has been minimized.

@OceanAirdrop
Copy link

Excellent work Alex. Thanks.

@in10se
Copy link

in10se commented Jul 27, 2018

@croemheld Thank you. Worked like a charm!

@amaitland
Copy link
Member

Manually including the unmanaged files should no longer be required, see #2156 for details.

Reports suggest it appears it is still required. If your clickonce installer isn't including the unmanaged files then you can attempt something like below:

You should in theory be able to create your own .targets file and import it after the .targets file from CefSharp. (in your .csproj or .vbproj). This example is for x86 only, you can easily modify it for x64 by changing 32 to 64. If you are using AnyCPU then look at the .targets/.props files in https://github.com/cefsharp/CefSharp/tree/master/NuGet too see how the current files are included.

<ItemGroup>
    <Content Include="@(CefRedist32)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpCommonBinaries32)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
</ItemGroup>

This approach should not require any changes if you update to a newer version.

NOTE: I have not tested this, pieces might be missing or incorrect, it's up to someone producing a ClickOnce setup to fill in any blanks, correct any mistakes. It's provided as a guide only.

@sa-he
Copy link

sa-he commented Mar 21, 2019

Based on croemheld's answer, I've created this approach which works with PackageReferences..

<!-- Include CefSharp files for support of ClickOnce deployment -->
<ItemGroup>
  <Content Include="$(UserProfile)\.nuget\packages\cef.redist.x86\3.3578.1870\CEF\**\*" Exclude="$(UserProfile)\.nuget\packages\cef.redist.x86\3.3578.1870\CEF\locales\*.pak">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <Visible>false</Visible>
  </Content>
  <Content Include="$(UserProfile)\.nuget\packages\cef.redist.x86\3.3578.1870\CEF\**\en-US.*;$(UserProfile)\.nuget\packages\cef.redist.x86\3.3578.1870\CEF\**\de.*">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <Visible>false</Visible>
  </Content>
  <Content Include="$(UserProfile)\.nuget\packages\cef.redist.x86\3.3578.1870\CEF\*">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <Visible>false</Visible>
  </Content>
  <Content Include="$(UserProfile)\.nuget\packages\cefsharp.common\71.0.2\CefSharp\x86\*.dll">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <Visible>false</Visible>
  </Content>
  <Content Include="$(UserProfile)\.nuget\packages\cefsharp.common\71.0.2\CefSharp\x86\*.exe">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <Visible>false</Visible>
  </Content>
  <Content Include="$(UserProfile)\.nuget\packages\cefsharp.wpf\71.0.2\CefSharp\x86\*.dll">
    <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
    <Visible>false</Visible>
  </Content>
</ItemGroup>

@paulpv
Copy link

paulpv commented Apr 3, 2019

@amaitland I tweaked your suggestion as follows, and it seems to run via ClickOnce just fine, but there are a lot of compiler warnings.

  <ItemGroup Condition="'$(Platform)' == 'x64'">
    <Content Include="@(CefRedist64)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpCommonBinaries64)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpWinFormsBinaries64)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(Platform)' == 'x86'">
    <Content Include="@(CefRedist32)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpCommonBinaries32)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpWinFormsBinaries32)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>

Theoretically FooAnyCPU includes could work too, but I haven't confirmed that yet (Any CPU has other known issues and steps required).

Warnings are along the lines of:

Warning		Assembly '.\packages\CefSharp.Common.71.0.2\CefSharp\x64\CefSharp.Core.dll' is incorrectly specified as a file.
Warning		The file '.\packages\CefSharp.Common.71.0.2\CefSharp\x64\CefSharp.Core.dll' could not be added to the project.  Cannot add a link to the file .\packages\CefSharp.Common.71.0.2\CefSharp\x64\CefSharp.Core.dll. This file is within the project directory tree.

@atuladhar
Copy link

I've targeted AnyCPU in my windows forms application with CEF 3.3578.1870. The applications works fine but clickonce application is not started. I've tried editing the .csproj file as mentioned by @croemheld and included both for x64 and x86. But upon editing the .csproj, the error of FileNotFound exception arises and application no longer runs. Also, tried adding the dlls as resource/content to copy in build folder. But clickonce application is not launched.. Is there anything else that I missed? Any help would be appreciated.

@dyerc
Copy link

dyerc commented May 7, 2019

Further building on @amaitland 's comment above. I have:

  1. Added a new file to my VS solution called cefsharp.targets containing:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Include CefSharp files for support of ClickOnce deployment -->
  <ItemGroup>
    <Content Include="@(CefRedist64)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpCommonBinaries64)">
      <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
</Project>
  1. Added the following to the end of my .csproj file which references the sub-targets file:
<Import Project="cefsharp.targets" Condition="Exists('cefsharp.targets')" />

This so far seems to work ok and definitely makes it more convenient than having to unload the .csproj file every time when testing.

VS does warn me about:

Warning: Publishing file 'CefSharp.BrowserSubprocess.Core.pdb' that may contain sensitive or proprietary information.
Warning: Publishing file 'CefSharp.BrowserSubprocess.pdb' that may contain sensitive or proprietary information.

Is there any way to exclude these files whilst preserving a CefSharp version ignorant targets file?

@zankhanarana9
Copy link

zankhanarana9 commented Jul 15, 2019

Hello all,

I am having the same issue. I followed the steps mentioned by @croemheld and a few other settings, but nothing seems to work.

I set the target platform to AnyCPU and I am able to install and run the application. However, the issue is, when I enter the Url and click on the Go button on my application, the browser is not loaded with the specified link. It works fine on the visual studio when I build and run my application. (The application is a simple browser like application. a text box where the user enters the Url clicks a button which handles the click event to load the CefSharp browser navigating to the Url specified by the user).

Can someone please help me figure out what am I doing wrong?

Thanks in advance.

@beingWH
Copy link

beingWH commented Jan 6, 2020

@croemheld
Thanks for your answer. Problems are solved by your csproj file.

@paulpv
Copy link

paulpv commented Jul 3, 2020

I've had the .targets file solution working with ClickOnce AnyCPU for nearly a year now w/ v79.x.
#1314 (comment)

I tried updating to the latest (as of today v83.4.2[0]), and ClickOnce stopped working. :/

I use a combination of the hacks above plus the hacks in #1714 (Option #2).
Again, this has been working fine for nearly a year.

I have enabled extensive logging to file during ClickOnce startup and can see it is failing to load the x64 assemblies.
Looking in the ClickOnce install folder there is no x64 sub-directory installed when using v83, but there is when using v79.
Something seems to have changed. :/

Still investigating...

@amaitland
Copy link
Member

See 2ec5a21#diff-20055252bad325be70c329dcee767196

@paulpv
Copy link

paulpv commented Jul 3, 2020

Ah! PEBCAK!
I had BOTH hacks (the .targets file and the imports directly in my .csproj)
The problem has nothing to do w/ changes in v83; the problem would have happened changing to any version because I hadn't updated the .csproj imports version numbers and my .targets file wasn't working.
I fixed the .targets file and removed the .csproj imports and it works fine now!

@paulpv
Copy link

paulpv commented Jul 3, 2020

Thanks @amaitland! That actually did help a little!

@paulpv
Copy link

paulpv commented Jul 4, 2020

FYI, my working .targets file is:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Condition="'$(Platform)' == 'x64' Or '$(Platform)' == 'AnyCPU'">
    <Content Include="@(CefRedist64)">
      <Link>x64\%(RecursiveDir)%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PublishState>Include</PublishState>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpCommonBinaries64)">
      <Link>x64\%(RecursiveDir)%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PublishState>Include</PublishState>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpWinFormsBinaries64)">
      <Link>x64\%(RecursiveDir)%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PublishState>Include</PublishState>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup Condition="'$(Platform)' == 'x86' Or '$(Platform)' == 'AnyCPU'">
    <Content Include="@(CefRedist32)">
      <Link>x86\%(RecursiveDir)%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PublishState>Include</PublishState>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpCommonBinaries32)">
      <Link>x86\%(RecursiveDir)%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PublishState>Include</PublishState>
      <Visible>false</Visible>
    </Content>
    <Content Include="@(CefSharpWinFormsBinaries32)">
      <Link>x86\%(RecursiveDir)%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PublishState>Include</PublishState>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>
</Project>

All I do is include this at the end of my .csproj file:

 <Import Project="MyProject.targets" />

@ryantm
Copy link

ryantm commented Nov 5, 2020

Here's yet another solution. I added this to my project's csproj file. Note this depends on the newer PackageReference way of specifying NuGet package dependencies, also it suffers from the problem of having to update all the version strings when upgrading to a new version of CefSharp (this could be avoided by using Pkg refs available in VS 2019, I'm using VS 2017 though):

<ItemGroup>
    <!-- The items in this group have been added because ClickOnce is not -->
    <!-- publishing them. Unfortunately all the DLLs and exes cause a -->
    <!-- warning message like: -->
    <!--   warning MSB3178: Assembly 'packages\CefSharp.Common.81.3.100\CefSharp\x86\CefSharp.BrowserSubprocess.Core.dll' is incorrectly specified as a file. -->
    <!-- I tried using <Reference> but the dlls and exes did not get copied into the ClickOnce deployment directory -->
    <!-- I tried adding these files to Application Files, but that gave this warning while publishing:  -->
    <!--   warning MSB3331: Unable to apply publish properties for item "cefsharp". -->
    <!-- the following list is based on https://github.com/cefsharp/CefSharp/wiki/Output-files-description-table-(Redistribution) -->
    <!-- We are not including the fancy 3D features. -->
    <Content Include="$(NuGetPackageRoot)CefSharp.Common\85.3.130\CefSharp\x86\CefSharp.BrowserSubprocess.exe;$(NuGetPackageRoot)CefSharp.Common\85.3.130\CefSharp\x86\CefSharp.BrowserSubprocess.Core.dll;$(NuGetPackageRoot)CefSharp.Common\85.3.130\CefSharp\x86\CefSharp.dll;$(NuGetPackageRoot)CefSharp.Common\85.3.130\CefSharp\x86\CefSharp.Core.dll;$(NuGetPackageRoot)CefSharp.WinForms\85.3.130\CefSharp\x86\CefSharp.WinForms.dll;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\libcef.dll;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\chrome_elf.dll;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\icudtl.dat;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\snapshot_blob.bin;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\v8_context_snapshot.bin;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\locales\en-US.pak;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\cef.pak;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\cef_100_percent.pak;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\cef_200_percent.pak;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\cef_extensions.pak;$(NuGetPackageRoot)cef.redist.x86\85.3.13\CEF\devtools_resources.pak">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
    </Content>
  </ItemGroup>

If anyone knows how to fix those msbuild warning messages, I'd be excited to hear about it.

@amaitland
Copy link
Member

amaitland commented Jan 9, 2021

The Nuget packages starting with 87.1.131-pre have been restructured and this includes changes that will impact on anyone using ClickOnce. Addition of a new CefSharp.Core.Runtime.dll and the many of the x86/x64 dlls have been converted to AnyCPU. Full details at #3319

In an attempt to better support ClickOnce I've added a new configruation option which allows for switching to using the <Content/> entries rather than the <None/> entries we use currently. See #3319 (comment) for details. I'd appreciate if people could take the time to test and report back on #3319

@SalmaTofaily
Copy link

SalmaTofaily commented Jan 20, 2021

I am new to WPF, ClickOnce and CefSharp.wpf.
I am trying to have a working standalone executable and I use VS 2019.

I tried to add all cef folders in publish, tried to have a separate resource folder... none worked.

image
image

After publishing, got the bellow output. Even my project builds normally and the exe is working within the release folder. Any idea??

Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4165,5): warning MSB3331: Unable to apply publish properties for item "cefsharp".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4165,5): warning MSB3331: Unable to apply publish properties for item "cefsharp.core".
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4165,5): warning MSB3331: Unable to apply publish properties for item "cefsharp.wpf" .Error: Cannot publish because a project failed to build.

image

I can build normally:
image

Any idea??

@amaitland
Copy link
Member

Anyone having problems my suggestion would be to upgrade to 87.1.131-pre (or higher,
The official 87 release will be out shortly) and follow the instructions at #3319 (comment)

@SalmaTofaily
Copy link

SalmaTofaily commented Jan 21, 2021

Thanks @amaitland for the new update, sounds interesting. But will not be able to do the update now as it is still in preview, and we are just pending deployment on the new solution.
Will have to try more!

@amaitland
Copy link
Member

amaitland commented Feb 12, 2021

In an attempt to better support ClickOnce I've added a new configruation option which allows for switching to using the <Content/> entries rather than the <None/> entries we use currently. See #3319 (comment) for details. I'd appreciate if people could take the time to test and report back on #3319

This is only working for PlatformTarget of x86/x64, when targeting AnyCPU it's not working see #3319 (comment) for details.

UPDATE: I've only tested with VS2019, reports suggest that VS2017 might not be working and you'll need to use one of the options listed above.

@janithcooray
Copy link

It isn't starting because it doesn't have the required files to load CefSharp.Core. You need to figure out how to get Click Once to deploy those files. In our application(using 39.0.2) we deploy the following:

locales/*.pak(too many to list)
cef.pak
cef_100_percent.pak
cef_200_percent.pak
CefSharp.BrowserSubprocess.Core.dll
CefSharp.BrowserSubProcess.exe
CefSharp.Core.dll
CefSharp.dll
CefSharp.Wpf.dll
d3dcompiler_43.dll
d3dcompiler_47.dll
devtools_resources.pak
ffmpegsumo.dll
icudtl.dat
libcef.dll
libEGL.dll
libGLESv2.dll
pdf.dll

In your listings of the *.deploy files I don't see any of them. You need to figure out how to get Click Once to deploy them or the application will never start.

This Worked
for those who still have trouble including them in click once >
https://docs.microsoft.com/en-us/visualstudio/deployment/how-to-specify-which-files-are-published-by-clickonce?view=vs-2019

@benwmills

This comment has been minimized.

@amaitland
Copy link
Member

Anyone targeting x86/x64 should use the instructions linked at #1314 (comment)

Both VS2017 and VS2019 should work as expected.

For targeting AnyCPU self hosting the browser sub process should resolve the problem described in #3319 (comment) (also following the instructions listed at #3319 (comment)).

Self hosting details at #3407 (comment) (If targeting .Net 4.x the code used should be exactly the same).

As there is a lot of outdated information contained within this thread I'm going to lock the conversation.

If you are still having problems then please join in the discussion at #3613

@cefsharp cefsharp locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests