Install package fails when solution/project is bound to TFS source control #1164

Closed
tillig opened this Issue Aug 12, 2015 · 18 comments

Projects

None yet

8 participants

@tillig
tillig commented Aug 12, 2015

Running VS 2015 with NuGet 3.1.60724.766.

While you can have your project/solution checked into TFS source control, once you bind the solution/project to TFS, NuGet package install starts failing due to looking in odd folder locations.

Repro:

  1. In VS 2015, create a new solution with a console application targeting .NET 4.5.2. Do not select the "Add solution to source control" option.
  2. Check in the solution, project, and files to TFS but don't bind it to TFS yet. Just check it in.
  3. Add a NuGet package to the console app, say, Newtonsoft.Json. Works great.
  4. Bind the solution/project to TFS. File -> Source Control -> Advanced -> Change Source Control. Check in the updated/bound project.
  5. Restart Visual Studio and open the solution.
  6. Try to install a package like Autofac. It will fail with an error like Could not find part of the path 'E:\dev\tfs\users\tillig\nuget3repro\lib'.
  7. Unbind the project from TFS using File -> Source Control -> Advanced -> Change Source Control.
  8. Restart Visual Studio and open the solution.
  9. Try installing the same package that just failed - now it works again.

On failure you'll see this error text in the Package Manager output window:

Attempting to gather dependencies information for package 'Autofac.3.5.2' with respect to project 'DemoApp', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'Autofac.3.5.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Autofac.3.5.2'
Resolved actions to install package 'Autofac.3.5.2'
For adding package 'Autofac.3.5.2' to project 'DemoApp' that targets 'net452'.
For adding package 'Autofac.3.5.2' to project 'DemoApp' that targets 'net452'.
Adding package 'Autofac.3.5.2' to folder 'E:\dev\tfs\users\tillig\nuget3repro\packages'
Install failed. Rolling back...
Package 'Autofac 3.5.2' does not exist in project 'DemoApp'
Removing package 'Autofac 3.5.2' from folder 'E:\dev\tfs\users\tillig\nuget3repro\packages'
Removed file 'Autofac.3.5.2.nupkg' from folder 'E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2'.
Removed folder 'E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2'.
Removed package 'Autofac 3.5.2' from folder 'E:\dev\tfs\users\tillig\nuget3repro\packages'
System.IO.DirectoryNotFoundException: Could not find a part of the path 'E:\dev\tfs\users\tillig\nuget3repro\lib'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.GetDirectories(String path, String searchPattern)
   at Microsoft.TeamFoundation.VersionControl.Client.FileSystemWalker.<GetEnumerator>d__2.MoveNext()
   at Microsoft.TeamFoundation.VersionControl.Client.Workspace.PendAdd(String[] paths, Boolean isRecursive, String fileType, LockLevel lockLevel, Boolean treatMissingItemsAsFiles, Boolean silent, Boolean applyLocalItemExclusions)
   at NuGet.TeamFoundationServer.DefaultTFSSourceControlManager.PendAddFiles(IEnumerable`1 fullPaths, String root, INuGetProjectContext nuGetProjectContext)
   at NuGet.ProjectManagement.FolderNuGetProject.<InstallPackageAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.ProjectManagement.MSBuildNuGetProject.<InstallPackageAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.UI.UIActionEngine.<ExecuteActionsAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.UI.UIActionEngine.<PerformActionAsync>d__3.MoveNext()
========== Finished ==========

In the Source Control - Team Foundation output window, you see:

E:\dev\tfs\users\tillig\nuget3repro\Autofac.3.5.2.nupkg: No file matches.
The item E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2\lib\net40\Autofac.dll could not be found in your workspace, or you do not have permission to access it.
The item E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2\lib\net40\Autofac.xml could not be found in your workspace, or you do not have permission to access it.
The item E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\Autofac.dll could not be found in your workspace, or you do not have permission to access it.
The item E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2\lib\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\Autofac.xml could not be found in your workspace, or you do not have permission to access it.
The item E:\dev\tfs\users\tillig\nuget3repro\packages\Autofac.3.5.2\Autofac.3.5.2.nupkg could not be found in your workspace, or you do not have permission to access it.
@yishaigalatzer yishaigalatzer added this to the 3.1.2 milestone Aug 12, 2015
@yishaigalatzer

@tillig did you save the solution at any point before checking it in?

Also want to know if this is blocking you in any way, looking at this again this might be ok to fix in the next release towards Nov, rather than trying to cram it into the Aug/Sep release

@tillig
tillig commented Aug 13, 2015

In this case, the solution was built/saved before checking in... But for the purposes of this repro, it doesn't seem to matter. You can save and/or build after every step, or only save/check in as VS prompts you. In the end, the thing that matters is the binding of the project/solution to TFS.

I'm not blocked now that I know the secret to working around the issue.

@yishaigalatzer

Thanks for the update. We are trying to finish an update to NuGet to alleviate a set of common problems. I'm not sure this fits in at that priority level. But given that we have such a detailed repro it might be easy to get it in. We will take a look at the code and assess where to take it.

Thanks for the diligence both in the report and the quick follow-up. Hope to have at least an initial answer in a few days.

@deepakaravindr
Member

@tillig, Thanks for the detailed repro! We believe we have fixed this issue in our ongoing release cycle, but it has not been released yet. Could you please contact me at daravind@microsoft.com regarding this?

@deepakaravindr
Member

It was verified that this bug has been fixed. This is related to #980

@tillig
tillig commented Aug 27, 2015

The fix may have been related, but the symptoms reported are vastly different.

@deepakaravindr
Member

True. I have removed the Duplicate flag

@RanjiniM
Member
RanjiniM commented Sep 2, 2015

Verified in 3.2

@RanjiniM RanjiniM added 3 - Done and removed 2 - Working labels Sep 2, 2015
@CobraCalle

This bug is still alive (version 3.3.0.167)... we have a solution with more that 170 projects... and updating nugets (own packages stored on a file share) is always a pain... cannot remember that it has rely worked in the past without hours of manually correcting the files package manager has destroyed... every time a bug / problem is fixed another opens... really frustrating... :-(

@RanjiniM RanjiniM was unassigned by CobraCalle Mar 24, 2016
@mhov
mhov commented Apr 25, 2016

I'm on VS 2015 Update 2, TFS 2015 Update 2, Nuget 3.4.2.820 and I still have this problem. Updating a few packages across my 30 project sln can take 30-40 minutes. The sln started out on VS 2012 years ago and upgraded along the way, so i'm not sure if that's part of this issue.

@yishaigalatzer

@mhov this looks like an unrelated issue, the good news is that we are working on perf improvements for this scenario, and have a couple of improvements in flight, are you able to share your project with us so we can validate it? email support @ nuget.org

CC @emgarten

@mhov
mhov commented Apr 25, 2016

@yishaigalatzer Sorry if it wasn't clear in my original post, but I am experiencing the "... could not be found in your workspace, or you do not have permission to access it." errors, with each one causing a 30-60 second delay (some sort of timeout/retry scenario?) for each package on each project. Adding up to 30-40 minute for some nuget scenarios. Does that change your opinion?

@emgarten
Contributor

@mhov would you share the full output log from your nuget update?

I don't see that error text anywhere in the nuget code base, but nuget may be causing Visual Studio to write it out.

@yishaigalatzer

@mhov yes it does, we do not have a fix for this in flight. Could you please open a new bug with exact repro steps, and if you could share a solution or repro over the bug or email, it will get us some traction.

I know I shouldn't be saying it, but did you try GIT (TFS servers support it) ?

@mhov
mhov commented Apr 25, 2016

For example if i try to upgrade AWSSDK i'll get this message

The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\lib\net35\AWSSDK.dll could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\lib\net35\AWSSDK.pdb could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\tools\net35\install.ps1 could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\tools\net45\install.ps1 could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\tools\account-management.ps1 could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\lib\net45\AWSSDK.dll could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\lib\net45\AWSSDK.pdb could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\lib\windows8\AWSSDK.dll could not be found in your workspace, or you do not have permission to access it.
The item D:\MyCompany\Main\packages\AWSSDK.2.1.4.0\lib\windowsphone8\AWSSDK.dll could not be found in your workspace, or you do not have permission to access it.

It sounds very much like a TFS issue surfaced by nuget. The upgrade succeeds eventually, but each of these error messages take a certain amount of time to come up. It may help to know that i have a .tfignore file in the root with \packages completely ignored by TFS. I had to do this because <add key="disableSourceControlIntegration" value="true" /> wasn't being observed at some point in the past. Perhaps i should rely on disableSourceControlIntegration if i have latest and greatest of VS/TFS/Nuget currently?

@yishaigalatzer

Yes please try disableSourceControlIntegration again

@mhov
mhov commented Apr 26, 2016

Removing \packages from the .tfignore file and relying on disableSourceControlIntegration did not resolve the situation, I saw the same errors and slow nuget package updating. Packages weren't added to source control, but all 600+ \packages_._ nuget files end up in the Pending Changes tab's Excluded Changes as "Detected: 600 add(s)".

@rrelyea
Contributor
rrelyea commented Apr 26, 2016

we're going to open a new issue and work on isolating the repro (with your help). thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment