Is it possible to manage multiple apps in 1 project?

i’ve done dfx new project1
and dfx new project2

then i copied the frontend+backend from project2 into project1
and copied the canister configs from project2’s dfx.json into project1’s.

when i tried to deploy them all, it failed at the dfx generate part, failing to build any candid files.

any idea?

Replica API running in the background on 127.0.0.1:4943
Deploying all canisters.
project1_backend canister created with canister id: uqqxf-5h777-77774-qaaaa-cai
project1_frontend canister created with canister id: uxrrr-q7777-77774-qaaaq-cai
project2_backend canister created with canister id: u6s2n-gx777-77774-qaaba-cai
project2_frontend canister created with canister id: uzt4z-lp777-77774-qaabq-cai
Building canister 'project2_backend'.
Building canister 'project2_frontend'.
Building canister 'project1_backend'.
Building canister 'project1_frontend'.
Error: Failed while trying to deploy canisters.
Caused by: Failed to build all canisters.
Caused by: Failed while trying to build all canisters.
Caused by: The post-build step failed for canister 'uzt4z-lp777-77774-qaabq-cai' (project2_frontend)
Caused by: Failed to build frontend for network 'local'.
Caused by: The command 'cd "/Projects/project1" && CANISTER_CANDID_PATH="/Projects/project1/.dfx/local/canisters/project2_frontend/assetstorage.did" CANISTER_CANDID_PATH_PROJECT2_BACKEND="/Projects/project1/.dfx/local/canisters/project2_backend/project2_backend.did" CANISTER_ID="uzt4z-lp777-77774-qaabq-cai" CANISTER_ID_PROJECT1_BACKEND="uqqxf-5h777-77774-qaaaa-cai" CANISTER_ID_PROJECT1_FRONTEND="uxrrr-q7777-77774-qaaaq-cai" CANISTER_ID_PROJECT2_BACKEND="u6s2n-gx777-77774-qaaba-cai" CANISTER_ID_PROJECT2_FRONTEND="uzt4z-lp777-77774-qaabq-cai" DFX_NETWORK="local" DFX_VERSION="0.29.2" "npm" "run" "build" "--workspace" "project2_frontend"' failed with exit status 'exit status: 255'.
Stdout:

> project2_frontend@0.0.0 prebuild
> dfx generate


Stderr:
WARN: .did file for canister 'project1_frontend' does not exist.
Building canister 'project1_backend'.
Building canister 'project2_backend'.
Generated type declarations for canister 'project2_frontend' to '/Projects/project1/src/declarations/project2_frontend'
Generated type declarations for canister 'project2_backend' to '/Projects/project1/src/declarations/project2_backend'
Error: Failed while trying to generate type declarations for 'project1_frontend'.
Caused by: Candid file: /Projects/project1/.dfx/local/canisters/project1_frontend/assetstorage.did doesn't exist.
npm error Lifecycle script `build` failed with error:
npm error code 255
npm error path /Projects/project1/src/project2_frontend
npm error workspace project2_frontend@0.0.0
npm error location /Projects/project1/src/project2_frontend
npm error command failed
npm error command sh -c dfx generate

A few months back I discovered the same problem and decided I won’t fix it because it’s very hard to fix generally, and nobody ever reported that issue on the forum :melting_face:

If you look at the files src/project<1/2>_frontend/package.json you will find "prebuild": "dfx generate". This line generates bindings for all canisters, which in turn requires that all canisters have been built before (or a .did file is available outside of the build, which is not the case for asset canisters). Effectively this means that frontend1 can only build if frontend2 has been built, and frontend2 can only build if frontend1 has been built.

If you change the prebuild step to "prebuild": "dfx generate project<1/2>_backend" the frontend build will only depend on that specific canister having been built before, and you should be able to build both frontends. If the frontends ever start depending on more canisters you can add them there, dfx generate can handle a list of canisters