Is there a way to keep files in App_Data from over

2019-07-22 20:22发布

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)?

3条回答
Rolldiameter
2楼-- · 2019-07-22 20:57

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.

查看更多
我命由我不由天
3楼-- · 2019-07-22 20:59

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.

查看更多
混吃等死
4楼-- · 2019-07-22 21:02

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.

查看更多
登录 后发表回答