Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SatelliteResourceLanguages to filter out resource files when publishing .NET Core API services

When publishing .NET Core API services, the output includes with localized resources (cs, de, es, fr, etc.)

Searching for a solution to prevent .NET Core from publishing these localized resource files, I came across this commit on Github to implement SatelliteResourceLanguages for that purpose.

But how can I implement it?

like image 386
user11081980 Avatar asked May 24 '19 14:05

user11081980


1 Answers

According to this answer, you should just add it to the project file:

<SatelliteResourceLanguages>en</SatelliteResourceLanguages>

Here's how you can use the above line in a project config:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <SatelliteResourceLanguages>en;de;pt</SatelliteResourceLanguages>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="FooBar" Version="2.0.1" />
  </ItemGroup>
</Project>

Note that I couldn't find SatelliteResourceLanguages documented officially anywhere as of today.

Also note that you need to have a recent version of the SDK, as this bug report mentions that a typo prevented this to work properly in prior releases.

like image 163
Abel Avatar answered Nov 19 '22 00:11

Abel