在网上找到了解决方案,贴出来。
TF30063
The root of the problem
The decision whether to or not to try NTLM authentication is based on which internet zone OS thinks the request target is. In other words if OS says that your TFS server is outside intranet then HttpWebRequestwon’t bother with NTLM authentication at all. It is that simple. The decision lies within PresentationCore’s (!) internal CustomCredentialPolicy.InternetSecurityManager class which delegates the question about the internet zone to OS and returns the result to HttpWebRequest. For some reason at some point it starts to return Internet instead of Intranet. I am not sure exactly why, but I have a remedy. A dramatically simple one which doesn’t even involve modifications to NuGet (no need to wait for a NuGet fix!).
The solution
Open Internet Explorer browser, go to Internet Options/Security, select Local Intranet icon, click Sites button
On Local Intranet dialog click Advanced
and add your TFS server to the Websites list, like I did with mine (replace TFS with the name of your server)
Restart Visual Studio any enjoy NuGet from a new perspective!
This solution apparently solves all of the issues I had with the dreaded 401. Let me know if it works for you as well.
Considerations
The problem might not be related to NuGet at all but rather to PresentationCore (NuGet is a WPF application) which gets confusing results from OS through some interop. NuGet/Visual Studio is just a combination that triggers the otherwise sleeping problem.
原文地址:http://blog.rthand.com/post/2011/08/26/Fixing-combination-of-NuGet-and-Team-Foundation-in-workgroup-configuration-401-Unauthorized.aspx