无法使用dotnet添加软件包安装软件包 [英] Unable to install packages using dotnet add package

查看:317
本文介绍了无法使用dotnet添加软件包安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用VS Code的.NET新手,同时关注Angular和.NET Core的在线课程。本课程要求安装 AutoMapper.Extensions.Microsoft.DependencyInjection 程序包,但是尝试安装 any 程序包时,我始终收到以下错误消息。

I'm a .NET newbie using VS Code while following an online course on Angular and .NET Core. The course requires the AutoMapper.Extensions.Microsoft.DependencyInjection package to be installed but I keep getting the following errors when I try install any package.


  • 无法解析< package_name>适用于``.NETCoreApp,Version = v2.2''

Package< package_name>与项目< csproj_path>

项目中的所有框架不兼容我使用以下命令安装软件包:

I use the following command to install the package:

dotnet add package AutoMapper.Extensions.Microsoft.DependencyInjection

到目前为止我已经尝试过:


  1. PackageReference 手动添加到.csproj文件中,然后使用 dotnet restore -导致相同的错误(NU1100)

  2. 使用 dotnet nuget locals all --clear 清除NuGet程序包缓存-导致相同错误

  1. Added PackageReference manually into the .csproj file then using dotnet restore - results in the same error (NU1100)
  2. Cleared the NuGet package cache using dotnet nuget locals all --clear - results in the same error

在课程开始时尝试安装 Microsoft.EntityFrameworkCore.Sqlite 程序包之前就可以使用了,现在由于某种原因我无法安装任何程序包。

It was working before when I tried to install the Microsoft.EntityFrameworkCore.Sqlite package at the beginning of the course and now for some reason I can't install any package.

请注意,我无法使用NuGet扩展程序,因为它无法在公司代理后面运行。

Do note that I'm not able to use the NuGet extension as it's not working behind a corporate proxy.

任何帮助将不胜感激:)

Any help would be greatly appreciated :)

推荐答案

我终于通过删除 C:\Users\< user> \AppData\Roaming\NuGet 文件夹中的 NuGet.Config 文件并运行 dotnet restore

I finally fixed the issue by deleting the NuGet.Config file in C:\Users\<user>\AppData\Roaming\NuGet folder then running dotnet restore

运行 dotnet restore 在文件夹中创建了一个新的配置文件,我注意到该文件夹​​具有不同的 packageSources 值比旧值高。

Running dotnet restore created a fresh config file on the folder which i noticed has a different packageSources value than the old one.

旧版本有 https: //www.nuget.org/api/v2/ ,而新版本具有 https://api.nuget.org/v3/index.json

The old one had https://www.nuget.org/api/v2/ while the new one had https://api.nuget.org/v3/index.json

我完全忘记了我拥有VS安装了2010(使用nuget)负责旧的配置文件,我没有意识到dotnet-cli中的nuget也使用相同的旧配置。

I completely forgot that I have VS 2010 (with nuget) installed which was responsible for the old config file and I did not realize that nuget from the dotnet-cli was also using the same old configurations.

这篇关于无法使用dotnet添加软件包安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆