0

I am running multiple C# Azure Functions in different instances of multi root projects, which have multiple libraries which feed a small number of projects which I all run manually & separately to avoid conflicts so this run without issue.

Now I want to create a new multi root which adds certain projects to run all at the same time, my issue is at present I am going through all the projects and running them separately and I want to make it easier and faster, but I can't find any information on how do do it.

I have a multi route folder, the code-workspace file is outside the folder structure, the .sln solution file is in one folder, and Azure Function projects are in most of the others with the exception of 3 folders which have class libraries, all folders have a sub folder of src holding all code and .csproj project files, all Azure Function folders have the vscode folders with the normal debugging config files.

I can add the configuration to the workspace file, with a list of the projects debugging names which starts them but then all I get is conflicts as they all access the same libraries from other projects

Any suggestions would be appreciated.

Edit:

My workspace structure is (the .code-workspace is outside of the workspace and one accessible in the filestructure without using a command to access it)

myworkspace.code-workspace

/MyWorkspace/
  /FunctionA/
    /src/
      FunctionA.csproj
    /.vscode/

  /FunctionB/
    /src/
      FunctionB.csproj
    /.vscode/

  /ClassLib/
    /src/
      ClassLib.csproj
    /.vscode/

  /Solution/
    MySolution.sln
8
  • you can look at semaphores, which will block every access to a function except for one, and that work over multiple instances Commented Apr 13 at 0:55
  • Sorry i don't understand what that means, i want to run all the azure functions in debug mode locally, all at the same time, there is a way to do it if theres no overlap in libraries but i can't do it if they access the same libraries Commented Apr 13 at 1:26
  • Why do you get library conflicts? Commented Apr 13 at 2:29
  • You first should define what you mean by library a dll or a datasource. a dll can be called multiple times, a datasource only allows access by one user(ok it is more complicated than taht, but for my purpose i take this assumption). so if you ave a resource that only should allow one use to access the resource at a time(this is also simplified) like a serial port, where only on process is allowed to use it. Commented Apr 13 at 10:55
  • i get library conflicts becuase when the workspace debug configuration runs, all projects get build at the same time, they all shared c# class libraries, so they all get hit at the same time, and i get x classlibrary is being used by another project Commented Apr 13 at 11:57

1 Answer 1

0

Note that, running multiple Azure Functions locally in VS Code that share class libraries can result in build conflicts when each function tries to compile the same DLL at the same time.

Alternatively, make use of a centralized build task and project-specific output paths to avoid locking issues and run all functions together smoothly.

A typical setup includes a multi-root workspace where different function apps reference a shared class library.

FunctionA uses ClassLib
FunctionB uses ClassLib

  • Each function contains its own .vscode folder and works independently, but when launched together, build conflicts may appear due to simultaneous access to the shared library.
error CS0433: The type 'SomeClass' exists in both 'ClassLib.dll' and 'ClassLib.dll'

To avoid this, use a solution file MySolution.sln that includes all projects. Build the solution once before debugging any functions using below.

dotnet build ./Solution/MySolution.sln

  • Check that all function projects and class libraries use unique output paths to prevent overwriting build artifacts.
<PropertyGroup>
  <OutputPath>bin\FunctionA\</OutputPath>
</PropertyGroup>

Define a workspace-level task in .vscode/tasks.json to centralize the build process:

{
  "label": "build-solution",
  "command": "dotnet",
  "type": "process",
  "args": [ "build", "${workspaceFolder}/Solution/MySolution.sln" ]
}

  • Use this task as a preLaunchTask in launch.json for each function app.
"preLaunchTask": "build-solution"

After setting up, all functions can be launched in parallel through a compound debug configuration, with shared libraries properly built and no conflicts during runtime.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, that sounds interesting will try it soon and let you know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.