将空目录发布到VS2010 Web项目中的Web应用程序

将空目录发布到VS2010 Web项目中的Web应用程序

问题描述:

我经常需要发布一个保留目录树的Web项目,即使目录为空,例如,用于保存上载文件的目录。
如果我使用VS2010 publish命令发布应用程序,则不会在Web服务器的远程文件系统上创建空目录。

Often I need to publish a web project preserving a directory tree even if the directories are empty, for example, directories to hold uploaded files. If I publish my app using the VS2010 publish command, the empty directories are not created on the remote filesystem, on the web server.

有没有办法强制VS在目标目录上创建某些文件夹(尽管是空的)?
谢谢!

Is there a way to force VS to create certain folders, albeit empty, on the target directory? thanks!

不可能,这恐怕也有同样的问题。如果要预编译工具生成这些空文件夹,则需要在每个空目录中创建一个placeholder.txt文件。否则,您将无法创建将在构建后事件中创建文件夹的命令行应用程序(但仅在使用Web应用程序项目而非网站项目的情况下)。

No this is not possible I'm afraid we had the same problem. You need to create a placeholder.txt file in each empty directory if you want the precompilation tool to generate these empty folders. Failing that you can create a command line app that will create the folders in your post build events (but only if you are using web application project not web site project).

希望这会有所帮助。