首页 > 解决方案 > 在我的 .NET Core 应用程序中更新 NuGet 包时遇到问题

问题描述

每次我尝试更新“Microsoft.Extensions.Primitives”时,它都会失败,如下所示:

  GET https://api.nuget.org/v3/registration4-gz-semver2/microsoft.extensions.primitives/index.json
  OK https://api.nuget.org/v3/registration4-gz-semver2/microsoft.extensions.primitives/index.json 142ms
Getting restore information for project /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj
Running non-parallel restore.
Reading project file /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj.
Persisting no-op dg to /Users/developer/Source/WebApp-001/WebApp-001/obj/WebApp-001.csproj.nuget.dgspec.json
Restoring packages for /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj...
Restoring packages for .NETCoreApp,Version=v3.1...
  GET https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json
  OK https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json 3473ms
Resolving conflicts for .NETCoreApp,Version=v3.1...
Unable to find package Microsoft.Extensions.Primitives with version (>= 3.1.1)
  - Found 36 version(s) in nuget.org [ Nearest version: 3.1.0 ]
Package restore failed. Rolling back package changes for 'WebApp-001'.

我在使用 Visual Studio 的 macOS 上使用 .NET Core 3.1 作为我的目标框架。我也试过从终端更新,没有运气。此 NuGet 包和其他一些包无法更新到版本 3.1.1。它们似乎都“卡在”3.1.0 版上。

也许有人以前遇到过这个问题?我不明白为什么“[u]nable to find package Microsoft.Extensions.Primitives with version (>= 3.1.1)”。

我的 .csproj 文件的副本:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RootNamespace>WebApp_001</RootNamespace>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(RunConfiguration)' == 'TheMidtownModel' ">
    <StartAction>Project</StartAction>
    <ApplicationURL>http://localhost:5002</ApplicationURL>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />

    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>

    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Primitives" Version="3.1.0" />    
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.1.0" />     

    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.5" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />

    <PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
    <PackageReference Include="Sendgrid" Version="9.12.6" />
    <PackageReference Include="React.AspNet" Version="5.1.2" />
    <PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="3.3.0" />
    <PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64" Version="3.3.0" />
    <PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64" Version="3.3.0" />
    <PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.3.0" />
    <PackageReference Include="JavaScriptEngineSwitcher.Extensions.MsDependencyInjection" Version="3.3.0" />
    <PackageReference Include="Twilio.AspNet.Core" Version="5.33.1" />
    <PackageReference Include="Twilio" Version="5.37.3" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.19" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
  </ItemGroup>
  <ItemGroup>
    <Content Remove="wwwroot\css\bootstrap-grid.min.css" />
    <Content Remove="wwwroot\css\bootstrap.min.css" />
    <Content Remove="wwwroot\css\bootstrap.min.css.map" />
    <Content Remove="wwwroot\js copy\__bootstrap.bundle.min.js" />
    <Content Remove="wwwroot\js\bootstrap.js" />
    <Content Remove="BackUpFiles\appsettings.Development.json" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Views\Admin\" />
    <Folder Include="Views\RoleAdmin\" />
    <Folder Include="Views\Claims\" />
    <Folder Include="Views\FileUpload\" />
    <Folder Include="Authorization\" />
    <Folder Include="Views\Shared\Layouts\" />
    <Folder Include="Views\Shared\Partial\" />
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="Migrations\20191216040205_SecondUpdateAlbumField.cs" />
    <Compile Remove="Migrations\20191216040205_SecondUpdateAlbumField.Designer.cs" />
    <Compile Remove="Migrations\20191216040329_ThirdUpdateAlbumField.cs" />
    <Compile Remove="Migrations\20191216040329_ThirdUpdateAlbumField.Designer.cs" />
  </ItemGroup>
</Project>

标签: c#asp.net.netnuget

解决方案


推荐阅读