Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force MSBuild to copy empty folders in project?

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>

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?

like image 937
Episodex Avatar asked Oct 23 '12 07:10

Episodex


1 Answers

Add a PostBuild step to copy the folders.

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

  • Right-click on the project and select Properties
  • Display the Build Events tab
  • Put your copy commands in the post-build event commands

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.

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


  <PropertyGroup>
    <PostBuildEvent>copy /Y "$(TargetDir)\*.*" "$(ProjectDir)\..\..\..\net40"</PostBuildEvent>
  </PropertyGroup>
like image 102
Brenda Bell Avatar answered Oct 03 '22 06:10

Brenda Bell