简体   繁体   中英

Unable to debug and publish Azure Function from Visual Studio 2017

I used to debug and publish my Azure Function Project using Visual Studio 2017.

However suddenly everything stopped working.

When i tried to debug the project i got the error "A project with an Output Type of Class Library cannot be started directly.". When i tried to publish the project, the option to publish to Azure disappeared and i'm only offered to publish to a folder. When trying to create a profile i can also only choose the Folder Profile type.

I saw a similar behavior once in a Web Project when the "Project Sdk" Attribute in the .csproj file was wrong but i doublechecked it with a newly created Azure Function Project and it was the same. When i create a new function project, i can publish to Azure as i could before.

I'm using the following packages:

along with .NET Framework 4.7.1.

Also i'm referencing some other projects from my solution containing Business Logic.

I ended up creating a new function project, copying everything there and now it's working again as expected.

Does anybody know how this could happen and how to fix it without creating everything from scratch?

就我而言,我能够通过确保引用了适用于Azure Functions的NuGet包来对其进行修复:

<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.14" />    

I just had this same thing happen to me. I added a new Azure Function project to an existing solution, and it wouldn't let me debug it. I added an additional Azure Function project just to test it, and it worked fine. Compared the .csproj files, they were both correct.

I restarted Visual Studio and I was able to debug both Function projects, though I don't know if that will always fix the problem.

Azure Functions tooling for Visual Studio is not always as stable as one would wish - but it's getting better for every release.

I had a similar problem after updating to Visual Studio 2017 v15.3 and then again when updating to v15.5. Both problems disappeared after updating or reinstalling the Azure Functions plugin.

But if you already have opened (and saved) to solution with a non-working VS setup then VS seems to 'destroy' the project sometimes.

You could look in your non-working project to see if your .csproj-file(s) contain:

<ProjectGuid>{0EC16A67-C60A-4950-A533-07D8783C88B0}</ProjectGuid>

...which is the guid for Azure Functions projects. If your ProjectGuid is different then you could try changing it to the above and it should(might?) work.

I had the same problem. I went in to the Visual Studio Installer and (re?) installed the "Azure development" workload. That fixed it for me.

It could be because the wrong project is set as startup project. In the solution explorer, you'll notice that the startup project is in bold. If it is not the right project, try right clicking on the correct one and click Set as startup project.

Solved it for me.

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