部署 WPF 应用程序时包含 xml 文件
我有一个 WPF 应用程序,有 3 个项目来代表 3 层架构。确定1个项目为主体工程。我的非主项目之一中有一些 XML 文件。这些 XML 文件由该项目的类中定义的函数访问。
当我尝试使用 VS2010 ClickOnce 发布应用程序时,即使将文件的“构建操作到内容”和“复制到输出目录”标记为“始终复制”,XML 文件也不会包含在安装文件中。运行已安装的应用程序时,应用程序报告找不到文件。我可以在 ClickOnce 生成的安装文件夹中看到 Application_Files 文件夹,但它不包含 XML 文件。
所以,我的问题是如何将 XML 文件包含在安装文件夹中,并在运行应用程序时获取它们的位置 URL。
谢谢, 纳文
更新 1: 应用程序解决方案结构由三个项目组成,即 P1、P2 和 P3。 P3是主要的启动项目。 P1和P2是类库项目。 XML 文件将添加到 P2 项目中。这些文件被标记为“构建操作 ->”内容和副本 ->始终复制。但是,在发布应用程序时,ClickOnce 不会将这些文件复制到应用程序的数据文件夹中。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单的解决方案。
右键单击要发布的项目文件。
选择属性。
然后在打开的窗口中选择发布。
单击应用程序文件按钮。
在那里,找到 .xml 文件,默认情况下该文件的类型为“数据文件”。将其更改为包含。
保存重建并发布,就是这样。
希望它可以帮助有需要的人。
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.
clickonce 使用 2 个位置:
因此您有一个应用程序目录和一个数据目录。仍然可以像
AppDomain.CurrentDomain.BaseDirectory
那样寻址应用程序目录。但是,如果您想寻址数据目录,则需要针对单击一次的特定内容:
ApplicationDeployment.CurrentDeployment.DataDirectory
。我不确定您是否检查过该数据目录,因为您在帖子中没有提到它。
there a 2 locations clickonce uses:
so you have an application directory and a data directory. Addressing the application dir can still be done like this
AppDomain.CurrentDomain.BaseDirectory
.But if you want to address the data dir, you need something specific for the clickonce:
ApplicationDeployment.CurrentDeployment.DataDirectory
.I'm not sure if you have checked that data dir, because you haven't mentioned it in your post.