System.IO.IOException: The process cannot access the file because it is being used by another process
@brecht-yperman-uz đang làm issue này rồi.
Từ ngày 12/10/2026.
- #830 của @brecht-yperman-uz — đang mở
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- csharp
- Lĩnh vực
- build-system
Hướng nghiên cứu
Xem xét src/LibraryManager.Contracts/FileHelpers.cs xung quanh phương thức CopyFileAsync ở các dòng 142-160, đặc biệt là việc mở FileStream nguồn. Tái hiện kịch bản sao chép thư viện đồng thời được mô tả trong issue và xác minh rằng nhiều dự án có thể sao chép cùng một tệp đã được lưu trong bộ nhớ đệm mà không xảy ra IOException, đồng thời vẫn duy trì hành vi sao chép thông thường.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
We have a solution containing multiple projects that use Microsoft.Web.LibraryManager.Build for restoring JavaScipt libraries. Some of these projects reference the same library from the same provider. We have multiple build servers, and on our more recent, faster build server we noticed builds are regularly failing with error messages of the following kind:
C:\nuget\microsoft.web.librarymanager.build\3.0.71\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : Error during copying file System.IO.IOException: The process cannot access the file 'C:\Users\[username]\AppData\Local\.librarymanager\cache\jsdelivr\jquery\3.7.1\dist\jquery.min.js' because it is being used by another process.
C:\nuget\microsoft.web.librarymanager.build\3.0.71\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
C:\nuget\microsoft.web.librarymanager.build\3.0.71\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
C:\nuget\microsoft.web.librarymanager.build\3.0.71\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
C:\nuget\microsoft.web.librarymanager.build\3.0.71\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at Microsoft.Web.LibraryManager.Contracts.FileHelpers.<CopyFileAsync>d__4.MoveNext()
This is the method this exception occurs in:
https://github.com/aspnet/LibraryManager/blob/07b204fe119d2ab9cf51ce700a690fbb434417ca/src/LibraryManager.Contracts/FileHelpers.cs#L142-L160
The problematic line ist probably the following:
using FileStream sourceStream = File.Open(sourceFile, FileMode.Open, FileAccess.Read);
I would suggest changing it as follows:
using FileStream sourceStream = File.Open(sourceFile, FileMode.Open, FileAccess.Read, FileShare.Read);
This should allow multiple processes to access the same file at the same time.
While at it, a Task.Delay between the first and second iteration might also help to reduce the flakiness.
Additional context
Microsoft.Web.LibraryManager.Build, Version 3.0.71
- Ngôn ngữ chính
- C#
- Star
- 485
- Fork
- 92
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aspnet/LibraryManager
-
Add documentation about using `Microsoft.Web.LibraryManager.Build`Có thể đã có người làm @jimmylewis đã nhận 317 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
aspnet/LibraryManager#804 · 2 reaction ·
-
Changelog for 3.0.114Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 48/100
aspnet/LibraryManager#829 · 1 bình luận · 3 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
aspnet/LibraryManager#820 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aspnet/LibraryManager#808 · 5 bình luận ·
-
Add NPM as a providerĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
aspnet/LibraryManager#807 · 3 bình luận ·
Tất cả issue của aspnet/LibraryManager
Issue tương tự
-
A numeric literal is parsed in the host's culture, so 1.5 is 15 in a made EXE on a comma-decimal OSĐang mởbug interpreter silently-wrong small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
reactiveui/ReactiveUI.Binding.SourceGenerators#176 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
dotnet/csharpstandard#1830 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
c:docs p:high size:S t:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày