Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including xml files when deploying WPF application

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.

like image 999
naveen Avatar asked Apr 05 '11 06:04

naveen


2 Answers

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.

like image 168
sunil ambiger Avatar answered Sep 20 '22 12:09

sunil ambiger


there a 2 locations clickonce uses:

  • a location for the main executable and all necessary dll's
  • a location for everything that isn't executable, i.e. resources, like your xml

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.

like image 30
Terry Avatar answered Sep 20 '22 12:09

Terry