Skip to content

Commit

Permalink
refactor: fix up PackableProjectsToMSBuildProject; Targets to Target
Browse files Browse the repository at this point in the history
  • Loading branch information
BinToss committed Aug 14, 2024
1 parent 9c7bd07 commit 4fbe86f
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions src/dotnet/MSBuildProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class EvaluationOptions {
{
FullName: "string",
SetProperties: type({ "[string]": "string" }),
Targets: "string[]",
Target: "string[]",
GetItems: "string[]",
GetProperties: "string[]",
GetTargetResults: "string[]"
Expand All @@ -124,9 +124,10 @@ class EvaluationOptions {
this.Properties = opts.SetProperties;
this.GetItem = opts.GetItems;
this.GetProperty = opts.GetProperties;
this.Target = opts.Targets;
this.Target = opts.Target;
this.GetTargetResults = opts.GetTargetResults;
}

/**
* The project file's full path.
*/
Expand Down Expand Up @@ -306,37 +307,37 @@ export class MSBuildProject {
return dirEntries.flat();
}

const projects: Promise<MSBuildProject>[] = await toDirEntries(projectsToPackAndPush)
.then((dirents) => {
return dirents.map(async (v): Promise<MSBuildProject> => {
const fullPath = join(v.parentPath, v.name);
const projTargets: Promise<string[]> = MSBuildProject.getTargets(fullPath, false); // TODO. should return a string[]. Option to exclude underscored targets?
// this might be too long for a command line. What was is on Windows?
// 2^15 (32,768) character limit for command lines?
const getProperties = getOwnPropertyDescriptors(/* enumerate getters (own and inherited) */
NugetProjectProperties, true, true
).map(
o => Object.entries(o)
).flat().filter(/* if predicate is true, e is a getter */
e => typeof e[1].get === "function" && e[0] !== '__proto__'
).map(/* return the getter's name (the MSBuild property name) */
v => v[0])
const options = new EvaluationOptions({
FullName: fullPath,
GetItems: [],
GetProperties: getProperties,
GetTargetResults: [],
SetProperties: {},
Targets: await projTargets.then(v => v.includes("Pack") ? ["Pack"] : [])
});
return new MSBuildProject({
fullPath,
projTargets: await projTargets,
evaluation: await MSBuildProject.Evaluate(options)
});
}
);
});
return Promise.all(projects);
return Promise.all(
await toDirEntries(projectsToPackAndPush)
.then(direntArr =>
direntArr.map(async (dirent): Promise<MSBuildProject> => {
const fullPath = join(dirent.parentPath, dirent.name)
const projTargets: Promise<string[]> = MSBuildProject.getTargets(fullPath, false)
// this might be too long for a command line. What was is on Windows?
// 2^15 (32,768) character limit for command lines?
const getProperties = getOwnPropertyDescriptors(
NugetProjectProperties, true, true
).map(
o => Object.entries(o)
).flat().filter(// if predicate is true, e is a getter
e => typeof e[1].get === "function" && e[0] !== '__proto__'
).map(// return the getter's name (the MSBuild property name)
v => v[0]
)
return await this.Evaluate(
new EvaluationOptions(
{
FullName: fullPath,
GetItems: [],
GetProperties: getProperties,
GetTargetResults: [],
SetProperties: {},
Target: await projTargets.then(v => v.includes("Pack") ? ["Pack"] : []),
}
)
)
})
)
);
}
}
}

0 comments on commit 4fbe86f

Please sign in to comment.