簡體   English   中英

NU1100:無法解析 'Microsoft.NET.Sdk.Functions (>= 3.0.3)' for '.NETCoreApp,Version=v3.1'

[英]NU1100:Unable to resolve 'Microsoft.NET.Sdk.Functions (>= 3.0.3)' for '.NETCoreApp,Version=v3.1'

嘗試使用 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>

是的,我同意 Cindy 的回答。 在 Nuget.Config 中的packageSources xml 節點中沒有條目或不正確的 package 源條目可能會導致錯誤。

我在使用幾天前在 Visual Studio Code 中發布的.Net 6創建Azure Function 版本 4.0.1時遇到了同樣的錯誤。 我沒有安裝 Visual Studio 2022。 我安裝了.Net 6 SDK並將其與 Visual Studio Code 一起使用。 你會認為安裝.Net 6 SDK 的NuGet實用程序應該配置了<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />在您的用戶級別全局級別默認設置為 NuGet 但事實並非如此。

I run do.net nuget add source https://api.nuget.org/v3/index.json -n nuget.org command in a DOS Command Prompt or a PowerShell session to add the nuget.org as a packageSource in my user級別設置 nuget.config 文件。 這解決了 **NU1100 無法解決 ** 錯誤。

另一方面,我會說 Visual Studio 2022 或其以前的版本會將 nuget.org 配置為 NuGet 的默認 package 源,因為在我之前使用 Visual Studio 2017 下載或恢復 NuGet 包時,我不必手動執行此操作。

你的.csproj文件的格式其實是沒有問題的。 您的代碼 of.csproj 在我這邊工作正常。

順便說一句,Microsoft.NET.Sdk.Functions 3.0.3版本兼容.Net Core 3.1。 我認為問題出在您的 package 管理工具上。 如果您使用nuget,請檢查其配置。

這是我的 Nuget.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

或者您可以嘗試重新安裝您的 nuget 管理工具。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM