5

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?

Episodex
  • 4,479
  • 3
  • 41
  • 58
  • 1
    You can put a dummy empty file in each folder. Maybe not very "pure", but it should work and is fast to implement. – Damien_The_Unbeliever Oct 23 '12 at 07:52
  • I thought about this, but I hope there is some better and clean solution. – Episodex Oct 23 '12 at 08:01
  • Now I know that I asked wrong question. Even though answers below works for building, they are not working for me, because I'm using WebDeploy and folders are not copied to package. The only way (recommended by MS too) is to put dummy files as @Damien_The_Unbeliever wrote. – Episodex Nov 05 '12 at 09:27

2 Answers2

4

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>
David Gardiner
  • 16,892
  • 20
  • 80
  • 117
Brenda Bell
  • 1,139
  • 8
  • 10
  • I'm using regular VS project, not MSBuild script. Should I edit the project file to add this? Could you provide an example of doing this in project file? I'm new to build scripts. – Episodex Oct 26 '12 at 06:48
3

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

Uffe
  • 2,275
  • 1
  • 13
  • 9
  • Thanks! That should work, I'll check on Monday. Why do you think I'm using old version? I installed XSockets 2 to my MVC 4 app using nuGet. Maybe I did something wrong? – Episodex Nov 01 '12 at 20:14
  • Ohh, then everything is fine! My bad :) Thought that you had some config stuff (that we used to have in a previous version). Just ping me/us if you have any issues and we will help you out the best we can! – Uffe Nov 01 '12 at 22:42
  • Probably I'll contact you with some questions soon, when I have them organized and rethinked well :). Thanks for awesome work on XSockets! As for question I added comment why these solutions are not working for me, but they are correct for question I asked. – Episodex Nov 05 '12 at 09:31
  • You are most welocome to contact us at any time. contact[at]xsockets[dot]net will send the message to all memebers of the team! – Uffe Nov 06 '12 at 21:04