Kon*_*262 1 c# nuget-package-restore visual-studio-code asp.net-core
我不确定如何将Visual Studio Code中的.net核心项目的默认nuget提要设置为https://api.nuget.org/v3/index.json
当我尝试添加程序包(并随后恢复依赖关系)时,出现以下错误...
C:\Program Files\dotnet\sdk\2.1.403\NuGet.targets(114,5): error : Unable to load the service index for source https://smartassessor.pkgs.visualstudio.com/_packaging/SANuget/nuget/v3/index.json. [c:\Users\Matthew.OConnor\Desktop\Important Documents\Programming\DatingApp\DatingApp.API\DatingApp.API.csproj]
C:\Program Files\dotnet\sdk\2.1.403\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [c:\Users\Matthew.OConnor\Desktop\Important Documents\Programming\DatingApp\DatingApp.API\DatingApp.API.csproj]
Run Code Online (Sandbox Code Playgroud)
此源https://smartassessor.pkgs.visualstudio.com/_packaging/SANuget/nuget/v3/index.json
与我当前的项目无关,但是它用于通常使用完整Visual Studio运行的其他项目。这些项目保存在与该项目完全不同的位置。
我只希望能够在.net核心项目中从nuget.org添加nuget包。如何在VS代码中执行此操作?
我目前在这个项目中没有nuget.config文件。
错误中提到的程序包源似乎来自我在使用Visual Studio时设置的程序包源
这是我的csproj文件...
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="4.0.1"/>
<PackageReference Include="CloudinaryDotNet" Version="1.3.1"/>
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final"/>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
CloudinaryDotNet
是产生上述错误的软件包。
小智 7
我认为VS Code只是在运行dotnet restore
,并且看到该源正在使用的原因是因为它是在用户/计算机nuget配置文件(分别位于您似乎正在运行的Windows上的%appdata%\NuGet\NuGet.Config
&%ProgramFiles(x86)%\NuGet\Config
)上配置的。您显示的VS配置编辑器只是此配置文件的一个不错的GUI。
如果要保留此常规设置,则应该可以nuget.config
在VS Code项目中使用一个文件(您提到的该文件目前还没有)。这里有更多信息- 将自定义包源添加到Visual Studio Code。
另外,如果您尝试手动还原,则可以使用以下两个标志之一-
dotnet restore --source https://api.nuget.org/v3/index.json
dotnet restore --ignore-failed-sources
这些是非常自我解释的,但是您可以在此处查看完整的文档-https: //docs.microsoft.com/zh-cn/dotnet/core/tools/dotnet-restore?tabs=netcore2x
希望这可以帮助 (:
归档时间: |
|
查看次数: |
2317 次 |
最近记录: |