Skip to content

Commit c72a0e3

Browse files
Update CopyOnWrite readme, fixes (#420)
* Update README.md for CopyOnWrite * Sign output * Ensure CloneFile support called only once
1 parent 5e6e7bd commit c72a0e3

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Supports utility projects that do not compile an assembly.
2929

3030
Supports staging artifacts from build outputs.
3131

32+
### [Microsoft.Build.CopyOnWrite](src/CopyOnWrite)
33+
[![NuGet](https://img.shields.io/nuget/v/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)
34+
[![NuGet](https://img.shields.io/nuget/dt/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)
35+
36+
Enables Copy on Write for faster file copies.
37+
3238
## How can I use these SDKs?
3339

3440
When using an MSBuild Project SDK obtained via NuGet (such as the SDKs in this repo) a specific version **must** be specified.

src/CopyOnWrite/Copy.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ private bool TryCopyOnWrite(string source, string dest)
10001000
return true;
10011001
}
10021002

1003-
private static readonly ConcurrentDictionary<string, bool> _reFsDrives = new(StringComparer.OrdinalIgnoreCase);
1003+
private static readonly ConcurrentDictionary<string, Lazy<bool>> _reFsDrives = new(StringComparer.OrdinalIgnoreCase);
10041004

10051005
/// <summary>
10061006
/// Check for CopyOnWrite support. Result is cached by drive root.
@@ -1024,16 +1024,16 @@ private bool IsCopyOnWriteSupported(string source, string dest)
10241024
}
10251025

10261026
return _reFsDrives.GetOrAdd(
1027-
source,
1028-
(key) =>
1027+
sourceDrive,
1028+
(key) => new Lazy<bool>(() =>
10291029
{
10301030
var supportsCloneFile = _cow.CopyOnWriteLinkSupportedInDirectoryTree(key);
10311031
Log.LogMessage(MessageImportance.Low,
10321032
supportsCloneFile
1033-
? $"Drive {sourceDrive} has support for CloneFile. All copies will attempt to use CloneFile."
1034-
: $"Drive {sourceDrive} does not have support for CloneFile. File.Copy will be used.");
1033+
? $"Drive {key} has support for CloneFile. All copies will attempt to use CloneFile."
1034+
: $"Drive {key} does not have support for CloneFile. File.Copy will be used.");
10351035
return supportsCloneFile;
1036-
});
1036+
})).Value;
10371037
}
10381038
#endregion
10391039
}

src/CopyOnWrite/Microsoft.Build.CopyOnWrite.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
</None>
2020
<None Include=".editorconfig" />
2121
</ItemGroup>
22-
22+
<ItemGroup>
23+
<FilesToSign Include="$(TargetPath)" Authenticode="Microsoft400" StrongName="StrongName" />
24+
</ItemGroup>
2325
<ItemGroup>
2426
<PackageReference Include="CopyOnWrite" GeneratePathProperty="True" PrivateAssets="All" />
2527
<PackageReference Include="Microsoft.Build.Tasks.Core" PrivateAssets="all" ExcludeAssets="Runtime">

src/CopyOnWrite/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Microsoft.Build.CopyOnWrite
2+
[![NuGet](https://img.shields.io/nuget/v/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)
3+
[![NuGet](https://img.shields.io/nuget/dt/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)
24

35
The `Microsoft.Build.CopyOnWrite` MSBuild SDK overrides the native MSBuild Copy task to add support for ReFS CloneFile (Copy on Write). It is designed to be as backwards compatible as possible and should directly replace all usages of Copy in MSBuild.
46

0 commit comments

Comments
 (0)