VS2019由于缺少NuGet Microsoft.NET.Sdk.Functions程序包而无法加载项目,但也无法添加此程序包

时间:2019-11-01 23:04:54

标签: visual-studio nuget-package

我的解决方案中有一个项目未在VSE2019中加载。它将引发此错误:

C:\MyProgram\src\MyProgram.Functions.csproj : error  : The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found.
Detailed Information:
Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.

该项目是由另一个开发人员(不在这里)创建的,.csproj包含以下内容:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <AzureFunctionsVersion>v1</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
    <PackageReference Include="WindowsAzure.ServiceBus" Version="2.1.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="Microsoft.ServiceBus">
      <HintPath>..\packages\WindowsAzure.ServiceBus.2.1.0.0\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
    </Reference>
    <Reference Include="System.Configuration" />
    <Reference Include="System.Web" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

以下是我到目前为止尝试过的方法,但仍然没有积极的结果:

  1. 我已注释掉引用此程序包的行,然后重新加载了解决方案(甚至重新启动了VS2019):
<!-- <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" /> -->
  1. 我尝试安装缺少的NuGet软件包,但是由于尚未加载该项目-我无法将其安装到该项目中(因为安装NuGet时,该项目根本不在可用项目列表中可用)。

我不确定为什么这个项目对软件包如此“讨厌”? 还是如何强制将缺少的NuGet安装到该项目?

1 个答案:

答案 0 :(得分:0)

似乎再次重新安装了最新的.Net SDK(3.0.100),就可以解决问题。