@nx-dotnet/core
Version:
- Have an existing nx workspace. For creating this, see [nrwl's documentation](https://nx.dev/latest/angular/getting-started/nx-setup). - .NET SDK is installed, and `dotnet` is available on the path. For help on this, see [Microsoft's documentation](https
70 lines (51 loc) • 1.87 kB
Markdown
## Prerequisites
- Have an existing nx workspace. For creating this, see [nrwl's documentation](https://nx.dev/latest/angular/getting-started/nx-setup).
- .NET SDK is installed, and `dotnet` is available on the path. For help on this, see [Microsoft's documentation](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install)
## Installation
### NPM
```shell
npm i --save-dev -dotnet/core
npx nx g -dotnet/core:init
```
### PNPM
```shell
pnpm i --save-dev -dotnet/core
pnpx nx g -dotnet/core:init
```
### Yarn
```shell
yarn add --dev -dotnet/core
npx nx g -dotnet/core:init
```
## Generate and run your first api!
Generate my-api, and my-api-test with C# and nunit tests.
```shell
npx nx g -dotnet/core:app my-api --test-template nunit --language C#
```
Run my-api locally
```shell
npx nx serve my-api
```
## nrwl/nx/enforce-module-boundaries support
Nrwl publishes an eslint rule for enforcing module boundaries based on tags in a library. We recently added similar support to nx-dotnet.
To avoid duplicating the rules configuration, if your workspace already has it, nx-dotnet can read the dependency constraints from your workspace's eslint files. It does this by looking at what is configured for typescript files.
If your workspace does not currently contain eslint, do not worry! You do not have to install eslint just for its configuration. The same dependency constraints can be placed inside of your .nx-dotnet.rc.json file at workspace root. This should look something like below:
```json
{
"moduleBoundaries": [
{
"onlyDependOnLibsWithTags": ["a", "shared"],
"sourceTag": "a"
},
{
"onlyDependOnLibsWithTags": ["b", "shared"],
"sourceTag": "b"
},
{
"onlyDependOnLibsWithTags": ["shared"],
"sourceTag": "shared"
}
],
"nugetPackages": {}
}
```