当尝试使用 Azure 函数时,我收到此错误。我只是想运行 HttpExample 我从命令中得到了与 Visual Studio Code 中完全相同的错误。这是代码。我是这方面的初学者,因此将提供任何帮助。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
小智 10
是的,我同意Cindy的回答。Nuget.Config中的packageSources xml 节点中没有条目或包源条目不正确可能会导致错误。
我刚刚在 Visual Studio Code 中使用几天前发布的.Net 6创建Azure Function 版本 4.0.1时遇到了同样的错误。我没有安装 Visual Studio 2022。我安装了.Net 6 SDK并将其与 Visual Studio Code 一起使用。您可能会认为随 .Net 6 SDK 安装的NuGet实用程序默认应该在您的用户级别或全局级别 NuGet 设置中进行配置。但事实并非如此。<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
我dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org在 DOS 命令提示符或 PowerShell 会话中运行命令,将 nuget.org 添加为我的用户级别设置 nuget.config 文件中的packageSource。这解决了 **NU1100 无法解析 ** 错误。
另一方面,我想说 Visual Studio 2022 或其以前的版本会将 nuget.org 配置为 NuGet 的默认包源,因为当我之前使用 Visual Studio 2017 来下载或恢复 NuGet 包时,我不必手动执行此操作。