Friday, March 17, 2017

Delete folders after publish with new ASP.NET CORE 1.1 csproj file format

Leave a Comment

I am publishing an ASP.NET Core 1.1 application and I need to delete from the output a few folders (fr;nl;pt) created by a library (Fluent Validation):

<ItemGroup>   <FluentValidationExcludedCultures Include="fr;nl;pt">     <InProject>false</InProject>   </FluentValidationExcludedCultures> </ItemGroup>  <Target Name="RemoveTranslationsAfterBuild" AfterTargets="AfterBuild">   <RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutputPath)%(Filename)')" /> </Target> 

But this does not work and the folders are still copied ... Then I tried:

<ItemGroup>   <Content Include="fr" CopyToPublishDirectory="Never" />   <Content Include="nl" CopyToPublishDirectory="Never" />   <Content Include="pt" CopyToPublishDirectory="Never" /> </ItemGroup> 

But this didn't work either ...

Does anyone has any idea how to make this work?

1 Answers

Answers 1

Try to edit your csproj file and add the following section for each of the directories that you do not want to include when publishing:

<ItemGroup>     <PublishFile Remove="directory\**" /> </ItemGroup> 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment