54

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?

Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
  • Your question predates it, but the same question, with an answer, is here: https://stackoverflow.com/questions/48893450/visual-studio-2017-localization-publish-settings – Daz Jul 04 '18 at 14:20

5 Answers5

66

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.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Igor.K
  • 661
  • 5
  • 4
  • 4
    Remark: the property should be added inside the existing `` node that contains ``, instead of adding a new ``, which I tried first and noticed does not work. – Veverke Jun 14 '21 at 16:45
8

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.

Scott Ridings
  • 744
  • 1
  • 8
  • 14
8

[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

Felix
  • 109
  • 2
  • 4
3

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

Lugube
  • 80
  • 6
2

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.

Eternal21
  • 4,190
  • 2
  • 48
  • 63