简体   繁体   中英

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

When attempting to work with Azure functions, I get this error. I am just trying to run the HttpExample I get the exact same error from the command as I do in Visual Studio Code. This is the code. I am a beginner at this so any help would be appricated.

<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>

Yes, I agree with Cindy's answer. Having no entries or incorrect package source entries in packageSources xml node in Nuget.Config can cause the error.

I have just encountered the same error when creating an Azure Function version 4.0.1 with .Net 6 released just a few days ago in Visual Studio Code. I do not have Visual Studio 2022 installed. I have .Net 6 SDK installed and use it with Visual Studio Code. You would think that the NuGet utility installed with.Net 6 SDK should have configured <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> in your user level or global level NuGet settings by default. But it did not.

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 level setting nuget.config file. That solved the **NU1100 Unable to resolve ** error.

On another note, I would say Visual Studio 2022 or its previous versions will configure nuget.org as the default package source for NuGet because I did not have to do that manually when I used Visual Studio 2017 before to download or restore NuGet packages.

The format of your.csproj file is actually no problem. Your code of.csproj works fine on my side.

By the way, version 3.0.3 of Microsoft.NET.Sdk.Functions is compatible with.Net Core 3.1. I think the problem is with your package management tool. If you use nuget, please check its configuration.

This is my 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>

Or you can try to reinstall your nuget management tool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM