Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

Commit 4d51ea0

Browse files
authored
fix(core): process project graph shouldn't throw if not a .NET project (#390)
1 parent b921a4f commit 4d51ea0

4 files changed

Lines changed: 44 additions & 16 deletions

File tree

e2e/core-e2e/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
preset: '../../jest.preset.js',
44
globals: {
55
'ts-jest': {
6-
tsConfig: '<rootDir>/tsconfig.spec.json',
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
77
},
88
},
99
transform: {

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
ensureNxProject,
55
listFiles,
66
readFile,
7-
readJson,
87
runCommand,
98
runNxCommand,
109
runNxCommandAsync,
10+
runPackageManagerInstall,
1111
tmpProjPath,
1212
uniq,
1313
updateFile,
@@ -53,7 +53,19 @@ describe('nx-dotnet e2e', () => {
5353
it('should work with affected', async () => {
5454
const testApp = uniq('app');
5555
const testLib = uniq('lib');
56+
5657
runCommand('git checkout -b "affected-tests"');
58+
updateFile('package.json', (f) => {
59+
const json = JSON.parse(f);
60+
json.dependencies['@nrwl/angular'] = 'latest';
61+
return JSON.stringify(json);
62+
});
63+
runPackageManagerInstall();
64+
65+
await runNxCommandAsync(
66+
`generate @nrwl/angular:app ng-app --style css --routing false --no-interactive`,
67+
// { cwd: e2eDir, stdio: 'inherit' },
68+
);
5769

5870
await runNxCommandAsync(
5971
`generate @nx-dotnet/core:app ${testApp} --language="C#" --template="webapi"`,
@@ -70,7 +82,7 @@ describe('nx-dotnet e2e', () => {
7082
const deps = await readDependenciesFromNxDepGraph(join(e2eDir), testApp);
7183
expect(deps).toContain(testLib);
7284
runCommand('git checkout main');
73-
}, 150000);
85+
}, 300000);
7486

7587
describe('nx g app', () => {
7688
it('should obey dry-run', async () => {

packages/core/src/graph/process-project-graph.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,30 @@ function visitProject(
2929
project: ProjectConfiguration,
3030
projectName: string,
3131
) {
32-
const projectFile = getProjectFileForNxProjectSync(project);
33-
getDependantProjectsForNxProject(
34-
projectName,
35-
context.workspace,
36-
(config, dependencyName, implicit) => {
37-
if (implicit) {
38-
builder.addImplicitDependency(projectName, dependencyName);
39-
} else {
40-
builder.addExplicitDependency(projectName, projectFile, dependencyName);
41-
}
42-
},
43-
);
32+
let projectFile: string | null = null;
33+
34+
try {
35+
projectFile = getProjectFileForNxProjectSync(project);
36+
} catch (e) {
37+
if (process.env['NX_VERBOSE_LOGGING'] === 'true') {
38+
console.log(e);
39+
}
40+
}
41+
if (projectFile !== null) {
42+
getDependantProjectsForNxProject(
43+
projectName,
44+
context.workspace,
45+
(config, dependencyName, implicit) => {
46+
if (implicit) {
47+
builder.addImplicitDependency(projectName, dependencyName);
48+
} else {
49+
builder.addExplicitDependency(
50+
projectName,
51+
projectFile as string,
52+
dependencyName,
53+
);
54+
}
55+
},
56+
);
57+
}
4458
}

tools/scripts/e2e.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ async function runTest() {
4949
console.log('No tests to run');
5050
} else if (selectedProjects) {
5151
execSync(
52-
`yarn nx run-many --target=e2e --projects=${selectedProjects} ${testNamePattern}`,
52+
selectedProjects.split(',').length > 1
53+
? `yarn nx run-many --target=e2e --projects=${selectedProjects} ${testNamePattern}`
54+
: `yarn nx run ${selectedProjects}:e2e ${testNamePattern}`,
5355
{
5456
stdio: [0, 1, 2],
5557
env: {

0 commit comments

Comments
 (0)