开发者

Deploy external file in c# solution with clickonce

开发者 https://www.devze.com 2023-04-12 19:41 出处:网络
I\'ve a problem with Visual Studio Express 2010 c# edition. I\'ve a project that reference a DLL. This DLL h开发者_JS百科as an external Excel file marked as

I've a problem with Visual Studio Express 2010 c# edition. I've a project that reference a DLL. This DLL h开发者_JS百科as an external Excel file marked as Build Action = Content Copy to Output Directory = Copy Always

When I build the solution, this Excel file is correctly copied into BIN\release solution folder.

BUT if I try to deploy the same solution, with Publish wizard, the Excel file is not copied in the install directory.

Please, could anyone help me?


Open the Publish properties for your ClickOnce project. Then click on the 'Application Files ...' button. That launches a dialog where you can control which files are being included in the publishing package.

In order for your XLSX file (or any other non build file) to appear in that dialog you need to mark is as 'Content' in the Build Action of the properties window.


Are you saying that the Excel file is referenced only by the dll you are including in your project? That is a secondary reference, and ClickOnce will not see it and automatically include the file.

First, on your dll, I'm assuming it is referenced directly by your project. If so, then be sure you have added it to your project and set the Build Action to "none" and "copy to output directory" to "do not copy". Then delete your reference to it and re-add it, pointing it to the version now included in your project. Set the "copy local" property to "true". This will ensure the dll itself gets deployed correctly.

For the Excel file, you are going to have to add it to your project. Set the build action to "content" and set "copy to output directory" as "copy always". It will not be included automatically because it is a secondary reference to the ClickOnce app, not a direct/primary reference like the dll is.


Try to include this file into solution and set "Copy to Output Directory" to "Copy always"


It appears your file is not listed in the "PublishFiles" list. Open the Projects Properties, go to "Publish" Tab, click on "Application Files" button, make sure you see the DLL file in the list of files with Publish Status as "Include".


You could avoid the problem by inserting the Excel file as a resource, then writing it out like this:

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

I'm making an assumption that the Excel file is some kind of template you are using to build an output file from.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号