安装 Microsoft.Owin 时出现问题(对于 SignalR)

Problems installing Microsoft.Owin (for SignalR)

我正在尝试通过将 SignalR 添加到现有(但很小)ASP.Net(.Net 4.6.1,VS 2017)Web 应用程序来试验 SignalR。但是,我在安装 Nuget 包时遇到了真正的问题;更具体地说,Microsoft.Owin 组件(似乎是一个依赖项)。

我已按照说明 here 进行操作,但一旦我尝试安装 Owin - 显式或间接地尝试安装主 SignalR 包,无论它是通过包管理器还是程序包管理器控制台 - 我收到错误:

PM> Install-Package Microsoft.Owin

Attempting to gather dependency information for package 'Microsoft.Owin.4.0.0' with respect to project 'SignalRProject', targeting '.NETFramework,Version=v4.6.1'

Gathering dependency information took 43.64 ms Attempting to resolve dependencies for package 'Microsoft.Owin.4.0.0' with DependencyBehavior 'Lowest'

Resolving dependency information took 0 ms Resolving actions to install package 'Microsoft.Owin.4.0.0'

Resolved actions to install package 'Microsoft.Owin.4.0.0'

Retrieving package 'Microsoft.Owin 4.0.0' from 'nuget.org'.

Retrieving package 'Owin 1.0.0' from 'nuget.org'.

Adding package 'Owin.1.0.0' to folder 'c:\code\SignalRProject\packages'

Install failed. Rolling back...

Package 'Owin.1.0.0' does not exist in project 'SignalRProject'

Removing package 'Owin.1.0.0' from folder 'c:\code\SignalRProject\packages'

Install-Package : TF400024: The change on c:\code\SignalRProject\packages\Owin.1.0\Owin.1.0.nupkg cannot be undone because a file already exists at c:\code\SignalRProject\packages\Owin.1.0\Owin.1.0.nupkg. The file must be deleted from disk for the undo to succeed.

我已经尝试了 Owin.1.0.nupkg 文件和父目录本身,但是在重新启动 VS 之后我继续得到错误。我试过升级到 .Net 4.7.1,但没有效果。我如何找出导致 Owin 安装错误的原因?

您可以下载一个 运行 微软示例,然后与您的示例进行比较 https://code.msdn.microsoft.com/Getting-Started-with-c366b2f3

Install-Package : TF400024: The change on c:\code\SignalRProject\packages\Owin.1.0\Owin.1.0.nupkg cannot be undone because a file already exists at c:\code\SignalRProject\packages\Owin.1.0\Owin.1.0.nupkg. The file must be deleted from disk for the undo to succeed.

此错误是由 TFVC 源代码控制引起的。您应该首先 check-in 您的更改,然后安装 nuget 包

我已经设法解决了我的问题,并使用第 3 方 Paket Nuget 替代方案安装了 Owin(和 SignalR)。

>paket.exe add Microsoft.Owin --project SignalRProject
Paket version 5.148.0
Dependencies files saved to c:\code\SignalRProject\paket.dependencies
Adding package Microsoft.Owin to c:\code\SignalRProject\paket.references into group Main
References file saved to c:\code\SignalRProject\paket.references
 - Creating model and downloading packages.
 - paket.references -> SignalRProject.csproj
Performance:
 - Disk IO: 63 milliseconds
 - Runtime: 6 seconds