Handling a potential race condition when writing global.json during migration.
This commit is contained in:
parent
537d78d2a6
commit
40c0c41cde
1 changed files with 8 additions and 1 deletions
|
@ -30,7 +30,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
if (!File.Exists(globalJson))
|
||||
{
|
||||
var file = new FileInfo(globalJson);
|
||||
File.WriteAllText(file.FullName, @"{}");
|
||||
try
|
||||
{
|
||||
File.WriteAllText(file.FullName, @"{}");
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
//this means there is someone else writing to the file already. So, just ignore it.
|
||||
}
|
||||
}
|
||||
|
||||
var testPj = new ProjectJsonBuilder(null)
|
||||
|
|
Loading…
Reference in a new issue