Closed paul-hammant closed 2 years ago
@paul-hammant Can you provide a repo to reproduce this problem? The output of nx report
would also be helpful.
https://github.com/paul-hammant/TestProjectForNxDotNetIssue Is the repo I have just made for this issue.
Now, some new problems with that (Mac)
npm install --save-dev @nx-dotnet/core
npx nx g @nx-dotnet/core:lib my-lib
Complains about missing JSON file, offers three solutions, No. 3 picked:
npx nx init
Causes:
npm ERR! peer dep missing: @nrwl/devkit@>13.4.0-beta.1, required by @nx-dotnet/core@1.12.0
npm ERR! peer dep missing: @nrwl/workspace@>13.4.0-beta.1, required by @nx-dotnet/core@1.12.0
npm ERR! peer dep missing: @nrwl/tao@>13.4.0-beta.1, required by @nx-dotnet/core@1.12.0
npm ERR! extraneous: eslint-visitor-keys@2.1.0 /path/to/TestProjectForNxDotNetIssue/node_modules/eslint-utils/node_modules/eslint-visitor-keys
npm ERR! extraneous: glob-parent@5.1.2 /path/to/TestProjectForNxDotNetIssue/node_modules/fast-glob/node_modules/glob-parent
npm ERR! extraneous: type-fest@0.21.3 /path/to/TestProjectForNxDotNetIssue/node_modules/ansi-escapes/node_modules/type-fest
npm ERR! extraneous: escape-string-regexp@1.0.5 /path/to/TestProjectForNxDotNetIssue/node_modules/figures/node_modules/escape-string-regexp
nx init
Adds nx.json file and installs nx if not installed already
Options:
--help Show help [boolean]
--version Show version number [boolean]
Error: Command failed: npm ls
npm ERR! peer dep missing: @nrwl/devkit@>13.4.0-beta.1, required by @nx-dotnet/core@1.12.0
npm ERR! peer dep missing: @nrwl/workspace@>13.4.0-beta.1, required by @nx-dotnet/core@1.12.0
npm ERR! peer dep missing: @nrwl/tao@>13.4.0-beta.1, required by @nx-dotnet/core@1.12.0
npm ERR! extraneous: eslint-visitor-keys@2.1.0 /path/to/TestProjectForNxDotNetIssue/node_modules/eslint-utils/node_modules/eslint-visitor-keys
npm ERR! extraneous: glob-parent@5.1.2 /path/to/TestProjectForNxDotNetIssue/node_modules/fast-glob/node_modules/glob-parent
npm ERR! extraneous: type-fest@0.21.3 /path/to/TestProjectForNxDotNetIssue/node_modules/ansi-escapes/node_modules/type-fest
npm ERR! extraneous: escape-string-regexp@1.0.5 /path/to/TestProjectForNxDotNetIssue/node_modules/figures/node_modules/escape-string-regexp
at checkExecSyncError (child_process.js:790:11)
at execSync (child_process.js:863:15)
at Object.initHandler (/Users/paul/.npm/_npx/35411/lib/node_modules/nx/src/command-line/init.js:10:58)
at /Users/paul/.npm/_npx/35411/lib/node_modules/nx/src/command-line/nx-commands.js:187:140
at Generator.next (<anonymous>)
at fulfilled (/Users/paul/.npm/_npx/35411/lib/node_modules/nx/node_modules/tslib/tslib.js:115:62) {
status: 1,
signal: null,
output: [
null,
<Buffer 2f 56 6f 6c 75 6d 65 73 2f 4f 48 44 2f 73 63 6d 2f 6f 73 73 2f 54 65 73 74 50 72 6f 6a 65 63 74 46 6f 72 4e 78 44 6f 74 4e 65 74 49 73 73 75 65 0a e2 ... 7317 more bytes>,
<Buffer 6e 70 6d 20 45 52 52 21 20 70 65 65 72 20 64 65 70 20 6d 69 73 73 69 6e 67 3a 20 40 6e 72 77 6c 2f 64 65 76 6b 69 74 40 3e 31 33 2e 34 2e 30 2d 62 65 ... 802 more bytes>
],
pid: 35418,
stdout: <Buffer 2f 56 6f 6c 75 6d 65 73 2f 4f 48 44 2f 73 63 6d 2f 6f 73 73 2f 54 65 73 74 50 72 6f 6a 65 63 74 46 6f 72 4e 78 44 6f 74 4e 65 74 49 73 73 75 65 0a e2 ... 7317 more bytes>,
stderr: <Buffer 6e 70 6d 20 45 52 52 21 20 70 65 65 72 20 64 65 70 20 6d 69 73 73 69 6e 67 3a 20 40 6e 72 77 6c 2f 64 65 76 6b 69 74 40 3e 31 33 2e 34 2e 30 2d 62 65 ... 802 more bytes>
}
I carry on regardless. Hacker me makes the nx.json
file by hand again.
$ npx nx g @nx-dotnet/core:lib my-lib
> NX Could not find Nx modules in this workspace.
As noted in the readme, one of the prerequisites for nx-dotnet is that you are operating inside of an Nx workspace already. To get started with this, you can create a workspace with npx create-nx-workspace
.
Can you try inside an Nx workspace and see if you s till encounter issues?
Thanks for the reply.
Looking at the suggestions offered by npx create-nx-workspace
, I don't know which one to choose for a C# library with no UI and no web that will may to nuget not npm:
apps [an empty workspace with no plugins with a layout that works best for building apps] core [an empty workspace with no plugins set up to publish npm packages (similar to yarn workspaces)] ts [an empty workspace with the JS/TS plugin preinstalled] react [a workspace with a single React application] angular [a workspace with a single Angular application] next.js [a workspace with a single Next.js application] nest [a workspace with a single Nest application] express [a workspace with a single Express application] web components [a workspace with a single app built using web components] react-native [a workspace with a single React Native application] react-express [a workspace with a full stack application (React + Express)] angular-nest [a workspace with a full stack application (Angular + Nest)]
Advice?
I've chosen the first open and seen the command through to completion.
I the tried the nx-dotnet setup command again.
npx nx g @nx-dotnet/core:lib my-lib
> NX Could not find Nx modules in this workspace.
I tried npm install
, then the same command again getting the same result.
Did you cd
into your new workspace before running the command?
Oh. I see what you're saying. This is very complicated for a migration chore.
Maybe I should start over.
OK, all done. Seven or so commits - https://github.com/paul-hammant/TestProjectForNxDotNetIssue/commits/master
My understanding gap obviously. You have to create a NEW nx-dotnet project(s), then move in your legacy source code to fit that directory structure. Nx is opinionated so you have to stick with that directory structure as you carry on.
In short, migration of existing is SECONDARY to nx-dotnet setup for a buildable/testable .NET thing.
Key setup was:
npm install --save-dev @nx-dotnet/core
npx nx init
cd workspace
npm install
npx nx g @nx-dotnet/core:lib my-lib
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Clone repo with existing .NET library solution/proj. One that used
dotnet test
as it's build toolchain.Run
npx nx g @nx-dotnet/core:lib my-lib
within (per the README)Now, there's no mention of nx.json in the readme as an important step in the generation of a lib.
Hacker me makes it with nano/vim with contents of
{ }
and re-runs.npx nx g @nx-dotnet/core:lib my-lib
I would've though a generate target wouldn't need to "find" a build-able project within a directory it was allegedly generating.