在部署WPF应用程序时包括xml文件 [英] Including xml files when deploying WPF application

查看:204
本文介绍了在部署WPF应用程序时包括xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有3个项目的WPF应用程序来表示3层架构。一个项目被设定为主体项目。我在一个非主要项目中有一些XML文件。这些XML文件由该项目的类定义的函数访问。



当我尝试使用VS2010 ClickOnce发布应用程序时,即使在标记文件将操作内容和复制到之后,XML文件也不会包含在安装文件中-OutputDirectory作为始终复制。运行安装的应用程序时,应用程序会报告找不到文件。我可以在ClickOnce生成的安装文件夹中看到一个Application_Files文件夹,但不包含XML文件。



所以,我的问题是如何在安装文件夹中包含XML文件,并在运行应用程序时获取他们的位置URL。



谢谢,
Naveen



更新1:
应用程序解决方案结构由三个项目组成,如P1,P2,和P3。 P3是主要的启动项目。 P1和P2是类库项目。 XML文件被添加到P2项目中。文件被标记为构建操作 - >内容和复制 - >始终复制。但是,发布应用程序时,这些文件不会被ClickOnce复制到应用程序的数据文件夹。

解决方案

简单解决方案。
右键单击要发布的项目文件。
选择属性。
然后在打开的窗口中选择发布。
点击Apllication文件按钮。
在那里,找到哟.xml文件,默认为数据文件类型。将其更改为包含。
保存重建和发布。



希望它帮助有需要的人。


I have a WPF application with 3 projects to represent a 3-layer architecture. One project is set as the main project. I have some XML files in one of the non-main project. These XML files are accessed by functions defined in classes of that project.

When I try to publish the application using VS2010 ClickOnce, the XML files are not included in the installation file even after marking the files' Build Action to Content and Copy-to-OutputDirectory as Copy Always. When running the installed application, the application reports that the files are not found. I can see an Application_Files folder in the installation folder generated by ClickOnce, but it does not contain the XML files.

So, my question is how can I include the XML files in the installation folders and also get their location URL while running the application.

Thanks, Naveen

Update 1: The application solution structure consists of three projects, say P1, P2, and P3. P3 is the main startup project. P1 and P2 are class library projects. The XML files are added to the P2 project. The files are marked as Build Action -> Content and Copy -> Copy Always. However, these files are not copied to the application's data folder by ClickOnce while publishing the application.

解决方案

Simple Solution. Right click on yo project file which you want to publish. Select properties. Then select publish in the opened window. Click on Apllication files button. There, find yo .xml file, which will of type 'Data file' by default. Change it to Include. Save Rebuild and publish and thats it.

Hope it helps someone in need of it.

这篇关于在部署WPF应用程序时包括xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆