microsoft / MSBuildSdks

MSBuild project SDKs
MIT License
460 stars 82 forks source link

DOCS: Instructions for Microsoft.Build.CopyOnWrite do not adequately explain how to install it #552

Open simeyla opened 7 months ago

simeyla commented 7 months ago

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

That is the introduction to the CopyOnWrite package. However there are no actual instructions on how to use it. I was excited to find out this week about DevDrives and this is the last piece to get the full benefits. There is only a mention of Central Package Management, which personally I've never heard of.

Also it would be good to include information about the future update to Windows that will make this package redundant.

ugumba commented 6 months ago

The package works silently and automatically in a normal SDK-style project (without CPM), e.g.:

<ItemGroup>
   <PackageReference Include="Microsoft.Build.CopyOnWrite" Version="1.0.315" />
</ItemGroup>

I think you need it in all projects where you want the benefit, so I put it in Directory.Build.props.

You need a sizable solution to notice an obvious improvement, and I spotted the difference by comparing the amount of free space on my Dev Drive before and after. Since each file reference is equal to others, the difference does not show up in "Folder properties - Size" or "Folder properties - Size on disk"! I'm sure there are ways to interrogate the CoW status on individual files (using fsutil or similar tools), but I haven't looked for this.

After a clean of my solution: 455 GB free After a full build of my solution without the package: 437 GB free After a full build of my solution with the package: 446 GB free

I also think build times improved somewhat, but I have no clear evidence for this.

erikmav commented 6 months ago

Took awhile but I posted a new blog entry that describes how to determine if a file is a CoW link (block clone). See https://devblogs.microsoft.com/engineering-at-microsoft/?p=910