Site icon Ryadel

ASP.NET Core Publish - Suppress Localization Folders

How to fix the "No executable found matching command dotnet-ef" error in Visual Studio with .NET Core

In this post, we will address a typical issue affecting most ASP.NET Core projects during their publishing phase.

As most seasoned developers know, when we publish an ASP.NET Core app (via command line, using the dotnet publish command, or through Visual Studio), the framework generates some localization and code coverage satellite assemblies, grouping them into several language-related folder.

As a consequence of such behavior, at the end of the publishing process, we are left with the following outcome:

ASP.NET Core Publish - Suppress Localization Folders

Although these folders are completely harmless, if we don't support these languages we might reasonably want to prevent them from being generated.

To do that, open the project file (the one ending with the .csproj prefix) and add the <SatelliteResourceLanguages> element to the first PropertyGroup (the one containing the TargetFramework element) in the following way:

The <SatelliteResourceLanguages> element allows us to specify which languages you want to preserve satellite resource assemblies for during build and publish: in the above scenario, we only want to support English (en) and Italian (it) languages, therefore we added these two.

For additional info regarding the SatelliteResourceLanguages element, check out this official reference.

If this setting doesn't do the trick alone, you might have to perform another change to the project file.

Locate the following element:

And add the ExcludeAssets="All" attribute to it, in the following way:

This should do the trick.

IMPORTANT: the above samples are taken from .NET 8 (v8.0.0) app: if you happen to use a different framework version, the above elements will have different reference numbers.

Conclusion

That's it, at least for now: we hope that this small guide will help other ASP.NET Core developers get rid of these useless localization folders when deploying their apps to the web.

 

 

Exit mobile version