Skip to content

Commit 53bdc17

Browse files
authored
fix(core): fall back to root if source root null (#408)
1 parent 035675e commit 53bdc17

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

packages/core/src/generators/restore/generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export default async function (
1212
dotnetClient = new DotNetClient(dotnetFactory()),
1313
) {
1414
const projects = await getNxDotnetProjects(host);
15-
for (const project of projects.values()) {
16-
const projectFiles = getProjectFilesForProject(host, project);
15+
for (const [projectName, project] of projects.entries()) {
16+
const projectFiles = getProjectFilesForProject(host, project, projectName);
1717
for (const file of projectFiles) {
1818
dotnetClient.restorePackages(file);
1919
}

packages/core/src/generators/sync/generator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export default async function (host: Tree) {
1818
const projects = await getNxDotnetProjects(host);
1919

2020
for (const [projectName, configuration] of projects.entries()) {
21-
const projectFiles = getProjectFilesForProject(host, configuration);
21+
const projectFiles = getProjectFilesForProject(
22+
host,
23+
configuration,
24+
projectName,
25+
);
2226
for (const f of projectFiles) {
2327
const xmldoc = readXml(host, f);
2428
console.log(`Scanning packages for ${projectName} (${f})`);

packages/core/src/generators/utils/update-dependency-version.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export async function updateDependencyVersions(
1414
) {
1515
const projects = await getNxDotnetProjects(host);
1616
for (const [projectName, configuration] of projects.entries()) {
17-
const projectFiles = getProjectFilesForProject(host, configuration);
17+
const projectFiles = getProjectFilesForProject(
18+
host,
19+
configuration,
20+
projectName,
21+
);
1822
for (const f of projectFiles) {
1923
const xmldoc = readXml(host, f);
2024
let updateFile = false;

packages/utils/src/lib/utility-functions/workspace.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ export async function getNxDotnetProjects(
115115
export function getProjectFilesForProject(
116116
host: Tree,
117117
project: ProjectConfiguration | undefined,
118+
projectName: string,
118119
) {
119-
if (!project?.sourceRoot) {
120-
throw new Error('Unable to read source root for project!');
120+
if (!project?.sourceRoot && !project?.root) {
121+
throw new Error(`Unable to read source root for project ${projectName}`);
121122
}
122123
return host
123-
.children(project.sourceRoot)
124+
.children(project.sourceRoot ?? project.root)
124125
.filter((x) => x.endsWith('proj'))
125126
.map((x) => `${project.sourceRoot}/${x}`);
126127
}

0 commit comments

Comments
 (0)