I have a pipeline building my C# application using Visual Studio 2019. Occasionally when building the solution, I get the following error.
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\al.exe /culture:da /out:obj\Release\da\MyApp.resources.dll /platform:AnyCPU /template:obj\Release\MyApp.exe /embed:obj\Release\MyApp.Properties.Resources.da.resources
##[error]CVTRES(0,0): Error CVT1108: cannot open C:\Users\WP2BUI~1\AppData\Local\Temp\RES161C.tmp for writing
The filename is always different (but it's always RESxxxx.tmp) and if I look on the server in the specified directory, there are a large number of these RES....tmp files, however the ones reported by this error message all appear to have a size of 0 bytes.
An internet search for the error message turns up multiple hits but in each case, it amounts to ensuring the build agent has write privileges to that directory. I don't feel like this is the answer in this case, as I've checked and the user does seem to have write privileges, and I would imagine if this was the problem it would fail every time.
Two other things I should point out.
There are many developers using this pipeline - it's a Continuous Integration pipeline used for pull requests.
When I build the application on my own machine and monitor the same dir, the RES....tmp file appears briefly and disappears, which makes me think VS should be deleting it after use. However, on the build server, there are hundreds of these files left over from a few months' worth of builds.
Edit
This error appears below the above. Not sure if it's caused by the above error or is the cause of it - but in case it matters:
CVTRES : fatal error CVT1108: cannot open C:\Users\WP2BUI~1\AppData\Local\Temp\RES161C.tmp for writing [c:\agent_work\56\s\src\MyApp\MyApp.csproj]
##[error]ALINK(0,0): Error AL1019: Metadata failure while creating assembly -- The specified image file did not contain a resource section.
Another Edit
It is always al.exe
which fails with the above error, and always on resources files. The application has 12 different languages, and al.exe
runs for the resources on each one. The one on which it fails seems random.
According to our discussion in the comments, you noticed an unusual RES*.tmp file behavior with al.exe, and are considering if msbuild
could be told to space out the calls to al.exe somehow.
So, I suggest you add -maxcpucount:1
to the msbuild
command to stop MSBuild from running in parallel. It looks like this has done the trick after monitoring it for a few days.