问题描述
我有一个简单的WinForms应用程序,正在使用ClickOnce在内部进行部署。主应用程序具有从属程序集,该程序集在构建属性中具有一些标记为内容和始终复制的xml模板文件,但是如果我进入项目属性,它们将不会显示在应用程序文件列表中- >发布->应用程序文件对话框。
I have a simple WinForms app that I am deploying internally using ClickOnce. The main application has a dependent assembly, that assembly has some xml template files marked as "Content" and "Copy Always" in the build properties, however they do not show up in the list of Application Files if I go into the Project Properties->Publish->Application Files dialog.
任何人都知道我如何部署这些依赖程序集的Xml文件。
Anyone know how I can deploy these Xml files that are part of a dependent assembly.
@codeConcussion-谢谢,效果很好。最后,我使用添加现有文件添加了xml文件,并选择了添加为链接,完成了同样的事情。
@codeConcussion- Thanks, that worked great. In the end I added the xml file using a Add Existing File and selected 'Add as Link', which accomplished the same thing.
推荐答案
我使用的是VS 2008 SP1,所以我不确定这与以前的VS版本完全一样。
I'm using VS 2008 SP1, so I'm not sure this will work exactly the same for previous VS versions.
您可以通过以下方法解决问题只需在您的主项目中添加一个构建后事件即可。在VB.Net项目中,该项目为我的项目>编译选项卡>构建事件...>编辑构建后的版本... 。在C#中,项目属性>构建事件>编辑构建后... 。一个简单的 xcopy [源文件] [目标文件夹] 命令应该可以将xml模板文件从从属程序集的bin文件夹复制到主项目的bin文件夹。
You can take care of your problem by simply adding a post-build event to your main project. In a VB.Net project that would be My Project > Compile Tab > Build Events... > Edit Post Build.... In C#, Project Properities > Build Events > Edit Post-build.... A simple xcopy [source file] [destination folder] command to copy the xml template file from the dependent assembly's bin folder to the main project's bin folder should work.
从那里开始,只需确保在发布选项卡的应用程序文件对话框中选中显示所有文件即可。
From there, just make sure you check "Show all files" in the Application Files dialog of the Publish tab.
另一种方法是更改您的两个项目以构建到相同的bin文件夹。效果很好,但只有在依赖程序集特定于此应用程序并且不是多个应用程序使用的库程序集的情况下,我才会这样做。
An alternative to this would be to change your two projects to build to the same bin folder. That works great but I would only do it if the dependent assembly is specific to this application and isn't a library assembly used by multiple apps.
这篇关于使用ClickOnce从相关程序集中部署内容文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!