CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

ClickOnce application not starting

Open croemheld opened this issue 11 years ago • 43 comments

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/cefsharp/CefSharp/issues/500] and [https://github.com/cefsharp/CefSharp/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!

croemheld avatar Oct 07 '15 15:10 croemheld

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.

taylorjonl avatar Oct 07 '15 20:10 taylorjonl

@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.

croemheld avatar Oct 07 '15 22:10 croemheld

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.

taylorjonl avatar Oct 07 '15 22:10 taylorjonl

@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?

croemheld avatar Oct 07 '15 23:10 croemheld

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.

taylorjonl avatar Oct 08 '15 00:10 taylorjonl

@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>

croemheld avatar Oct 08 '15 10:10 croemheld

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

davestevens avatar Jan 11 '16 15:01 davestevens

+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.

OceanAirdrop avatar Sep 24 '16 10:09 OceanAirdrop

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

tomwestwood avatar Jul 03 '17 16:07 tomwestwood

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 avatar Jul 03 '17 17:07 OceanAirdrop

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!

OceanAirdrop avatar Jul 03 '17 17:07 OceanAirdrop

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

tomwestwood avatar Jul 07 '17 11:07 tomwestwood

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

OceanAirdrop avatar Jul 07 '17 12:07 OceanAirdrop

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

brandonyoung avatar Jul 10 '17 02:07 brandonyoung

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

tomwestwood avatar Jul 10 '17 08:07 tomwestwood

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 avatar Jul 10 '17 15:07 brandonyoung

@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

brandonyoung avatar Jul 13 '17 08:07 brandonyoung

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

tomwestwood avatar Jul 13 '17 15:07 tomwestwood

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?

mtayyab063 avatar Aug 22 '17 05:08 mtayyab063

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

amaitland avatar Jan 23 '18 02:01 amaitland