Reputation: 2726
I am using VS Code and Net Core 1.1.1
I need to create a folder named "Database" inside my output directory at building time. This is the folder where I want the sqlite database to be stored after creation.
I already copy files into the output folder like this:
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\\Seed\\Countries.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
How should I modify the .csproj file to automatically create the folder I need in my output direcory?
As suggested in this old question, I tried to add the following code but the folder is not created.
<Target Name="efcore">
<MakeDir Directories="$(OutDir)Database" Condition="!Exists('$(OutDir)Database')" />
</Target>
Upvotes: 6
Views: 9147
Reputation: 26773
You almost had it. You need to chain your target into the build system by adding "AfterTargets".
<Target Name="MakeMyDir" AfterTargets="Build">
<MakeDir Directories="$(OutDir)Database" />
</Target>
Upvotes: 20