繁体   English   中英

无法在 VS 2022 企业版 17.0.0 中在进程外编译 Azure Function v4

[英]Unable to compile Azure Function v4 out-of-process in VS 2022 Enterprise Version 17.0.0

Azure 函数的.csproj定义按照以下代码段进行:

<PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <LangVersion>10.0</LangVersion>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
     <OutputType>Exe</OutputType>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
  </ItemGroup>

Program.cs 文件的初始化类似于以下代码片段:

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureAppConfiguration((context, configure) =>
    {
        configure
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true)
        .AddEnvironmentVariables();
    })
    .ConfigureServices((context, services) =>
    {
          services.AddMyServices();
    })
    .Build();

编译器发出以下错误消息:

严重性代码说明项目文件行抑制状态错误 MSB4062 无法从程序集加载“GenerateFunctionMetadata”任务 C:\\Users\\myusername.nuget\\packages\\microsoft.net.sdk.functions\\4.0.1\\build..\\tools \\net6.0\\Microsoft.NET.Sdk.Functions.MSBuild.dll。 确认声明正确,程序集及其所有依赖项都可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共类。 MyApp.Functions C:\\Users\\myusername.nuget\\packages\\microsoft.azure.functions.worker.sdk\\1.3.0\\build\\Microsoft.Azure.Functions.Worker.Sdk.targets 60

你能给出解决这个问题的方向吗?

我们需要删除 Microsoft.NET.Sdk.Functions NuGet 包引用来解决这个编译问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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