azure-functions-core-tools: Can't determine Project to build. Expected 1 .csproj or .fsproj but found 3 when running "func start"
The func start command used to work flawlessly but it started showing the subject error message. Further info:
- .NET SDK 8.0.101
func --versionreveals version 4.0.5455- There is only one .csproj file in the function app’s folder, but the function app is a part of a C# solution
- I launched VS Code to create and initialize a new minimal azure function app. The
func startworks.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 41
- Comments: 55 (13 by maintainers)
Delete the /bin & obj folder
I’m having the exact same issue.
A new version or core tools was released last week with a fix to address this issue. Please upgrade to that version.
https://github.com/Azure/azure-functions-core-tools/releases/tag/4.0.6280
ACK I just filed this bug too and realize my bug is a dupe of this. I am escalating directly to team.
@ryanzwe It worked as a workaround but one has to keep doing it every single time. I think the root cause must be addressed.
@claus18 The issue is automatically closed by the GitHub workflow when the associated pull request is completed. This means the change has been merged into the correct branch, and the next step is to release a new version of the core tools that includes this change.
We will provide an update in this thread when a new version of the core tools, including this change, becomes available.
Just an update: this issue is happening not only on Windows 11, but also on a macOS with VS Code. I think the priority of this issue must be elevated to address and deploy a solution ASAP.
/cc @khkh-ms
Is there an ETA?
I appreciate the effort, and in the spirit of providing good heart feedback I must say the the developer experience with Azure Functions in .NET has impacted my team’s productivity – to the point that we will not consider it as a viable architecture in the future and we will look for alternatives to migrate our code.
I’ve submitted a pull request with a fix to this issue. The fix limits the search for .csproj files to the function directory. It was recursively searching before. I think the fix is appropriate because the code in question is a validation check that is trying to make sure that a subsequent call to dotnet build is going to work, and dotnet build (when called without specifying a project file) also only looks in the working directory non-recursively. So, in my opinion the validation check should follow the same rules.
That being said, I’m not associated with this project in any way. I’m not a contributor to this project, nor do I work at Microsoft. I’m just someone who wanted this fixed. So, if you have one of the following questions, not only do I not know the answer, but I would also love to have an answer from a maintainer of this project.
I was able to build the project locally with my fix and then replace func.exe, func.dll in C:\Program Files\Microsoft\Azure Functions Core Tools with the ones I built and now the problem is fixed for me. You are welcome to attempt the same, but you would be on your own in terms of support, and there could be unexpected consequences of running a locally built version.
We just upgraded to latest isolated functions with .net 8 and 4.0.5611 azure function core tools and are receiving the same issue.
The workarounds mentioned above work, but they are really annoying.
I will add that you can use the command line to clean and start at the same time, which makes it slightly less annoying.
Had this issue as well due to the same cause with
Microsoft.Azure.Functions.Worker.Sdkversion1.17.0. Looks like the latest version of the package resolves this issue though. Deleting the current bin/obj directories and then updatingMicrosoft.Azure.Functions.Worker.Sdkto1.17.2resolves this issue.I can confirm this happens when upgrading
Microsoft.Azure.Functions.Worker.Sdkfrom1.16.4to1.17.0.Details:
I’m using .net 8 dotnet-isolated. For me it is the Worker.SDK that is borked. Microsoft.Azure.Functions.Worker.Sdk - 1.16 - works Microsoft.Azure.Functions.Worker.Sdk - 1.17.0, 1.17.1, 1.17.2, 1…17.3, 1.17.4 - borked
Personally I’d like to see the changes made in Worker.SDK 1.17.* rolled back
Still the same issue on version
Microsoft.Azure.Functions.Worker.Sdk 1.17.4Running into the same issue in 5907 in a debian linux container
our container is based on
mcr.microsoft.com/dotnet/sdk:8.0which is pretty official…full in-container specification:
Run dotnet clean immediately prior to running the function did work, however.
macOS Sonoma 14.6.1 dotnet version 8.0.401 azure-functions-core-tools@4 4.0.5907
@dsschnau @dirkesquire Issue still active in version 4.0.5907 The code change from the merged PR is not in the latest release https://github.com/Azure/azure-functions-core-tools/blob/4.0.5907/src/Azure.Functions.Cli/Common/FileSystemHelpers.cs
The fix is here https://github.com/Azure/azure-functions-core-tools/pull/3773
Pretty annoying… I have lots of issues with Azure Functions on net8 in the last month or so…since net6 is going away.
#3773 aims to address this issue. The root problem is the cli is trying to recursively search for csproj’s as a pre-validation for calling
dotnet build. Instead, this validation can be removed entirely asdotnet buildwill perform its own validation.To reproduce the issue:
Existing projects and workspaces are fine. It’s just workspaces created with this version of VSCode:
Deleting the sln file resolves the issue but VSCode recreates it when opening the workspace and destroys the project.
@xandrw which packages specifically?
Delete
/binand/objfolders, downgrade packages until it works.@ryanzwe VS 2022 works smoothly but it becomes more annoying when one has to work by VS Code on macOS.
I have this issue in our .NET Aspire application. The workaround, deleting bin/obj, doesn’t work. I downgraded Microsoft.Azure.Functions.Worker.Sdk to 1.16.4, and I have this behavior with all the versions from 1.16.4 to the latest 1.17.4.
When I run the Azure function without .NET Aspire, it works fine.
Reading through these posts, I see that we are not alone in suffering from the horrible developer experience of Azure Functions. Our team works mostly with VS Code, and a little bit with Visual Studio. Both tools cannot even remotely offer the quality we are used to with other .NET technologies in development. “Blips” like this one will definitely get us to reevaluate our architecture design regarding serverless technologies.
till you fix it i create this workaround – in powershell
– in mac
I think it may have something to do with the C# dev kit extension creating a sln automatically, not necessarily OS
I have a .net8 iso app that has this issue and a .net6 in-proc app that doesn’t have it. Can’t say for certain it doesnt happen on in-proc but at least on mine it doesn’t.
I don’t wish to be mean, but I wonder who decided it would be a good idea to create \obj\Debug\net8.0\WorkerExtensions\WorkerExtensions.csproj on each build. I hope Azure Functions team seriously re-evaluates if this is indeed the route they want to be going in. I appreciate the hard work in separating out various workers, but there must be a better solution, surely. Perhaps this can be fixed in V5 on Azure Function Tools.
Error messages like:
obj/Debug/net8.0/WorkerExtensions/WorkerExtensions.csproj" was not foundif .sln file is present (which gets automatically created) and running ‘dotnet build’. Error messages like:Can't determine Project to build. Expected 1 .csproj or .fsproj but found 2.if deleting the .sln file and running ‘func start’ twice in a row.It just seems such an anti-pattern (one .csproj project creating another .csproj project), and completely confuses everything. Solution (.sln) files being automatically created, needing to delete /bin and /obj folders on each run. VS Code now can’t debug anymore. Azure pipeline broke since there are two projects detected. Azure functions just seems a complete mess now. I must admit we are trying to upgrade from Azure Functions V1 which worked perfectly.
.net 8.0.301, func tools 4.0.1, worker sdk 1.17.4, C# project.
P.S. I’ve noticed that downgrading to the Worker.SDK 1.16.4 resolves this issue:
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />Same issue here! Of course, deleting bin and obj works (in my case, deleting obj is enough, since the second .csproj file is located in ./obj/Debug/net8.0/WorkerExtensions/WorkerExtensions.csproj), but this is no real solution as stated by others.
Please fix, MS!
Thanks @ryanzwe , this issue is already handled here : https://github.com/Azure/azure-functions-core-tools/issues/3602