wpf 在编译时禁用 Dll 文化文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20342061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable Dll Culture Folders on Compile
提问by Alexander Forbes-Reed
I'm using 2 dlls (Microsoft.Expression.Interactions.dlland System.Windows.Interactivity.dll) that, when the parent application is compiled, create loads of culture folders:

我正在使用 2 个 dll(Microsoft.Expression.Interactions.dll和System.Windows.Interactivity.dll),在编译父应用程序时,它们会创建大量文化文件夹:

And inside each are 2 dlls (Microsoft.Expression.Interactions.resources.dlland 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.
每个内部都有 2 个 dll(Microsoft.Expression.Interactions.resources.dll和System.Windows.Interactivity.resources.dll)。我已经用谷歌搜索过,但找不到与如何阻止这种烦人的自动生成内容相关的任何内容。
采纳答案by Jonatas W. Gon?alves
I found a good answer for .NET Core 3
我为 .NET Core 3 找到了一个很好的答案
Just add ExcludeAssets="All" to the package reference.
只需将 ExcludeAssets="All" 添加到包引用中。
<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
这是微软社区原帖的链接:https: //forums.asp.net/post/6281458.aspx
回答by Wojciech Kulik
There are two workarounds for this issue:
此问题有两种解决方法:
- copy
System.Windows.Interactivity.dlland add a reference directly to this file - remove those folders from:
\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries
System.Windows.Interactivity.dll直接复制并添加对此文件的引用- 从以下位置删除这些文件夹:
\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries
Related links:
Original solution
Generated files by caliburn.micro in Release directory
回答by Digger
I use other solution. You can configure Post-build event for your project in Vistual Studio, wich will remove redundant folders:
我使用其他解决方案。您可以在 Visual Studio 中为您的项目配置构建后事件,这将删除冗余文件夹:
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.
此解决方案比从 sdk 文件夹中删除文件夹的侵入性小。
回答by al.koval
Faced the same problem. My project uses ASP.NET Core 3.1
面临同样的问题。我的项目使用 ASP.NET Core 3.1
Add this line to your *.csproj
将此行添加到您的 *.csproj
<PropertyGroup>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
回答by Ivan Konstantinov
I had the same issue in my project on .NET Core 3.1 using nuget package Microsoft.VisualStudio.Web.CodeGeneration.Design
我在使用 nuget 包 Microsoft.VisualStudio.Web.CodeGeneration.Design 在 .NET Core 3.1 上的项目中遇到了同样的问题
First of all DELETE folder 'bin' from your project directory.
首先从您的项目目录中删除文件夹“bin”。
Then you need to set option 'ExcludeAssets' for the package.
然后您需要为包设置选项“ExcludeAssets”。
In Visual Studio here:
在 Visual Studio 中:
Or another way is direct change in *.csproj file like this:
或者另一种方法是直接更改 *.csproj 文件,如下所示:
...
<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.
UPD:我找到了第二个解决方案 - 这是另一种让您选择所需语言环境文件夹的方法。但是如果你这样做 - 再次删除'bin'文件夹并将所选包的'ExcludeAssets'选项设置为默认值 - 空。
In *.csproj file add tag 'SatelliteResourceLanguages' like this
在 *.csproj 文件中添加标签 'SatelliteResourceLanguages' 像这样
...
<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.
对于我的项目,我现在有默认的 en-US 语言环境和附加的“ru”语言环境。您可以使用分隔符 ';' 选择其他语言环境 它们之间。
2nd solution found here https://github.com/dotnet/sdk/issues/774
在这里找到的第二个解决方案https://github.com/dotnet/sdk/issues/774
回答by Eyal Perry
Apply the System.Resources.NeutralResourcesLanguageAttributeattribute at the assembly scope, like so:
在程序集范围内应用System.Resources.NeutralResourcesLanguageAttribute属性,如下所示:
[assembly: System.Resources.NeutralResourcesLanguageAttribute("en")]
(A good place for this would be the AssemblyInfo.cs file in the properties section of the project)
(一个很好的地方是项目属性部分中的 AssemblyInfo.cs 文件)
回答by David Rogers
I had the same problem (similar answerhere) 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":
我遇到了同样的问题(这里有类似的答案),但其他答案都不适合我,所以我所做的是将以下几行添加到我的主要“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.
这将在文件生成后有效地删除它们,不如不首先创建它们,但它对我有用。
回答by dethSwatch
Fwiw, I was able to dump them from my build that used system.windows.interactivity.dll by modifying my csproj:
Fwiw,通过修改我的 csproj,我能够从使用 system.windows.interactivity.dll 的构建中转储它们:
<?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>
回答by Gapster
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.
对于 VS 2019 中的 .net 4.6.1 ...使用 NuGet 管理器解决方案,我只需单击卸载选项下的删除依赖项。这似乎对我有用。

