无法使用 dotnet add package 安装包

编程入门 行业动态 更新时间:2024-10-27 10:24:08
本文介绍了无法使用 dotnet add package 安装包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我是 .NET 新手,正在学习 Angular 和 .NET Core 的在线课程,同时使用 VS Code.该课程需要安装 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"

与项目

我使用以下命令安装包:

I use the following command to install the package:

dotnet add package AutoMapper.Extensions.Microsoft.DependencyInjection

到目前为止我尝试过的:

PackageReference 手动添加到 .csproj 文件中,然后使用 dotnet restore - 导致相同的错误 (NU1100) 使用 dotnet nuget locals all --clear 清除 NuGet 包缓存 - 导致相同的错误 Added PackageReference manually into the .csproj file then using dotnet restore - results in the same error (NU1100) 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 中的 NuGet.Config 文件解决了这个问题AppDataRoamingNuGet 文件夹,然后运行 ​​dotnet restore

I finally fixed the issue by deleting the NuGet.Config file in C:Users<user>AppDataRoamingNuGet 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/api/v2/ 而新的有 https://api.nuget/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 add package 安装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-14 16:03:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/845306.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:安装包   dotnet   add   package

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!