如何强制MSBuild复制项目中的空文件夹? [英] How to force MSBuild to copy empty folders in project?

查看:74
本文介绍了如何强制MSBuild复制项目中的空文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2012中有一个MVC 4项目.其中没有一个Logs文件夹,其中仅包含四个空子文件夹.我使用的一个库需要这种结构.我包括了这些文件夹,以便进行这样的投影:

I have an MVC 4 project in Visual Studio 2012. There is Logs folder in it containing only four empty subfolders. This structure is needed by one library I use. I included these folders to project like this:

<ItemGroup>
    <Folder Include="App_Data\" />
    <Folder Include="XSockets\XSocketServerPlugins\Log\XConnectionInterceptor\" />
    <Folder Include="XSockets\XSocketServerPlugins\Log\XErrorInterceptor\" />
    <Folder Include="XSockets\XSocketServerPlugins\Log\XHandshakeInterceptor\" />
    <Folder Include="XSockets\XSocketServerPlugins\Log\XMessageInterceptor\" />
</ItemGroup>

但这还不够,并且所有这些文件夹(包括Visual Studio创建项目时所在的App_Data)都不会复制到程序包中.我可以以某种方式强迫MSBuild复制它们,即使它们为空吗?

But this is not enough and all these folders (including App_Data which was there from creation of project by Visual Studio) are not copied to package. Can I somehow force MSBuild to copy them even though they are empty?

推荐答案

添加PostBuild步骤以复制文件夹.

Add a PostBuild step to copy the folders.

我不能专门针对VS2012进行回答,但是这是您在VS2010中执行的操作:

I can't answer specifically for VS2012, but here's how you do this in VS2010:

  • 右键单击该项目,然后选择属性"
  • 显示构建事件"标签
  • 将复制命令放入构建后事件命令中

如果单击编辑"按钮,则弹出对话框将带有一个宏按钮,其中列出了所有可用的VS变量,可用于避免使用显式路径等.

If you click the edit button, the pop-up dialog will have a macros button that lists all of the available VS variables you can use to avoid using explicit paths, etc.

在VS2010中,这会将项目文件修改为如下所示:

In VS2010, that modifies the project file to look something like this:


  <PropertyGroup>
    <PostBuildEvent>copy /Y "$(TargetDir)\*.*" "$(ProjectDir)\..\..\..\net40"</PostBuildEvent>
  </PropertyGroup>

这篇关于如何强制MSBuild复制项目中的空文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆