Episodex
Episodex

Reputation: 4559

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?

Upvotes: 5

Views: 3667

Answers (2)

Brenda Bell
Brenda Bell

Reputation: 1139

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>

Upvotes: 4

Uffe
Uffe

Reputation: 2275

Do not edit the project file. I can see that you are using an older version on XSockets, Right?

Do as Brenda says and do not mind the project file. Look at the image attached... build events

Not 100% sure that it is this that you are looking for, but... it shows both pre- and post- build events

Regards Uffe, Team XSockets

Upvotes: 3

Related Questions