1

I have recently updated my VS to 2022. My project is Azure Function App.

But when I click on debug item, I am getting the following error.

A project with an Output Type of Class Library cannot be started directly 
        
In order to debug this project, add an executable project to this solution which 
references the library project. Set the executable project as the startup project.

Usually, I prompt screen would appear with my Function app running.

What could be the issue?

user8400863
  • 655
  • 1
  • 7
  • 17

5 Answers5

7

I got it working. Seems that during installation Azure Development was not selected.

user8400863
  • 655
  • 1
  • 7
  • 17
1

Try cleaning and rebuilding your project. Also, if you have multiple projects try setting up a startup project and then compile the same.

Here are few workarounds that you can try

  1. Try cleaning and rebuilding your solution.

  2. If you have multiple projects try setting up a startup project and then compile the same.

    enter image description here

  3. If the above doesn't work try adding a new project to your solution and set Output Type of either Console Application or Windows Application. For this you can navigate to your properties by right clicking on your project

REFERENCES: A project with an Output type of Class Library cannot be started directly

SwethaKandikonda
  • 7,513
  • 2
  • 4
  • 18
0

Strange, because azure function work in VS2022 without any issue for me, which version of target framework is used in your function?

0

I've got this error when I removed Microsoft.NET.Sdk.Functions from Dependencies - Packages. When I clicked on Dependencies and choose Remove Unused Dependencies, it suggested removing Microsoft.NET.Sdk.Functions. After this I won't be able to run my project. When I added this dependency back, it works fine.

Alsin
  • 1,514
  • 1
  • 14
  • 18
0

I got this error after updating VS2022 to 17.6.1 where all my existing Azure Function projects were not recognized as such and wouldn't start. All the right modules were installed, NuGet cache cleared, solutions cleaned, etc. After trying everything else short of reinstalling Visual Studio, I created a new Azure Function project in a new solution. It showed as a Class Library at first but after a few minutes it recognized it as an Azure Function project. I then closed it and went back to my existing solutions and all projects were recognized as Azure Functions