【问题标题】:Could not locate the assembly "Microsoft.Owin..." (and more) after updating Nuget更新 Nuget 后找不到程序集“Microsoft.Owin...”(以及更多)
【发布时间】:2020-11-18 16:30:11
【问题描述】:

我今天为一个项目更新了 Nuget(现在很多 MS 包都是 5.0)...但是现在我在编译时遇到了这些错误:

1>------ Build started: Project: IcSso.Client.DotNetFramework, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin, Version=4.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin.Security, Version=4.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Owin.Security.Cookies, Version=4.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>D:\Develop\Projects\_Ic\IcSso\IcSso.Client.DotNetFramework\AuthHelper.vb(5,9): warning BC40056: Namespace or type specified in the Imports 'System.Web.Mvc' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
1>D:\Develop\Projects\_Ic\IcSso\IcSso.Client.DotNetFramework\AuthHelper.vb(10,44): error BC30002: Type 'Microsoft.Owin.IOwinContext' is not defined.
1>D:\Develop\Projects\_Ic\IcSso\IcSso.Client.DotNetFramework\Startup.vb(5,9): warning BC40056: Namespace or type specified in the Imports 'Microsoft.Owin.Security.Cookies' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
1>D:\Develop\Projects\_Ic\IcSso\IcSso.Client.DotNetFramework\Startup.vb(60,49): error BC30002: Type 'CookieApplyRedirectContext' is not defined.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这是我的包裹...

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net48" />
  <package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.Cryptography.Internal" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.DataProtection" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.DataProtection.Abstractions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.DataProtection.Extensions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.2.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.2.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.Http.Abstractions" version="2.2.0" targetFramework="net48" />
  <package id="Microsoft.AspNetCore.Http.Features" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.Configuration.Abstractions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.DependencyInjection" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.FileProviders.Abstractions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.Hosting.Abstractions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.Logging.Abstractions" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.Options" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Extensions.Primitives" version="5.0.0" targetFramework="net48" />
  <package id="Microsoft.Owin" version="4.1.1" targetFramework="net48" />
  <package id="Microsoft.Owin.Security" version="4.1.1" targetFramework="net48" />
  <package id="Microsoft.Owin.Security.Cookies" version="4.1.1" targetFramework="net48" />
  <package id="Microsoft.Owin.Security.Interop" version="2.1.2" targetFramework="net48" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
  <package id="Microsoft.Win32.Registry" version="5.0.0" targetFramework="net48" />
  <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net48" />
  <package id="Owin" version="1.0" targetFramework="net48" />
  <package id="System.Buffers" version="4.5.1" targetFramework="net48" />
  <package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" />
  <package id="System.IO.Pipelines" version="5.0.0" targetFramework="net48" />
  <package id="System.Memory" version="4.5.4" targetFramework="net48" />
  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net48" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net48" />
  <package id="System.Security.AccessControl" version="5.0.0" targetFramework="net48" />
  <package id="System.Security.Cryptography.Xml" version="5.0.0" targetFramework="net48" />
  <package id="System.Security.Permissions" version="5.0.0" targetFramework="net48" />
  <package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net48" />
  <package id="System.Text.Encodings.Web" version="5.0.0" targetFramework="net48" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
  <package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>

知道为什么在更新 Nuget 后会出现所有这些错误吗? Owin 对其他 .Net 5 包有问题吗?

我已尝试清除 bin 和 obj 文件夹 - 没有帮助。

【问题讨论】:

    标签: .net visual-studio nuget .net-5


    【解决方案1】:

    尝试以下步骤:

    1)clean all nuget caches或删除C:\Users\xxx(current user)\.nuget\packages下的所有nuget缓存

    2)关闭VS,删除解决方案文件夹下的.vs隐藏文件夹,binobj文件夹。

    3)重启你的项目,在Tools-->Nuget Package Manager-->Package Manager下运行update-package -reinstall控制台

    【讨论】:

      猜你喜欢
      • 2019-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-08
      • 1970-01-01
      相关资源
      最近更新 更多