We have periodically seen this failure in our own build:
src\Tasks\system.design\system.design.txt(0,0): error MSB3103: Invalid Resx file. The process cannot access the file 'D:\a\1\s\src\Tasks\system.design\system.design.txt' because it is being used by another process.
Today I looked into it. I suspect this flow of things:
|
private void ReadTextResources(ReaderInfo reader, String fileName) |
|
{ |
|
// Check for byte order marks in the beginning of the input file, but |
|
// default to UTF-8. |
|
using (LineNumberStreamReader sr = new LineNumberStreamReader(fileName, new UTF8Encoding(true), true)) |
|
internal LineNumberStreamReader(String fileName, Encoding encoding, bool detectEncoding) |
|
: base(File.Open(fileName, FileMode.Open, FileAccess.Read), encoding, detectEncoding) |
File.Open does not specify FileShare.Read, which defaults to "no sharing". So if this is run on the same file in parallel (for instance, in our Tasks project which is multitargeted), there's a possibility that the second attempt to read the file fails because the first one is still holding a lock.
We have periodically seen this failure in our own build:
Today I looked into it. I suspect this flow of things:
msbuild/src/Tasks/GenerateResource.cs
Lines 3561 to 3565 in 797fd82
msbuild/src/Tasks/GenerateResource.cs
Lines 3876 to 3877 in 797fd82
File.Opendoes not specifyFileShare.Read, which defaults to "no sharing". So if this is run on the same file in parallel (for instance, in our Tasks project which is multitargeted), there's a possibility that the second attempt to read the file fails because the first one is still holding a lock.