MSBuild create folder if folder does not exists

Viewed 1253

Similarly to this question, but rather than creating a file if it doesn't exist - I want to create a folder, if it doesn't exist.

1 Answers

MSBuild create folder if folder does not exists

To create a folder if folder does not exists, you can use the below xml code:

  <Target Name="MakeMyDir" AfterTargets="PrepareForBuild">
    <MakeDir Directories="$(ProjectDir)Newfolder" Condition="!Exists('$(ProjectDir)Newfolder')"  />
  </Target>

Newfolder is the name of your created folder.

Related