'.net core build produces localization folders

I have a web asp.net solution that is using .net core 2.0. I am building it using the command:

dotnet publish MySolution.sln --configuration release --output d:\test_output

But when I check the output folder, I'm seeing a lot of localization folders, as you can see in the image bellow:

output content

Is there a way to publish the code without generating these folders?



Solution 1:[1]

On the .csproj file, you look for "Microsoft.VisualStudio.Web.CodeGeneration.Design" Package reference and add the property ExcludeAssets="All"

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

Here is the reference: Disable Dll Culture Folders on Compile

Solution 2:[2]

For the projects using ASP.NET Core 3.1, add this line to your *.csproj file:

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

The source of the answer in this post: Disable Dll Culture Folders on Compile.

Solution 3:[3]

The solution provided by @Igor.K worked for my API project, but for the ASP.NET Core MVC website in my solution, I had to make a minor change.

Try adding the line below to your .csproj file.

<PropertyGroup>   
    <ResourceLanguages>en</ResourceLanguages>
</PropertyGroup>

You can edit this file by right-clicking your project and selecting "Unload Project". Then, when you right-click again you will be able to edit the .csproj file. Make sure you reload the project when you're finished though.

So, if SatelliteResourceLanguages doesn't solve your problem, ResourceLanguages might do the trick.

Solution 4:[4]

Neither the SateliteResourceLangauges nor the ResourceLangauges solutions worked for me. In my case the files were being generated by the following nuget:

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

Affixing ExcludeAssets="All" to it as shown above resolved the issue.

Solution 5:[5]

[in net 5.0] All above solutions didn't work for me. Out of despair I added:

<PropertyGroup>   
    <SatelliteResourceLanguages>en-US;en</SatelliteResourceLanguages>
</PropertyGroup>

and it worked, absolutely no idea why

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lugube
Solution 2 Jeremy Caney
Solution 3 Scott Ridings
Solution 4 Eternal21
Solution 5 Felix