Skip to content

Commit

Permalink
Update CopyOnWrite readme, fixes (#420)
Browse files Browse the repository at this point in the history
* Update README.md for CopyOnWrite

* Sign output

* Ensure CloneFile support called only once
  • Loading branch information
AndyGerlicher authored Feb 9, 2023
1 parent 5e6e7bd commit c72a0e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Supports utility projects that do not compile an assembly.

Supports staging artifacts from build outputs.

### [Microsoft.Build.CopyOnWrite](src/CopyOnWrite)
[![NuGet](https://img.shields.io/nuget/v/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)
[![NuGet](https://img.shields.io/nuget/dt/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)

Enables Copy on Write for faster file copies.

## How can I use these SDKs?

When using an MSBuild Project SDK obtained via NuGet (such as the SDKs in this repo) a specific version **must** be specified.
Expand Down
12 changes: 6 additions & 6 deletions src/CopyOnWrite/Copy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ private bool TryCopyOnWrite(string source, string dest)
return true;
}

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

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

return _reFsDrives.GetOrAdd(
source,
(key) =>
sourceDrive,
(key) => new Lazy<bool>(() =>
{
var supportsCloneFile = _cow.CopyOnWriteLinkSupportedInDirectoryTree(key);
Log.LogMessage(MessageImportance.Low,
supportsCloneFile
? $"Drive {sourceDrive} has support for CloneFile. All copies will attempt to use CloneFile."
: $"Drive {sourceDrive} does not have support for CloneFile. File.Copy will be used.");
? $"Drive {key} has support for CloneFile. All copies will attempt to use CloneFile."
: $"Drive {key} does not have support for CloneFile. File.Copy will be used.");
return supportsCloneFile;
});
})).Value;
}
#endregion
}
Expand Down
4 changes: 3 additions & 1 deletion src/CopyOnWrite/Microsoft.Build.CopyOnWrite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
</None>
<None Include=".editorconfig" />
</ItemGroup>

<ItemGroup>
<FilesToSign Include="$(TargetPath)" Authenticode="Microsoft400" StrongName="StrongName" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CopyOnWrite" GeneratePathProperty="True" PrivateAssets="All" />
<PackageReference Include="Microsoft.Build.Tasks.Core" PrivateAssets="all" ExcludeAssets="Runtime">
Expand Down
2 changes: 2 additions & 0 deletions src/CopyOnWrite/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Microsoft.Build.CopyOnWrite
[![NuGet](https://img.shields.io/nuget/v/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)
[![NuGet](https://img.shields.io/nuget/dt/Microsoft.Build.CopyOnWrite.svg)](https://www.nuget.org/packages/Microsoft.Build.CopyOnWrite)

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.

Expand Down

0 comments on commit c72a0e3

Please sign in to comment.