ASP.Net Core 排除除英语以外的已发布语言目录

kof*_*fus 10 asp.net-core asp.net-core-3.0 asp.net-core-3.1

我像这样发布我的 ASP.Net Core 3.1 服务器:

dotnet publish --configuration Release --runtime win7-x64 -p:PublishTrimmed=true --output c:\MyServer
Run Code Online (Sandbox Code Playgroud)

我在 c:\MyServer 中得到的是很多国际语言目录:cs、de、es、fr、zh-hans 等

如何只发布英文版?

我尝试ExcludeFoldersFromDeployment在我的 csproj 中使用:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
    <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>    
    <AspNetCoreHostingModel>inprocess</AspNetCoreHostingModel>
    <Nullable>enable</Nullable>
    <ExcludeFoldersFromDeployment>cs;de;es;fr;he;hi;it;ja;ko;nl;pl;pt;ru;tr-TR;zh-Hans;zh-Hant</ExcludeFoldersFromDeployment>
  </PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

但这没有帮助

有什么帮助吗?

Ren*_*Str 13

编辑您的 .csproj 并将以下行添加到 PropertyGroup:

<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
Run Code Online (Sandbox Code Playgroud)

它应该只发布选定的语言资源文件夹。


Rya*_*yan 10

CodeAnalysis.dll如果您有对 的项目引用Microsoft.VisualStudio.Web.CodeGeneration.Design,您会在发布的输出中获得许多包含文件的语言文件夹,这是脚手架控制器所需要的。如果您的项目确实如此,请更改 .csproj 文件中的包引用以包含 ExcludeAssets="All":

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" ExcludeAssets="All"/>
Run Code Online (Sandbox Code Playgroud)

参考https://forums.asp.net/t/2160546.aspx?how+to+get+rid+of+fr+it+ja+etc+folders+in+net+core+3+0+