17

I am using visual studio 2013 & Fluent Validation 5.6.2

I see that after build in the bin folder it copies all the culture specific FluentValidation.resources.dll which seems to be mentioned it in .nuspec file

> <file src="lib\NET35\de\FluentValidation.resources.dll"
> target="lib\NET35\de\FluentValidation.resources.dll" />
>     <file src="lib\NET35\es\FluentValidation.resources.dll" target="lib\NET35\es\FluentValidation.resources.dll" />
>     <file src="lib\NET35\fr\FluentValidation.resources.dll" target="lib\NET35\fr\FluentValidation.resources.dll" />
>     <file src="lib\NET35\it\FluentValidation.resources.dll" target="lib\NET35\it\FluentValidation.resources.dll" />
>     <file src="lib\NET35\nl\FluentValidation.resources.dll" target="lib\NET35\nl\FluentValidation.resources.dll" />
>     <file src="lib\NET35\pt\FluentValidation.resources.dll" target="lib\NET35\pt\FluentValidation.resources.dll" />
>     <file src="lib\NET35\sv\FluentValidation.resources.dll" target="lib\NET35\sv\FluentValidation.resources.dll" />

But I do not need these in bin folder, because project does not support any culture specific messages.

So how can I tell vs-build to ignore these culture specific dlls?

algos
  • 238
  • 2
  • 8
  • Did you find a solution for this? – Alex Oct 15 '15 at 05:53
  • Those assemblies are included in the Fluent Validation package, so one way is to remove all unwanted cultures from the package (With the hassle to re-apply the changes for each new release) or do an after-build cleanup. – Alex Oct 15 '15 at 12:00
  • that way i am aware, but is looking for better solution – algos Oct 15 '15 at 14:38
  • Does this answer your question? [Omit localized versions of assemblies from the build output](https://stackoverflow.com/questions/30262592/omit-localized-versions-of-assemblies-from-the-build-output) – thalm Jan 29 '20 at 03:51

2 Answers2

22

My solution was to add this target at the end of the .csproj file before the closing project tag.

<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="RemoveTranslationsAfterBuild" AfterTargets="AfterBuild">
    <RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutputPath)%(Filename)')" />
</Target>

<Target Name="RemoveTranslationsAfterPackage" AfterTargets="AfterPackage">
    <RemoveDir Directories="@(FluentValidationExcludedCultures->'$(_PackageTempDir)\$(OutputPath)%(Filename)')" />
</Target>

It's not pretty, but it gets the job done. If you need some culture specific resource, just remove the corresponding line from the list. If a future update adds a new culture that you don't want, add it to the list.

The best option would be ask the developer to separate the resources in multiple nugets, this way you could just add the ones needed. I'll stick with this solution, for now, until someone come up with a better one.


Now you can find my solution at the official project wiki: https://github.com/JeremySkinner/FluentValidation/wiki/f.-Localization (at the bottom of the page)

Marcos
  • 3,263
  • 1
  • 23
  • 22
  • And what about the same but Publish? I mean, I see those folders in the BIN directory after publishing. – Romias Aug 05 '16 at 16:35
  • @Romias, please try my updated answer, that addresses the _Publish_ scenario. It's important that you clean the deployment destination once, if you already had deployed before. – Marcos Aug 06 '16 at 21:10
  • There is a better solution now, this answer should not be flagged as a solution anymore: https://stackoverflow.com/questions/30262592/omit-localized-versions-of-assemblies-from-the-build-output – thalm Mar 04 '20 at 17:01
0

i had same problem with external library, i'm add post-build script in Visual Studio project properties, which delete all folders (for me it`s okay, otherwise set list of dirs) at output directory:

FOR /D %%d IN ($(TargetDir)*) DO RMDIR /S /Q %%d
progpow
  • 1,560
  • 13
  • 26