Panda
Panda

Reputation:

Where to Add a folder in .net solution so that while building the project folder should be created?

Where to Add a folder in .net solution so that while building the project folder should be created?

Upvotes: 1

Views: 1001

Answers (6)

Jaswant Agarwal
Jaswant Agarwal

Reputation: 4905

I also face same issues as suppose i have one report folder with all the .rpt files and after building the project that Report folder need to be copied in debug or release folder based on debugging mode..

And i applied the same logic for Mkdir in Postbuild event and added another commands to copy the things from original location of folder to the new folder being created..

Upvotes: 0

RobV
RobV

Reputation: 28646

If the folder isn't needed until runtime you can generally just do a Directory.Exists check for it in your program start up logic and create the folder(s) as required.

Otherwise a folder added to the solution has to have something in it which has Build Action of None (or Content I think) and which has the Copy to Output Directory property set

Upvotes: 0

Mac
Mac

Reputation: 8339

If I understood you correctly, you want to create a folder in the output directory as part of the build process. I see two ways to achieve that :

  1. Tweak your .csproj file using MSBuild tasks (specifically MakeDir) :

    <Target Name="AfterBuild">
      <MakeDir Directories="$(TargetDir)\MyFolder" />
    </Target>
    
  2. Use DOS commands in the post-build step : alt text

Upvotes: 3

Paolo Tedesco
Paolo Tedesco

Reputation: 57202

You could just use a post-build step:

mkdir $(TargetDir)\MyDirectory

Upvotes: 3

Noon Silk
Noon Silk

Reputation: 55082

Annoyingly, a folder won't be created if it doesn't have anything in it (at least, IIRC). I've added a 'blank.txt' to a folder before, and then you can just delete that, post-build.

Upvotes: 1

Noam Gal
Noam Gal

Reputation: 3405

Not sure what you mean there, but generally speaking, creating a folder inside the solution only creates a virtual folder - no actual folder is created on your file system. If you want the actual folders to match the ones appearing in your solution, just manually create a folder using the windows explorer (Or any other way you like) at the same spot, using the same name.
I have no idea what those solution virtual folders are good for.

Upvotes: 0

Related Questions