Merge pull request #3794 from freefair/rel/1.0.0

Fixed bug in build process with ReadOnly file flag
This commit is contained in:
Eric Erhardt 2016-07-11 09:25:21 -05:00 committed by GitHub
commit fa59167974

View file

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -27,7 +28,9 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
foreach (var asset in assets) foreach (var asset in assets)
{ {
File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)), overwrite: true); var file = Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath));
File.Copy(asset.ResolvedPath, file, overwrite: true);
RemoveFileAttribute(file, FileAttributes.ReadOnly);
} }
} }
@ -44,6 +47,19 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
var transformedFile = asset.GetTransformedFile(tempLocation); var transformedFile = asset.GetTransformedFile(tempLocation);
File.Copy(transformedFile, targetName, overwrite: true); File.Copy(transformedFile, targetName, overwrite: true);
RemoveFileAttribute(targetName, FileAttributes.ReadOnly);
}
}
private static void RemoveFileAttribute(String file, FileAttributes attribute)
{
if (File.Exists(file))
{
var fileAttributes = File.GetAttributes(file);
if ((fileAttributes & attribute) == attribute)
{
File.SetAttributes(file, fileAttributes & ~attribute);
}
} }
} }