Unable to copy file, Could not find a part of the path

Viewed 647

My site has localization (multi-language)

I use ASP.NET resource files for each culture, such as:

  • Controllers.UserProfileController.en-ca.resx
  • Controllers.UserProfileController.es-us.resx
  • Controllers.UserProfileController.pt-br.resx

and etc..

I also have this line in Startup.cs

services.AddLocalization(options => options.ResourcesPath = "ResourcesDirectoryFolderName");

When I build and publish the site, in bin folder it is creating a folder for each culture, such as:

  • C:\User\Documents\SchoolApp\School.API\bin\Release\netcoreapp3.1\en-ca
  • C:\User\Documents\SchoolApp\School.API\bin\Release\netcoreapp3.1\es-us
  • C:\User\Documents\SchoolApp\School.API\bin\Release\netcoreapp3.1\pt-BR

In each folder, I have some DLL files. Which is fine.

Problem comes when I use Azure pipelines to compile/build/publish the app (CI/CD). It is throwing error:

##[error] /usr/share/dotnet/sdk/3.1.401/Microsoft.Common.CurrentVersion.targets(4364,5): Error MSB3021: Unable to copy file "/home/vsts/work/1/s/School.Services/bin/Release/netcoreapp3.1/pt-br/School.Services.resources.dll" to "bin/Release/netcoreapp3.1/pt-br/School.Services.resources.dll". Could not find a part of the path '/home/vsts/work/1/s/School.API/bin/Release/netcoreapp3.1/pt-br/School.Services.resources.dll'.

All if fine on local. I am not getting error when I build or publish on my localhost. This is happening on Azure Pipelines.

This is happening only for pt-br. For other cultures I am not getting an error. Before adding pt-br I was not getting any error.

Notice that pt-br (lowercase) is used in resource file name, but when folder generated inside bin folder it is names as pt-BR (uppercase BR). Could this case sensitivity be the problem? Maybe when copying the files Azure Pipelines is looking for folder name pt-br but actually the system generated folder name pt-BR? Why other cultures are not encountering this problem, but only pt-br?

I followed instuctions at here to build my multi language app: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1

How can I fix it?

1 Answers

Could this case sensitivity be the problem?

The copy-related commands in Linux are case-sensitive. (You're running the pipeline in Ubuntu machine). So I agree that case sensitivity could be the problem.

It looks like your School.API project depends on School.Services project, so you need to check these two projects for why the folder is generated as pt-BR.

You should check project files and the resource files of these two projects. Also, as a quick workaround I suggest you can rename your resource file to Controllers.UserProfileController.pt-BR.resx. See Supported Culture Codes ,the pt-BR is the original format that represents Portuguese (Brazil).

Related