Azure DevOps build pipeline corrupts unicode filenames

We have a legacy .NET MVC 5 project targeting .NET Framework 4.7.2. We’ve created a build pipeline in Azure Devops using Classic interface (we will switch to YAML later), and we have a hosted agent pool with a single hosted agent. The pipeline specifies to use “windows-latest”.

Our problem is that the App_Data folder contains a couple of files with non ascii characters, and in the built image these file names are corrupted. As an example. the original file name PuBavtalRegistervård.pdf ends up as PuBavtalRegisterv├Ñrd.pdf. If you take the latter as an OEM850 encoded string and interpret it as UTF-8 then you get the original file name. So it would appear that somewhere along the way the file names that are originally in unicode get correctly encoded as UTF-8 but then that string is interpreted as if it were OEM850 and published as such into the built image.

This problem does not occur when we build from within Visual Studio (2022). In VS, both regular build (F5) and publish (to file system) work just fine.

The pipeline uses this MSBuild command line:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"

Is there any way we can get it to handle these file names correctly?

Leave a Comment