Multitargeted generate AngleSharp twice, so minimise the chance of either seeing the other in an incomplete state during build
This commit is contained in:
parent
b529f2b913
commit
535b601d55
|
|
@ -45,8 +45,24 @@ namespace AngleSharpBuilder
|
||||||
RemoveStrongName(moduleDefinition);
|
RemoveStrongName(moduleDefinition);
|
||||||
SetAssemblyName(moduleDefinition, "Microsoft.AspNetCore.Blazor.AngleSharp");
|
SetAssemblyName(moduleDefinition, "Microsoft.AspNetCore.Blazor.AngleSharp");
|
||||||
|
|
||||||
moduleDefinition.Write(
|
// Try to minimize the chance of a parallel build reading the assembly in an
|
||||||
Path.Combine(outputDir, $"{moduleDefinition.Name}.dll"));
|
// incomplete state by writing it to a temp location then moving the result.
|
||||||
|
// There's still a race condition here, but hopefully this is enough to stop
|
||||||
|
// it from surfacing in practice.
|
||||||
|
|
||||||
|
var tempFilePath = Path.GetTempFileName();
|
||||||
|
moduleDefinition.Write(tempFilePath);
|
||||||
|
|
||||||
|
var outputPath = Path.Combine(outputDir, $"{moduleDefinition.Name}.dll");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(outputPath);
|
||||||
|
File.Move(tempFilePath, outputPath);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
File.Delete(tempFilePath); // In case it didn't get moved above
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetAssemblyName(ModuleDefinition moduleDefinition, string name)
|
private static void SetAssemblyName(ModuleDefinition moduleDefinition, string name)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue