Deploying an external file in a C # solution using clickonce

I have a problem with Visual Studio Express 2010 C #. I have a project that references a DLL. This DLL has an external Excel file marked as Build Action = Content Copy to Output Directory = Always Copy

When I create a solution, this Excel file is correctly copied to the solution folder BIN \ release.

BUT, if I try to deploy the same solution using the publish wizard, the Excel file will not be copied to the installation directory.

Please can someone help me?

+4
source share
5 answers

Are you saying that the Excel file only refers to the DLL that you include in your project? This is a secondary link, and ClickOnce will not see it and will automatically include the file.

First, in your DLL, I assume that it refers directly to your project. If so, then make sure you add it to your project, and set "Build Actions" to "none" and "Copy to output directory" so that "not copy". Then remove the link to it and add it, pointing it to the version included in your project. Set the copy local property to true. This will ensure proper dll deployment.

For an Excel file, you will need to add it to your project. Set the build action to "content" and set "copy to output directory" to "copy always". It will not be included automatically, as it is a secondary link to the ClickOnce application, and not a direct / primary link such as a DLL.

+4
source

Open Publish Properties for the ClickOnce Project. Then click the "Application Files ..." button. This launches a dialog in which you can control which files are included in the publication package.

In order for your XLSX file (or any other non-line file) to appear in this dialog box, you need to be marked as "Content" in the "Action" window of the properties window.

+8
source

Try to include this file in the solution and set the option "Copy to output directory" to "Always copy"

0
source

It seems your file is not listed in the "PublishFiles" list. Open the "Project Properties", go to the "Publish" tab, click the "Application Files" button, make sure that you see the DLL file in the list of files with the publication status as "Include".

0
source

You can avoid this problem by pasting the Excel file as a resource, and then write it like this:

File.WriteAllBytes(DestinationFileName, Properties.Resources.MyResourceFile); 

I make the assumption that the Excel file is some kind of template that you use to create the output file.

0
source

All Articles