我已将VS 2022更新到最新版本,并将Azure函数项目升级到.Net7。从Visual Studio运行应用时收到错误消息“没有与项目中指定的版本匹配的函数运行时可用。”如何解决此问题?请注意,它在Azure中运行良好。
csproj文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
<None Remove="appsettings.Production.json" />
<None Remove="appsettings.staging.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.Production.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.staging.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageReference Include="Azure.Identity" Version="1.8.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.1" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.6.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Visual Studio 2022信息:
Microsoft Visual Studio Community 2022
Version 17.5.1
VisualStudio.17.Release/17.5.1+33424.131
Microsoft .NET Framework
Version 4.8.09032
Installed Version: Community
ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools
ASA Service Provider 1.0
ASP.NET and Web Tools 17.5.317.37931
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.5.317.37931
Azure App Service Tools v3.0.0
Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 17.5.317.37931
Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 4.5.0-6.23123.11+271ccd71554f7d28d2f90551aafd0bdeb5d327aa
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Microsoft Azure Hive Query Language Service 2.6.5000.0
Language service for Hive query
Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Language service for Azure Stream Analytics
Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
NuGet Package Manager 6.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.5.2.2307502+8b3141d86b738daf2ca3ed9c15b12513071fc676
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.2.40118.0
Microsoft SQL Server Data Tools
ToolWindowHostedEditor 1.0
Hosting json editor into a tool window
TypeScript Tools 17.0.20105.2003
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.5.0-6.23123.11+271ccd71554f7d28d2f90551aafd0bdeb5d327aa
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.5.0-beta.23053.5+794b7c259d9646a7eb685dad865aa27da7940a21
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
此外,如果我尝试创建一个新的Azure函数项目,我不认为.Net7是一个运行时选项。
1条答案
按热度按时间gab6jxml1#
当.NET 7在Azure Functions Context上的Visual Studio IDE中不可见时,请尝试在“控制面板”〉“程序”〉“程序和功能”中检查,所有程序和功能均已按预期安装,但仍未显示在Visual Studio 2022最新版本IDE中。
很高兴@frosty您在VS Dev社区文章#10224478的帮助下解决了此问题
1.通常,可以通过删除**
%LocalAppData%\AzureFunctionsTools
并重新启动Visual Studio IDE来解决此问题,看看是否可以正常工作。1.如果不起作用,请转到VS IDE〉工具-〉选项-〉项目和解决方案-〉Azure Functions并单击“
check for updates
**"。然后下载并安装更新,看看是否起作用。