wpf 您如何在 ClickOnce 部署中包含许多其他文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34387761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 13:35:43  来源:igfitidea点击:

How do you include many additional files with ClickOnce deployment?

c#wpfvisual-studiodeploymentclickonce

提问by Lori Austin

I am trying to deploy my first WPF, C# application to many desktops. For most records in the case database there is a large PDF which I want to store separate from the database and is displayed when a button is pressed (PDF filename equals the id number). It is a search only program, no data is being saved back to the database by users. There are approximately 32,000 pdfs and this number will grow. When I tried to list these files in the project and use ClickOnce to Deploy VS said I had exceeded the maximum manifest size.

我正在尝试将我的第一个 WPF、C# 应用程序部署到许多桌面。对于案例数据库中的大多数记录,我想将它与数据库分开存储并在按下按钮时显示(PDF 文件名等于 ID 号)。它是一个仅搜索程序,用户不会将数据保存回数据库。大约有 32,000 份 pdf,而且这个数字还会增长。当我尝试在项目中列出这些文件并使用 ClickOnce 部署时,VS 说我已经超出了最大清单大小。

Is there a way to deploy my app with ClickOnce and then copy the files with some type of post-install command? Thank you.

有没有办法使用 ClickOnce 部署我的应用程序,然后使用某种类型的安装后命令复制文件?谢谢你。

回答by Mohit Shrivastava

Add the files to your project. Mark the Build Action as Contentand the Copy to local directoryto Always. Then it will include the files with your deployment.

将文件添加到您的项目中。将 Build Action 标记为ContentCopy to local directoryto Always。然后它将在您的部署中包含这些文件。

You can also check the Application Files dialog to see if they are there. And if the files have a file extension of XML or something that indicates data, you want to change the option from Include(Data)to Includeor Include(Required). If you include a file as data, it is put in the DataDirectory after deployment.

您还可以检查“应用程序文件”对话框以查看它们是否存在。如果文件的文件扩展名为 XML 或表示数据的内容,您希望将选项从 更改Include(Data)IncludeInclude(Required)。如果将文件包含为数据,则部署后会将其放入 DataDirectory。

  • Select a data file in Solution Explorer.
  • In the Properties window, change the Build Action property to the Content value
  • 在解决方案资源管理器中选择一个数据文件。
  • 在 Properties 窗口中,将 Build Action 属性更改为 Content 值

2. To mark files as data files

2. 将文件标记为数据文件

  • With a project selected in Solution Explorer, on the Project menu, click Properties.
  • Click the Publish tab.
  • Click the Application Files button to open the Application Files dialog box.
  • In the Application Files dialog box, select the file that you wish to mark as data.
  • In the Publish Status field, select Data File from the drop-down list.
  • 在解决方案资源管理器中选择一个项目后,在“项目”菜单上,单击“属性”。
  • 单击发布选项卡。
  • 单击应用程序文件按钮打开应用程序文件对话框。
  • 在“应用程序文件”对话框中,选择要标记为数据的文件。
  • 在发布状态字段中,从下拉列表中选择数据文件。

3. To mark files as prerequisites

3. 将文件标记为先决条件

  • With a project selected in Solution Explorer, on the Project menu, click Properties.
  • Click the Publish tab.
  • Click the Application Files button to open the Application Files dialog box.
  • In the Application Files dialog box, select the application assembly (.dll file) that you wish to mark as a prerequisite. Note that your application must have a reference to the application assembly in order for it to appear in the list.
  • In the Publish Status field, select Prerequisite from the drop-down list.
  • 在解决方案资源管理器中选择一个项目后,在“项目”菜单上,单击“属性”。
  • 单击发布选项卡。
  • 单击应用程序文件按钮打开应用程序文件对话框。
  • 在“应用程序文件”对话框中,选择要标记为先决条件的应用程序程序集(.dll 文件)。请注意,您的应用程序必须具有对应用程序程序集的引用才能使其出现在列表中。
  • 在发布状态字段中,从下拉列表中选择先决条件。

Source: MSDN - How to: Specify Which Files Are Published by ClickOnce

来源:MSDN - 如何:指定 ClickOnce 发布哪些文件