Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cg110 opened this issue Mar 25, 2024 · 5 comments
Closed

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

cg110 opened this issue Mar 25, 2024 · 5 comments

Comments

@cg110
Copy link

cg110 commented Mar 25, 2024

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

@cg110 cg110 changed the title Msbuild copy on write sometimes errors on build hosts Microsoft.Build.CopyOnWrite sometimes errors on build hosts Mar 25, 2024
@erikmav
Copy link
Collaborator

erikmav commented Mar 25, 2024

Thanks for the bug report. Agreed this is a case to fix in the CoW library. I'll get started on a fix ASAP.

@erikmav
Copy link
Collaborator

erikmav commented Mar 25, 2024

The following SDK package versions have been released to nuget.org with a fix:

  • Microsoft.Build.CopyOnWrite 1.0.315
  • Microsoft.Build.Artifacts 6.1.30

Please give them a try.

@cg110
Copy link
Author

cg110 commented Mar 26, 2024

Thanks for the quick response, I'll update (but given the rarity it's likely a fix that'll be hard to prove is fixed other than it not occurring)

@erikmav
Copy link
Collaborator

erikmav commented Apr 16, 2024

Didn't hear back after 3 weeks, closing this as completed. Please reopen if you hit the problem again.

@erikmav erikmav closed this as completed Apr 16, 2024
@cg110
Copy link
Author

cg110 commented Apr 20, 2024

Hi,

I'm not aware of any of our builds having the problem since updating to the fixed version.

So very much seems fixed.

Thanks
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants