Skip to content

Commit

Permalink
feat(core): check for .net sdk install on package add (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Oct 15, 2021
1 parent 4efe39a commit 2ec5de9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions e2e/core-e2e/tests/nx-dotnet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ import { ensureDirSync } from 'fs-extra';
const e2eDir = 'tmp/nx-e2e/proj';

describe('nx-dotnet e2e', () => {
beforeAll(() => {
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');
}, 1500000);

it('should create apps, libs, and project references', async () => {
const testApp = uniq('app');
const testLib = uniq('lib');
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');

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

await runNxCommandAsync(
`generate @nx-dotnet/core:app ${testApp} --language="C#" --template="webapi"`,
Expand Down Expand Up @@ -209,7 +211,6 @@ describe('nx-dotnet e2e', () => {
const testApp = uniq('app');
const testLib = uniq('lib');
const testAppTest = `${testApp}-test`;
ensureNxProject('@nx-dotnet/core', 'dist/packages/core');
const appDir = `${e2eDir}/apps/${testApp}`;
const testAppDir = `${e2eDir}/apps/${testAppTest}`;
const libDir = `${e2eDir}/libs/${testLib}`;
Expand Down
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"generators": "./generators.json",
"builders": "./executors.json",
"private": false,
"scripts": {
"postinstall": "node ./src/tasks/post-install"
},
"dependencies": {},
"homepage": "https://nx-dotnet.com/docs/core",
"bugs": {
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/tasks/post-install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DotNetClient, dotnetFactory } from '@nx-dotnet/dotnet';

try {
const client = new DotNetClient(dotnetFactory());
const sdkVersion = client.printSdkVersion();
console.info(
`[nx-dotnet] .NET SDK ${sdkVersion} will be used for .NET CLI commands`,
);
} catch {
console.warn(`[nx-dotnet] [WARN] .NET SDK NOT FOUND`);
}

0 comments on commit 2ec5de9

Please sign in to comment.