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

AreNuGetPackagesSafe task failed unexpectedly #11

Open
jkariotisAtNexIt opened this issue May 27, 2014 · 2 comments
Open

AreNuGetPackagesSafe task failed unexpectedly #11

jkariotisAtNexIt opened this issue May 27, 2014 · 2 comments

Comments

@jkariotisAtNexIt
Copy link

Error 1 The "AreNuGetPackagesSafe" task failed unexpectedly.
System.IO.IOException: The process cannot access the file 'C:\Projects\Alme\Agent\Development\NextIT.Alme.Server\packages\SafeNuGet.1.0.9\build\cache\unsafepackages.xml' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.IO.FileInfo.OpenRead()
at Owasp.SafeNuGet.Unsafe.PackageListLoader.GetCachedUnsafePackages(String cachePath, Int32 cacheTimeInMinutes, Boolean& cacheHit)
at Owasp.SafeNuGet.AreNuGetPackagesSafe.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() NextIT.Utilities.Generics

@eoftedal
Copy link

Is it doing that even after restarting Visual Studio ?

@git-hub-user
Copy link

I encounter this issue intermittently. In my case, I have 3 start-up projects: 2 web applications and a console application. The error occurs both when starting with debugging (F5) and when (re)building all.

It did some investigation with Process Monitor. These are the results:

First task

Process
Name: MSBuild.exe
Command Line: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe /nologo /nodemode:1 /nodeReuse:true
PID: 1220
Parent PID: 10588

Event
Event Class: File System
Operation: CreateFile
Result: SUCCESS
Path: ...\WebApp\packages\SafeNuGet.1.0.10\build\cache\unsafepackages.xml.new
Duration: 0.0001743
Desired Access: Generic Write, Read Attributes
Disposition: OverwriteIf
Options: Synchronous IO Non-Alert, Non-Directory File, Open No Recall
Attributes: n/a
ShareMode: Read
AllocationSize: 0
OpenResult: Overwritten

Second task

Process
PID: 12624
Parent PID: 10588

Event
Event Class: File System
Operation: CreateFile
Result: SHARING VIOLATION
Path: ...\WebApp\packages\SafeNuGet.1.0.10\build\cache\unsafepackages.xml.new
Duration: 0.0000357
Desired Access: Generic Write, Read Attributes
Disposition: OverwriteIf
Options: Synchronous IO Non-Alert, Non-Directory File, Open No Recall
Attributes: n/a
ShareMode: Read
AllocationSize: 0

Conclusion

The Parent PID belongs to Visual Studio 2017. It is clear that msbuild is started in parallel and both processes attempt to open the same file for writing. It the second file is not granted the access, the build fails.

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

3 participants