diff options
author | Aleksey Kliger <alklig@microsoft.com> | 2018-10-02 01:39:42 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-10-03 10:46:03 +0300 |
commit | 7af03ce00326bac912d098dd54a0149c4fec43cb (patch) | |
tree | 7e15740a5c4f057b17b8c5d3cffd8bfd3c2a24ce | |
parent | 5648356e4eabb55a39461e4d5d9a9bfcf42b2497 (diff) |
[linker] OutputStep should not create readonly filesmono-2018-08
File.Copy will preserve permissions and create readonly files.
We should create writeable files instead.
See https://github.com/mono/mono/issues/10743
-rw-r--r-- | linker/Linker.Steps/OutputStep.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/linker/Linker.Steps/OutputStep.cs b/linker/Linker.Steps/OutputStep.cs index 61852b7c1..4969ef81e 100644 --- a/linker/Linker.Steps/OutputStep.cs +++ b/linker/Linker.Steps/OutputStep.cs @@ -213,18 +213,27 @@ namespace Mono.Linker.Steps { if (source == target) return; - File.Copy (source, target, true); + CopyFileAndRemoveReadOnly (source, target); if (!Context.LinkSymbols) return; var mdb = source + ".mdb"; if (File.Exists (mdb)) - File.Copy (mdb, target + ".mdb", true); + CopyFileAndRemoveReadOnly (mdb, target + ".mdb"); var pdb = Path.ChangeExtension (source, "pdb"); if (File.Exists (pdb)) - File.Copy (pdb, Path.ChangeExtension (target, "pdb"), true); + CopyFileAndRemoveReadOnly (pdb, Path.ChangeExtension (target, "pdb")); + } + + static void CopyFileAndRemoveReadOnly (string src, string dest) { + File.Copy (src, dest, true); + + FileAttributes attrs = File.GetAttributes (dest); + + if ((attrs & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) + File.SetAttributes (dest, attrs & ~FileAttributes.ReadOnly); } protected virtual string GetAssemblyFileName (AssemblyDefinition assembly, string directory) |