简体   繁体   中英

Web.Config to not publish certain files

I am curious if it is possible to specify in a web.config file to have visual studio not publish certain files or a certain directory.

The use case that I am trying to solve for is that I have a Test folder on a web app, that provides a series of useful pages for testing and debugging. The pages are very useful for development and qa. However in production they should not exist. What I would like is that when I publish my code with the release config that these files, or the entire folder is not published.

It doesn't really matter where the build conditions are stored, what is important is how you're gonna use them during build/publish. A conditional msbuild script would easily solve your issue - one of build tasks would be to publish/discard files depending of the value of some internal msbuild property and the property value comes from the web.config or any other external source (build script parameter, external XML file, etc.)

You could exclude the folder from your solution, then in publish it would not push it out. Then, if you want it back in your solution, it will still be there. Just right click the folder and include it.

I don't really if this is the "right" way or even possible to do what you are asking.

What I would suggest is to create a second project for your test. I usually go that way and just deploy the second "project" in my test environement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM