![]() |
VOOZH | about |
dotnet add package CopyOnWrite --version 0.5.0
NuGet\Install-Package CopyOnWrite -Version 0.5.0
<PackageReference Include="CopyOnWrite" Version="0.5.0" />
<PackageVersion Include="CopyOnWrite" Version="0.5.0" />Directory.Packages.props
<PackageReference Include="CopyOnWrite" />Project file
paket add CopyOnWrite --version 0.5.0
#r "nuget: CopyOnWrite, 0.5.0"
#:package CopyOnWrite@0.5.0
#addin nuget:?package=CopyOnWrite&version=0.5.0Install as a Cake Addin
#tool nuget:?package=CopyOnWrite&version=0.5.0Install as a Cake Tool
Note: This library is being superseded by CoW support now built into the Windows 11 24H2 release, as well as Windows Server 2025. Use of CoW is automatic for Dev Drive and ReFS volumes starting in these OS versions. See related notes in our blog entry and linked earlier articles. We will continue to accept bug fixes for this library, and updates for the related Microsoft.Build.CopyOnWrite and Microsoft.Build.Artifacts SDKs to use newer versions.
The CopyOnWrite library provides a .NET layer on top of Windows OS-specific logic that provides copy-on-write linking for files (a.k.a. CoW, file cloning, or reflinking). CoW linking provides the ability to copy a file without actually copying the original file's bytes from one disk location to another. The filesystem is in charge of ensuring that if the original file is modified or deleted, the CoW linked files remain unmodified by lazily copying the original file's bytes into each link. Unlike symlinks or hardlinks, writes to CoW links do not write through to the original file, as the filesystem breaks the link and copies in a lazy fashion. This enables scenarios like file caches where a single copy of a file held in a content-addressable or other store is safely linked to many locations in a filesystem with low I/O overhead.
*NOTE: Only Windows functionality is implemented. On Linux and Mac using File.Copy is sufficient as it automatically uses CoW for Linux (starting in .NET 7, and as long as a CoW compatible filesystem like btrfs is in use) and Mac (.NET 8). A similar PR for Windows did not make it into .NET, however there is work underway to integrate CoW into the Windows API in a possible future release.
This library allows a .NET developer to:
Discovery is important, as different operating systems and different filesystems available for those operating systems provide varying levels of CoW link support:
When using this library you may need to create a wrapper that copies the file if CoW is not available.
using Microsoft.CopyOnWrite;
ICopyOnWriteFilesystem cow = CopyOnWriteFilesystemFactory.GetInstance();
bool canCloneInCurrentDirectory = cow.CopyOnWriteLinkSupportedInDirectoryTree(Environment.CurrentDirectory);
if (canCloneInCurrentDirectory)
{
cow.CloneFile(existingFile, cowLinkFilePath);
}
File clones on Windows do not actually allocate space on-drive for the clone. This has a good and a possibly bad implication:
CloneFile as the implementation did not use overlapped I/O anyway. CoW support is releasing in the Server 2025 and Win11 24H2 wave, built into the CopyFile API suite and on by default for Dev Drive and ReFS, so overlapped I/O in this library will never be implemented. Resolves https://github.com/microsoft/CopyOnWrite/issues/50CopyOnWriteLinkSupported... methods to avoid the need for checking for Windows OS before calling.CloneFlags.NoSerializedCloning and the useCrossProcessLocksWhereApplicable flag to CopyOnWriteFilesystemFactory. The related concurrency bug in Windows was fixed in recent patches and retested on Windows 11.CloneFlags.DestinationMustMatchSourceSparseness was used (https://github.com/microsoft/CopyOnWrite/issues/17)CloneFlags.NoSparseFileCheck with DestinationMustMatchSourceSparseness,
hence minor version increase.Microsoft.Build.Artifacts MSBuild SDK plugin to speed up file copies for artifact staging.This project welcomes contributions and suggestions. See CONTRIBUTING.md.
If you have a local ReFS drive volume on which to run ReFS related tests, set the following user or system level environment variable:
CoW_Test_ReFS_Drive=D:\
(You may need to exit and restart VS, VSCode, or consoles after setting this.) When this env var is not available, unit tests create and mount a local ReFS VHD for testing and must be run elevated (as admin), e.g. by opening Visual Studio as an admin before opening the solution.
See .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on CopyOnWrite:
| Package | Downloads |
|---|---|
|
Microsoft.MSBuildCache.Common
A project cache plugin for MSBuild |
Showing the top 1 popular GitHub repositories that depend on CopyOnWrite:
| Repository | Stars |
|---|---|
|
microsoft/MSBuildSdks
MSBuild project SDKs
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.0 | 2,195 | 12/2/2024 |
| 0.4.2 | 517 | 11/4/2024 |
| 0.4.1 | 323 | 10/28/2024 |
| 0.4.0 | 270 | 10/14/2024 |
| 0.3.12 | 346 | 10/14/2024 |
| 0.3.11 | 409 | 9/24/2024 |
| 0.3.10 | 303 | 9/23/2024 |
| 0.3.9 | 293 | 9/23/2024 |
| 0.3.8 | 31,282 | 3/25/2024 |
| 0.3.7 | 8,339 | 9/11/2023 |
| 0.3.6 | 8,200 | 7/17/2023 |
| 0.3.5 | 324 | 7/13/2023 |
| 0.3.4 | 402 | 7/12/2023 |
| 0.3.3 | 366 | 7/11/2023 |
| 0.3.2 | 9,304 | 2/9/2023 |
| 0.3.1 | 518 | 2/8/2023 |
| 0.3.0 | 1,275 | 1/30/2023 |
| 0.2.2 | 606 | 1/27/2023 |
| 0.2.1 | 6,113 | 9/27/2022 |
| 0.2.0 | 687 | 9/15/2022 |