Disable Dll Culture Folders on Compile

C#.NetWpfCulture

C# Problem Overview


I'm using 2 dlls (Microsoft.Expression.Interactions.dll and System.Windows.Interactivity.dll) that, when the parent application is compiled, create loads of culture folders:

And inside each are 2 dlls (Microsoft.Expression.Interactions.resources.dll and System.Windows.Interactivity.resources.dll). I've googled around and I just can't find anything related to how to stop this annoying auto-generated content.

C# Solutions


Solution 1 - C#

Faced the same problem. My project uses ASP.NET Core 3.1

Add this line to your *.csproj

<PropertyGroup>
   <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>

Solution 2 - C#

There are two workarounds for this issue:

  • copy System.Windows.Interactivity.dll and add a reference directly to this file
  • remove those folders from:
    \Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries

Related links:
Original solution
https://stackoverflow.com/questions/29639129/generated-files-by-caliburn-micro-in-release-directory/29639287#29639287

Solution 3 - C#

I use other solution. You can configure Post-build event for your project in Vistual Studio, wich will remove redundant folders:

rd /s /q "de", "en", "es", "fr", "it", "ja", "ko", "ru", "zh-Hans", "zh-Hant"

This solution is less invasive than removes folders from sdk folder.

Solution 4 - C#

I found a good answer for .NET Core 3

Just add ExcludeAssets="All" to the package reference.

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" ExcludeAssets="All" />

This is the link for the original post on Microsoft Community: https://forums.asp.net/post/6281458.aspx

Solution 5 - C#

I had the same issue in my project on .NET Core 3.1 using nuget package Microsoft.VisualStudio.Web.CodeGeneration.Design

First of all DELETE folder 'bin' from your project directory.

Then you need to set option 'ExcludeAssets' for the package.

In Visual Studio here:

enter image description here

Or another way is direct change in *.csproj file like this:

...
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1">
    <ExcludeAssets>All</ExcludeAssets>
</PackageReference>
...

For me it solved the problem.

UPD: I found second solution - it's another way which lets you to chose which locale folders you need. But if you go this way - again delete 'bin' folder and set 'ExcludeAssets' option of chosen package to default value - empty.

In *.csproj file add tag 'SatelliteResourceLanguages' like this

...
<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <SatelliteResourceLanguages>ru;en-US</SatelliteResourceLanguages>
</PropertyGroup>
...

For my project I now have default en-US locale and additional 'ru' locale. You can select another locales with devider ';' between them.

2nd solution found here https://github.com/dotnet/sdk/issues/774

Solution 6 - C#

I had the same problem (similar answer here) but none of the other answers worked for me, so instead what I did was add the following lines to the end of my Main "csproj":

<ItemGroup>
    <FluentValidationExcludedCultures Include="be;cs;cs-CZ;da;de;es;fa;fi;fr;ja;it;ko;mk;nl;pl;pt;ru;sv;tr;uk;zh-CN;zh-CHS;zh-CHT">
        <InProject>false</InProject>
    </FluentValidationExcludedCultures> 
</ItemGroup>

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

This will effectively remove the files after they are generated, not as good as not creating them in the first place, but it works for me.

Solution 7 - C#

Answer no longer relevant

Apply the System.Resources.NeutralResourcesLanguageAttribute attribute at the assembly scope, like so:

[assembly: System.Resources.NeutralResourcesLanguageAttribute("en")]

(A good place for this would be the AssemblyInfo.cs file in the properties section of the project)

Solution 8 - C#

Fwiw, I was able to dump them from my build that used system.windows.interactivity.dll by modifying my csproj:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Import Project="$(   **<CHOPPED**>... />
  <PropertyGroup>

 <!--added this line for system.windows.interactivity.dll to dump the localized dll's-->
    <SupportedCultures>en-US</SupportedCultures>

Solution 9 - C#

For .net 4.6.1 in VS 2019 ... Using NuGet manager for solution, I just clicked Remove Dependencies under Uninstall Options. That seemed to work for me.

Solution 10 - C#

None of the given solutions worked for me. But the accepted answer - though poorly rated - did put me on the right track.

The content of each of my generated culture folders looked like this:

enter image description here

This lead me the the conclusion that the Nuget package that created these files was not the often mentioned Microsoft.VisualStudio.Web.CodeGeneration.Design package but one of the XUnit and Test packages that I had recently installed. By trial and error I finally found the culprit and the solution for me:

I added ExcludeAssets="All" to the Microsoft.NET.Test.Sdk package in .csproj like so...

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" ExcludeAssets="All" />

...and the culture folders disappeared.

So my recommendation to solve the generic problem is:

  • Have a look into the generated culture folders.
  • From the names of the files in these folders try to determine, which Nuget package(s) might be responsible for the generation.
  • Add ExcludeAssets="All" to the corresponding <PackageReference> in your .csproj file.
  • Keep doing this with more PackageReferences until the culture folders disappear when building.

Disclaimer:
I am still on VS 2017 and Core 2.2, which might be the reason why the generic solution with SatelliteResourceLanguages did not work for me.

Solution 11 - C#

Here is my horrid workaround in the csproj file. I wish the SatelliteResourceLanguages solution worked. My projects have many references, and I'm not sure which causes the problem now, nor do I know which new ones will cause the problem in the future. So this heavy-handed solution:

<PostBuildEvent>
		rd /s /q "$(TargetDir)de\" 2&gt;nul
		rd /s /q "$(TargetDir)cs\" 2&gt;nul
		rd /s /q "$(TargetDir)es\" 2&gt;nul
		rd /s /q "$(TargetDir)fr\" 2&gt;nul
		rd /s /q "$(TargetDir)it\" 2&gt;nul
		rd /s /q "$(TargetDir)ja\" 2&gt;nul
		rd /s /q "$(TargetDir)ko\" 2&gt;nul
		rd /s /q "$(TargetDir)pl\"&gt;2&gt;nul
		rd /s /q "$(TargetDir)pt-BR\" 2&gt;nul
		rd /s /q "$(TargetDir)ru\" 2&gt;nul
		rd /s /q "$(TargetDir)tr\" 2&gt;nul
		rd /s /q "$(TargetDir)zh-Hans\" 2&gt;nul
		rd /s /q "$(TargetDir)zh-Hant\" 2&gt;nul
	</PostBuildEvent>

Solution 12 - C#

Just in Solution Explorer Click on Items That Changed Properties and in Properties Tab Change Copy Local to False.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexander Forbes-ReedView Question on Stackoverflow
Solution 1 - C#al.kovalView Answer on Stackoverflow
Solution 2 - C#Wojciech KulikView Answer on Stackoverflow
Solution 3 - C#DiggerView Answer on Stackoverflow
Solution 4 - C#Jonatas W. GonçalvesView Answer on Stackoverflow
Solution 5 - C#Ivan KonstantinovView Answer on Stackoverflow
Solution 6 - C#David RogersView Answer on Stackoverflow
Solution 7 - C#Eyal PerryView Answer on Stackoverflow
Solution 8 - C#dethSwatchView Answer on Stackoverflow
Solution 9 - C#GapsterView Answer on Stackoverflow
Solution 10 - C#JpsyView Answer on Stackoverflow
Solution 11 - C#Daniel WilliamsView Answer on Stackoverflow
Solution 12 - C#ayubView Answer on Stackoverflow