Skip to content

Commit 2ec5de9

Browse files
committed
feat(core): check for .net sdk install on package add (#212)
1 parent 4efe39a commit 2ec5de9

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

e2e/core-e2e/tests/nx-dotnet.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ import { ensureDirSync } from 'fs-extra';
2424
const e2eDir = 'tmp/nx-e2e/proj';
2525

2626
describe('nx-dotnet e2e', () => {
27+
beforeAll(() => {
28+
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');
29+
}, 1500000);
30+
2731
it('should create apps, libs, and project references', async () => {
2832
const testApp = uniq('app');
2933
const testLib = uniq('lib');
30-
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');
3134

3235
await runNxCommandAsync(
3336
`generate @nx-dotnet/core:app ${testApp} --language="C#" --template="webapi"`,
@@ -47,7 +50,6 @@ describe('nx-dotnet e2e', () => {
4750
it('should work with affected', async () => {
4851
const testApp = uniq('app');
4952
const testLib = uniq('lib');
50-
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');
5153

5254
await runNxCommandAsync(
5355
`generate @nx-dotnet/core:app ${testApp} --language="C#" --template="webapi"`,
@@ -209,7 +211,6 @@ describe('nx-dotnet e2e', () => {
209211
const testApp = uniq('app');
210212
const testLib = uniq('lib');
211213
const testAppTest = `${testApp}-test`;
212-
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');
213214
const appDir = `${e2eDir}/apps/${testApp}`;
214215
const testAppDir = `${e2eDir}/apps/${testAppTest}`;
215216
const libDir = `${e2eDir}/libs/${testLib}`;

packages/core/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"generators": "./generators.json",
55
"builders": "./executors.json",
66
"private": false,
7+
"scripts": {
8+
"postinstall": "node ./src/tasks/post-install"
9+
},
710
"dependencies": {},
811
"homepage": "https://nx-dotnet.com/docs/core",
912
"bugs": {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { DotNetClient, dotnetFactory } from '@nx-dotnet/dotnet';
2+
3+
try {
4+
const client = new DotNetClient(dotnetFactory());
5+
const sdkVersion = client.printSdkVersion();
6+
console.info(
7+
`[nx-dotnet] .NET SDK ${sdkVersion} will be used for .NET CLI commands`,
8+
);
9+
} catch {
10+
console.warn(`[nx-dotnet] [WARN] .NET SDK NOT FOUND`);
11+
}

0 commit comments

Comments
 (0)