Handling a potential race condition when writing global.json during migration.

This commit is contained in:
Livar Cunha 2017-01-26 12:40:29 -08:00
parent 537d78d2a6
commit 40c0c41cde

View file

@ -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)