使用新的ASP.NET CORE 1.1 csproj文件格式在发布后删除文件夹

时间:2017-03-02 17:02:00

标签: msbuild asp.net-core

我正在发布一个ASP.NET Core 1.1应用程序,我需要从输出中删除一个由库创建的文件夹(fr; nl; pt)(Fluent Validation):

<ItemGroup>
  <FluentValidationExcludedCultures Include="fr;nl;pt">
    <InProject>false</InProject>
  </FluentValidationExcludedCultures>
</ItemGroup>

<Target Name="RemoveTranslationsAfterBuild" AfterTargets="AfterBuild">
  <RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutputPath)%(Filename)')" />
</Target>

但这不起作用,文件夹仍然被复制......然后我尝试了:

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

但是这也不起作用......

有没有人知道如何使这项工作?

2 个答案:

答案 0 :(得分:2)

尝试编辑csproj文件,并为发布时不想包含的每个目录添加以下部分:

cloudinary.uploader.upload('my_image.jpg', function(result) { console.log(result) }, 
                       { public_id: "sample_image", overwrite:true, invalidate,true });

答案 1 :(得分:0)

另一种适用于构建/发布的解决方案

<!-- Removes FluentValidation localization folders -->
  <Target Name="AfterPackage" AfterTargets="CopyAllFilesToSingleFolderForPackage" />
  <ItemGroup>
    <FluentValidationExcludedCultures Include="cs;da;de;es;fa;fi;fr;it;ko;mk;nl;pl;pt;ru;sv;tr;zh-CN">
      <InProject>false</InProject>
    </FluentValidationExcludedCultures>
  </ItemGroup>
  <Target Name="FluentValidationRemoveTranslationsAfterBuild" AfterTargets="AfterBuild">
    <RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutDir)%(Filename)')" />
  </Target>
  <Target Name="FluentValidationRemoveTranslationsAfterPackage" AfterTargets="AfterPublish">
    <RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutDir)%(Filename)')" />
  </Target>