Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Creating new nx-dotnet library does not respect the specified path #801

Open
md-owes opened this issue Nov 11, 2023 · 1 comment
Open
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member

Comments

@md-owes
Copy link

md-owes commented Nov 11, 2023

Current Behavior

When i create a new library with the following command

nx g @nx-dotnet/core:lib --name Domain --tags fs --directory apps/FinancialService/src --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none

it creates the project structure under libs folder as specified below

libs/apps/financial-service/src/Domain

Expected Behavior

In earlier versions it used to respect the specified path and does not force a new dotnet library project under libs folder. So, i n earlier version with the same command

nx g @nx-dotnet/core:lib --name Domain --tags fs --directory apps/FinancialService/src --template jaamdom --language C# --skipSwaggerLib true --pathScheme dotnet --testTemplate none

the new project will be created under the following path

apps/financial-service/src/Domain

Github Repo

No response

Steps to Reproduce

  1. just create a new nx dotnet library using nx-dotnet 2.1.0 or higher and specify a path from the root directory using --directory flag

Nx Report

nx report

 >  NX   Its time to update Nx 🎉

   Your repository uses a higher version of Nx (17.1.1) than your global CLI version (16.10.0)
   For more information, see https://nx.dev/more-concepts/global-nx


 >  NX   Report complete - copy this into the issue template

   Node   : 20.8.0
   OS     : win32-x64
   npm    : 10.1.0

   nx (global)    : 16.10.0
   nx             : 17.1.1
   @nx/js         : 17.1.1
   @nx/linter     : 17.1.1
   @nx/eslint     : 17.1.1
   @nx/workspace  : 17.1.1
   @nx/devkit     : 17.0.2
   @nrwl/tao      : 17.1.1
   nx-cloud       : 16.5.2
   typescript     : 5.2.2
   ---------------------------------------
   Community plugins:
   @nx-dotnet/core : 2.1.1
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nx/devkit@17.0.2
     - @nrwl/devkit@17.0.2

   To fix this, run `nx migrate nx@17.1.1`

nx.json

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": [
          "build",
          "lint",
          "test",
          "e2e",
          "codegen",
          "swagger"
        ]
      }
    }
  },
  "targetDefaults": {
    "build": {
      "dependsOn": [
        "^build",
        "codegen",
        "^codegen"
      ],
      "inputs": [
        "production",
        "^production"
      ]
    },
    "lint": {
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/.eslintignore"
      ]
    },
    "test": {
      "inputs": [
        "default",
        "^production",
        "{workspaceRoot}/jest.preset.js"
      ]
    }
  },
  "namedInputs": {
    "default": [
      "{projectRoot}/**/*",
      "sharedGlobals"
    ],
    "production": [
      "default",
      "!{projectRoot}/.eslintrc.json",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/jest.config.[jt]s",
      "!{projectRoot}/src/test-setup.[jt]s",
      "!{projectRoot}/test-setup.[jt]s"
    ],
    "sharedGlobals": []
  },
  "plugins": [
    "@nx-dotnet/core"
  ]
}

Failure Logs

No response

Additional Information

Not all libraries have to be created under libs folder. nx g @nx-dotnet/core:lib command should respect the directory path specified from the root folder in order to give the user the ability to create libraries in their path of choice

@md-owes md-owes added bug Something isn't working needs-triage This issue has yet to be looked over by a core team member labels Nov 11, 2023
@sharky98
Copy link

sharky98 commented Jan 17, 2024

I would say that it is not a bug per se, but this behavior does not align with NX 17 new behavior (started on 16.8.0) on the directory: https://nx.dev/deprecated/as-provided-vs-derived.

nx-dotnet should still implement the new behavior.

In fact, this same "not implemented new behavior" is seen when creating a webapi that generate the swagger and types project, having the following warning, and having the project created at the root instead of the apps or libs directory.

In Nx 18, generating projects will no longer derive the name and root.
Please provide the exact project name and root in the future.
Example: nx g @nx/js:library generated-backend-types --directory generated/backend-types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member
Projects
None yet
Development

No branches or pull requests

2 participants