views:

608

answers:

3

I use an XML file in App_Data in conjunction with a Repeater on the main page of an intranet application allow me to display messages to users when they logon about application status, maintenance, etc. To test the functionality, it would be nice to have the file in the App_Data folder under development, but if I do this it copies it over the file on the production server when I publish the application. Is there anyway I can prevent this from happening short of going to a Web Deployment project (and will that solve my problem)?

+1  A: 

In Visual Studio 2005, I see a checkbox labeled "Include files from the App_Data folder", which defaults to checked. Have you tried publishing with that checkbox unchecked?

EDIT: Seeing as how that checkbox isn't available for your project, I would look into using the VS2005 Web Deployment add-on for visual studio. I haven't used it myself but the features to customize publishing between debug and release mode looks promising.

J c
The checkbox doesn't seem to be there on a Web Site, perhaps it's only available for a Web Application. Wouldn't work for me anyway as I have other XML files that do need to be published.
tvanfosson
+1  A: 

To avoid that problem I would also deploy to a local "staging" location, essentially a folder on my desktop. Once the files were compiled and deployed there by Visual Studio I would delete the files I wasn't interested in (in your case App_Data) and then either XCopy or using Windows Explorer to copy the files to the web server.

Other than something similar to that, I know of no way to make Visual Studio itself omitted those files/folder on deployment.

Jason Whitehorn
My work around to test the functionality in development right now is to not include the file in the project, set a breakpoint in the code where it opens the file, and manually change the path so that it looks at a file I've created in C:\Temp. I was hoping there was a way to exclude certain files.
tvanfosson
+1  A: 

Another approach is to have a "debug" file and a "production" file..

Stream xml;
#if DEBUG
xml = File.Open("debug.xml");
#else
xml = File.Open("release.xml");
#endif

Compiling in DEBUG mode will use the debug file, compiling in release mode will use release file.

Andrew Theken