angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Cannot use same target name in angular.json for multiple projects

Open EricABC opened this issue 8 years ago • 8 comments

Bug Report or Feature Request (mark with an x)

- [ X ] bug report

Command (mark with an x)

- [ X ] build
- [ X ] serve

Versions

7.0.0-beta.3 and 4.

Repro steps

Using an angular.json with multiple projects sharing the target name (ie, 'serve' and 'build' under the 'architect' node) will cause this error, even when specifying the project (ie. not a multiTarget). A recent change here caused this regression. It will give the error 'Could not determine a single project for the 'serve' target.' from within the call to getProjectNamesByTarget(), even though I have specified the project.

  "projects": {
    "stuff": {
      "architect": {
        "build": {

        }
      }
    },
    "morestuff": {
      "architect": {
        "build": {

The log given by the failure

Error: Could not determine a single project for the 'serve' target. at ServeCommand.getProjectNamesByTarget (/Stuff/Spore/Typescript/node_modules/@angular/cli/models/architect-command.js:167:19) at ServeCommand.initialize (/Stuff/Spore/Typescript/node_modules/@angular/cli/models/architect-command.js:75:39) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:746:11) at startup (internal/bootstrap/node.js:238:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

Desired functionality

Ability to still use the same target names, 'build', 'serve', etc... across numerous projects in the same angular.json. A workaround is to use unique names.

EricABC avatar Sep 20 '18 11:09 EricABC

The error Could not determine a single project for the 'serve' target. is indicated that it cannot locate a single project when you use build and run. Thus in order to use the these builders you'd need to provide the project name as an argument.

Ex;

$ ng serve morestuff 

alan-agius4 avatar Sep 20 '18 11:09 alan-agius4

Yup. This error occurs even when that is done.

EricABC avatar Sep 20 '18 11:09 EricABC

@alan-agius4 can you please reopen?

EricABC avatar Sep 20 '18 11:09 EricABC

I checked a bit regarding this, and it seems it happens when you don't have a defaultProject set.

alan-agius4 avatar Sep 20 '18 11:09 alan-agius4

I can, if you give me a min. getProjectNamesByTarget() is designed to get the default project for all non multiTargets (which this is). target will be set to 'build' or 'serve' and there is no check to see if targetSpec.project is set.

EricABC avatar Sep 20 '18 11:09 EricABC

err...ya, ok ill skip the repro unless you poke me again.

EricABC avatar Sep 20 '18 11:09 EricABC

Oh, and its not the defaultProject, because I do have that set. (theres also another issue with that i think). Its that targetSpec.project.

EricABC avatar Sep 20 '18 11:09 EricABC

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.