38

I publish my ASP.Net Core 3.1 Server like this:

dotnet publish --configuration Release --runtime win7-x64 -p:PublishTrimmed=true --output c:\MyServer

What I get in c:\MyServer is a lot of international language directories: cs, de, es, fr, zh-hans etc

How can I publish with only the English version ?

I tried using ExcludeFoldersFromDeployment in my 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>

But that didn't help

Any help ?

kofifus
  • 17,260
  • 17
  • 99
  • 173
  • Does this answer your question? [.net core build produces localization folders](https://stackoverflow.com/questions/48424796/net-core-build-produces-localization-folders) – Mehdi Dehghani May 20 '23 at 13:24

2 Answers2

72

Edit your .csproj and add the following line to a PropertyGroup:

<SatelliteResourceLanguages>en</SatelliteResourceLanguages>

It should publish only the selected language resource folder.

RenanStr
  • 1,208
  • 1
  • 13
  • 15
  • 1
    Refer MSBuild properties - https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#satelliteresourcelanguages – shr Jul 05 '22 at 06:10
19

You get a lot of language folders containing CodeAnalysis.dll files in your published output if you have a project reference to Microsoft.VisualStudio.Web.CodeGeneration.Design, which is needed for scaffolding controllers. If that is true for your project, change the package reference in your .csproj file to include ExcludeAssets="All":

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

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

Ryan
  • 19,118
  • 10
  • 37
  • 53