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 --version reveals 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 start works.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 41
  • Comments: 55 (13 by maintainers)

Commits related to this issue

Most upvoted comments

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

Thanks to @ryanski44 for contributing the fix for this issue. We will provide an update in this thread when a new version of the core tools, including this change, becomes available.

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.

  • When will this pull request be reviewed?
  • What release would this fix get included in?

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.

dotnet clean & func start -p 1234

Had this issue as well due to the same cause with Microsoft.Azure.Functions.Worker.Sdk version 1.17.0. Looks like the latest version of the package resolves this issue though. Deleting the current bin/obj directories and then updating Microsoft.Azure.Functions.Worker.Sdk to 1.17.2 resolves this issue.

I can confirm this happens when upgrading Microsoft.Azure.Functions.Worker.Sdk from 1.16.4 to 1.17.0.

Details:

  • .NET SDK 8.0.200
  • func --version version 4.0.5530

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.4

Running into the same issue in 5907 in a debian linux container

our container is based on mcr.microsoft.com/dotnet/sdk:8.0 which is pretty official…

full in-container specification:

vscode@91376dec6507:/workspaces/repo-name$ func --version
4.0.5907
vscode@91376dec6507:/workspaces/repo-name$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
vscode@91376dec6507:/workspaces/repo-name$ dotnet --info
.NET SDK:
 Version:           8.0.204
 Commit:            c338c7548c
 Workload version:  8.0.200-manifests.9f663350

Runtime Environment:
 OS Name:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.204/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.4
  Architecture: x64
  Commit:       2d7eea2529

.NET SDKs installed:
  8.0.204 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

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 as dotnet build will perform its own validation.

To reproduce the issue:

  • create new Azure Function App project using VSCode with HttpTrigger
  • new project works fine and function app runs locally
  • save project as workspace. SLN file appears in project directory.
  • at this point dotnet build is still working
  • run function app locally. VSCode fails to run the function app if the sln file is present.
  • project is now unusable. Cannot run function app locally, cannot run dotnet build. The sln file is around twice as big as existing sln files from previous versions of vscode. Its presence stop vscode working.

/usr/local/share/dotnet/sdk/8.0.100/NuGet.targets(399,5): error MSB3202: The project file “/Users/alistair/dev/test/TestFunction/obj/Debug/net8.0/WorkerExtensions/WorkerExtensions.csproj” was not found. [/Users/alistair/dev/test/TestFunction/TestFunction.sln]

Existing projects and workspaces are fine. It’s just workspaces created with this version of VSCode:

Version: 1.90.0 Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573 Date: 2024-06-04T19:34:44.157Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin x64 22.6.0

Deleting the sln file resolves the issue but VSCode recreates it when opening the workspace and destroys the project.

@xandrw which packages specifically?

Delete /bin and /obj folders, 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

function runAzurFunc {
    # clean
    dotnet clean

    # build and run
    func start
}
Set-Alias -Name zfunc  -Value runAzurFunc

– in mac

runAzurFunc() {
    # clean
    dotnet clean
    # build
    func start
}
alias zfunc=runAzurFunc

I think it may have something to do with the C# dev kit extension creating a sln automatically, not necessarily OS

Thanks for your patience. We are working on a fix for this issue.

Just to confirm, this issue is happening only for dotnet-isolated model function apps. Correct? If anyone else is seeing this issue in non-dotnet isolated apps, please share a minimal repro.

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 found if .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!

Adding to this issue.

  • dotnet-isolated V4 durable function
  • .NET SDK 8.0.201
  • func --version version 4.0.5530
  • There is only one .csproj file in the function app’s folder, but the function app is a part of a C# solution

Func start gives error ‘Can’t determine Project to build. Expected 1 .csproj or .fsproj but found 2’ If I delete /bin & /obj folder it builds, but fails to start function with: Could not load file or assembly 'Microsoft.Azure.WebJobs.Script.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c5b9424214e8f8c'. The system cannot find the file specified. .csproj <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <AzureFunctionsVersion>v4</AzureFunctionsVersion> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <PublishReadyToRun>true</PublishReadyToRun> <OutputType>Exe</OutputType> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <PackageReference Include="Azure.Data.Tables" Version="12.8.3" /> <PackageReference Include="Azure.Identity" Version="1.10.4" /> <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.1" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" /> <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" /> <PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.2" /> <PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.2.0" /> <PackageReference Include="Result.Net" Version="1.5.0" /> </ItemGroup> <ItemGroup>

Try restore manually, or install that package individually, had this happen before on a dependent package needing newtonsoft, installing newtonsoft directly fixed it.

Thanks @ryanzwe , this issue is already handled here : https://github.com/Azure/azure-functions-core-tools/issues/3602