Skip to content

Microsoft.Build.CopyOnWrite sometimes errors on build hosts #546

@cg110

Description

@cg110

Hi,

We've added CopyOnWrite to our builds, but every so often our build servers get an exception while trying to initialize the task, which I believe is some kind of volume has been removed/isn't accessible.

  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061: The "Copy" task could not be instantiated from "C:\Users\svc_build\.nuget\packages\microsoft.build.copyonwrite\1.0.302\build\netstandard2.0\Microsoft.Build.CopyOnWrite.dll".
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061: System.TypeInitializationException: The type initializer for 'Microsoft.Build.Tasks.Copy' threw an exception.
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:  ---> System.IO.FileNotFoundException: Failed retrieving volume information for \\?\Volume{105aac29-84e5-4492-934a-0d99cbe7d212}\\ with winerror 2
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.CopyOnWrite.Windows.NativeMethods.ThrowSpecificIoException(Int32 lastErr, String message) in D:\CoW\lib\Windows\NativeMethods.cs:line 30
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.CopyOnWrite.Windows.VolumeInfoCache.GetVolumeInfo(VolumePaths volumePaths) in D:\CoW\lib\Windows\VolumeInfoCache.cs:line 141
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.CopyOnWrite.Windows.VolumeInfoCache.BuildFromCurrentFilesystem() in D:\CoW\lib\Windows\VolumeInfoCache.cs:line 36
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.CopyOnWrite.Windows.WindowsCopyOnWriteFilesystem..ctor() in D:\CoW\lib\Windows\WindowsCopyOnWriteFilesystem.cs:line 24
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.CopyOnWrite.CopyOnWriteFilesystemFactory.Create() in D:\CoW\lib\CopyOnWriteFilesystemFactory.cs:line 48
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at System.Lazy`1.CreateValue()
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.CopyOnWrite.CopyOnWriteFilesystemFactory.GetInstance() in D:\CoW\lib\CopyOnWriteFilesystemFactory.cs:line 22
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.Build.Tasks.Copy..cctor()
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    --- End of inner exception stack trace ---
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at Microsoft.Build.Tasks.Copy..ctor()
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4061:    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
  dotnet\sdk\8.0.203\Microsoft.Common.CurrentVersion.targets(4967,5): error MSB4060: The "Copy" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.

I'm not sure if there's an error case that needs better handling so that the code assumes it shouldn't do COW on a volume it can't find. (We may simply disable CoW for our windows build servers, as they're not using ReFS so don't benefit from the nuget anyway).

Thanks,
Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions