@halospv3/hce.shared-config 3.4.7 → 3.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +25 -4
  2. package/mjs/CaseInsensitiveMap.mjs +27 -1
  3. package/mjs/CaseInsensitiveMap.mjs.map +1 -1
  4. package/mjs/commitlintConfig.mjs +13 -1
  5. package/mjs/commitlintConfig.mjs.map +1 -1
  6. package/mjs/debug.mjs +8 -1
  7. package/mjs/debug.mjs.map +1 -1
  8. package/mjs/dotnet/GithubNugetRegistryInfo.mjs +39 -1
  9. package/mjs/dotnet/GithubNugetRegistryInfo.mjs.map +1 -1
  10. package/mjs/dotnet/GitlabNugetRegistryInfo.mjs +81 -1
  11. package/mjs/dotnet/GitlabNugetRegistryInfo.mjs.map +1 -1
  12. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs +42 -1
  13. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs.map +1 -1
  14. package/mjs/dotnet/MSBuildProject.mjs +345 -2
  15. package/mjs/dotnet/MSBuildProject.mjs.map +1 -1
  16. package/mjs/dotnet/MSBuildProjectProperties.mjs +233 -1
  17. package/mjs/dotnet/MSBuildProjectProperties.mjs.map +1 -1
  18. package/mjs/dotnet/NugetProjectProperties.mjs +520 -1
  19. package/mjs/dotnet/NugetProjectProperties.mjs.map +1 -1
  20. package/mjs/dotnet/NugetRegistryInfo.mjs +599 -3
  21. package/mjs/dotnet/NugetRegistryInfo.mjs.map +1 -1
  22. package/mjs/dotnet/helpers.mjs +222 -1
  23. package/mjs/dotnet/helpers.mjs.map +1 -1
  24. package/mjs/dotnet/index.mjs +9 -1
  25. package/mjs/dotnet.mjs +9 -1
  26. package/mjs/eslintConfig.mjs +97 -1
  27. package/mjs/eslintConfig.mjs.map +1 -1
  28. package/mjs/index.mjs +2 -1
  29. package/mjs/insertPlugins.mjs +35 -1
  30. package/mjs/insertPlugins.mjs.map +1 -1
  31. package/mjs/semanticReleaseConfig.mjs +63 -1
  32. package/mjs/semanticReleaseConfig.mjs.map +1 -1
  33. package/mjs/semanticReleaseConfigDotnet.mjs +223 -6
  34. package/mjs/semanticReleaseConfigDotnet.mjs.map +1 -1
  35. package/mjs/setupGitPluginSpec.default.mjs +18 -2
  36. package/mjs/setupGitPluginSpec.default.mjs.map +1 -1
  37. package/mjs/setupGitPluginSpec.mjs +108 -1
  38. package/mjs/setupGitPluginSpec.mjs.map +1 -1
  39. package/mjs/utils/Exact.d.mts +10 -10
  40. package/mjs/utils/Exact.d.mts.map +1 -1
  41. package/mjs/utils/env.mjs +39 -1
  42. package/mjs/utils/env.mjs.map +1 -1
  43. package/mjs/utils/execAsync.mjs +54 -7
  44. package/mjs/utils/execAsync.mjs.map +1 -1
  45. package/mjs/utils/isError.mjs +17 -1
  46. package/mjs/utils/isError.mjs.map +1 -1
  47. package/mjs/utils/miscTypes.mjs +7 -1
  48. package/mjs/utils/miscTypes.mjs.map +1 -1
  49. package/mjs/utils/reflection/filterForGetters.mjs +25 -1
  50. package/mjs/utils/reflection/filterForGetters.mjs.map +1 -1
  51. package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs +27 -1
  52. package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs.map +1 -1
  53. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs +34 -1
  54. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs.map +1 -1
  55. package/mjs/utils/reflection/getPrototypeChainOf.mjs +39 -1
  56. package/mjs/utils/reflection/getPrototypeChainOf.mjs.map +1 -1
  57. package/mjs/utils/reflection/getPrototypeOf.mjs +12 -1
  58. package/mjs/utils/reflection/getPrototypeOf.mjs.map +1 -1
  59. package/mjs/utils/reflection/inheritance.mjs +10 -1
  60. package/mjs/utils/reflection/inheritance.mjs.map +1 -1
  61. package/mjs/utils/reflection/isConstructor.mjs +30 -1
  62. package/mjs/utils/reflection/isConstructor.mjs.map +1 -1
  63. package/mjs/utils/reflection/isGetterDescriptor.mjs +13 -1
  64. package/mjs/utils/reflection/isGetterDescriptor.mjs.map +1 -1
  65. package/mjs/utils/reflection/listOwnGetters.mjs +29 -1
  66. package/mjs/utils/reflection/listOwnGetters.mjs.map +1 -1
  67. package/mjs/utils/reflection.mjs +10 -1
  68. package/package.json +17 -43
  69. package/src/utils/Exact.d.ts +17 -0
  70. package/mjs/utils/Exact.mjs +0 -2
  71. package/mjs/utils/Exact.mjs.map +0 -1
  72. package/src/utils/Exact.ts +0 -49
@@ -1,3 +1,346 @@
1
- import{CaseInsensitiveMap as e}from"../CaseInsensitiveMap.mjs";import{isError as t}from"../utils/isError.mjs";import{execAsync as n}from"../utils/execAsync.mjs";import{MSBuildProjectProperties as r}from"./MSBuildProjectProperties.mjs";import{NPPGetterNames as i,NugetProjectProperties as a}from"./NugetProjectProperties.mjs";import{warn as o}from"node:console";import{type as s}from"arktype";import*as c from"node:path";import{readdir as l,realpath as u,stat as d}from"node:fs/promises";import{setTimeout as f}from"node:timers/promises";const p=s({"[string]":`string`,Identity:`string`,"SubType?":`string`,"TargetFrameworkIdentifier?":`string`,"TargetPlatformMoniker?":`string`,"CopyUpToDateMarker?":`string`,"TargetPlatformIdentifier?":`string`,"TargetFrameworkVersion?":`string`,"ReferenceAssembly?":`string`,FullPath:`string`,RootDir:`string`,Filename:`string`,Extension:`string`,RelativeDir:`string`,Directory:`string`,RecursiveDir:`string`,ModifiedTime:`string`,CreatedTime:`string`,AccessedTime:`string`,DefiningProjectFullPath:`string`,DefiningProjectDirectory:`string`,DefiningProjectName:`string`,DefiningProjectExtension:`string`}),m=s({Result:`'Success'`,Items:p.array()}),h=s({Result:`'Failure'`,Items:`never[]`}),g=s({"Properties?":s({"[string]":`string`}),"Items?":s({"[string]":p.array()}),"TargetResults?":s({"[string]":m.or(h)})});var _=class{constructor(e){let t=g.assert(typeof e==`string`?JSON.parse(e):e);this.Properties=t.Properties,this.Items=t.Items,this.TargetResults=t.TargetResults}Properties;Items;TargetResults};const v=Object.freeze(s({FullName:`string`,Property:s({"[string]":`string`}).as().partial(),Targets:s.string.array().readonly().or(`string[]`),GetItem:s.string.array().readonly().or(`string[]`),GetProperty:s.string.array().readonly().or(`string[]`),GetTargetResult:s.string.array().readonly().or(`string[]`)}));var y=class t{static MatrixProperties=Object.freeze([`TargetFramework`,`TargetFrameworks`,`RuntimeIdentifier`,`RuntimeIdentifiers`]);constructor(t){this.Items=t.evaluation.Items??{},this.Properties=new a(t.fullPath,new e(Object.entries(t.evaluation.Properties??{}))),this.Targets=t.projTargets,this.TargetResults=t.evaluation.TargetResults===void 0?[]:[t.evaluation.TargetResults]}Items;Properties;Targets;TargetResults;static async GetTargets(e,t=!1){return n(`dotnet msbuild ${e} -targets`,!0).then(e=>{let n=e.stdout.split(`
2
- `).filter((e,t)=>e!==``&&t!==0).map(e=>e.replaceAll(`\r`,``)).sort((e,t)=>e.localeCompare(t));return t?n:n.filter(e=>!e.startsWith(`_`))})}static async Evaluate(e){if(e.GetProperty.length===0&&e.GetItem.length===0&&e.GetTargetResult.length===0)throw Error(`No MSBuild Property, Item, or TargetResult queries were provided.`);e.FullName=r.GetFullPath(e.FullName);let i=Object.entries(e.Property).filter(e=>typeof e[1]==`string`),a=i.length===0?``:`-p:"${i.map(e=>e[0]+`=`+e[1]).join(`;`)}"`,s=e.Targets.length===0?``:`"-t:${e.Targets.join(`;`)}"`,c=e.GetItem.length===0?``:`-getItem:"${e.GetItem.join(`,`)}"`,l=e.GetProperty.length===0?``:`-getProperty:"${e.GetProperty.join(`,`)}"`,u=e.GetTargetResult.length===0?``:`-getTargetResult:"${e.GetTargetResult.join(`,`)}"`,d=[`dotnet`,`msbuild`,`"${e.FullName}"`,`-restore`,a,s,c,l,u].filter(e=>e!==``).join(` `),p;for(;p===void 0;)p=await f(1e3,n(d,!0)).then(async e=>await e).catch(T);if(p.stdout.startsWith(`MSBuild version`))throw o(p.stdout),Error(`dotnet msbuild was expected to output JSON, but output its version header instead.`);let m;if(p.stdout.startsWith(`{`))m=p.stdout;else if(e.GetProperty.length>0&&e.GetProperty[0]!==void 0)m={Properties:{[e.GetProperty[0]]:String(JSON.parse(p.stdout))}};else throw Error(`Dotnet/MSBuild evaluation output is not a string nor JSON object or array.`);let h=new _(m);return new t({fullPath:e.FullName,projTargets:await t.GetTargets(e.FullName),evaluation:h})}static async PackableProjectsToMSBuildProjects(e){return await n(typeof e==`string`?[e]:e).then(e=>e.map(e=>r(e)));async function n(e){return(await Promise.all(e.map(async e=>{e=await u(w(e));let t=await d(e),n;if(t.isFile()){n=await l(c.dirname(e),{withFileTypes:!0});let t=n.find(t=>c.join((`path`in t?t.path:void 0)??t.parentPath,t.name)===e);if(t)return t;throw Error(`file "${e}" not found. It may have been moved or deleted.`)}if(!t.isDirectory())throw Error(`"${e}" is not a file or directory`);return n=await l(e,{withFileTypes:!0}),n.filter(e=>e.isFile()&&(e.name.endsWith(`.csproj`)||e.name.endsWith(`.fsproj`)||e.name.endsWith(`.vbproj`)))}))).flat()}async function r(e){let n=c.join((`path`in e?e.path:void 0)??e.parentPath,e.name),r=await t.GetTargets(n).then(e=>e.includes(`Pack`)?[`Pack`]:[]),a=i.InstanceGettersRecursive;return await t.Evaluate(v.from({FullName:n,GetItem:[],GetProperty:a,GetTargetResult:[],Property:{},Targets:r}))}}static fromJSON(e){let n=S.assert(JSON.parse(e));return s.true.assert(Reflect.setPrototypeOf(n,t.prototype)),s.true.assert(Reflect.setPrototypeOf(n.Properties,a.prototype)),n.Properties=x.assert(n.Properties),b.assert(n)}};const b=s.instanceOf(y),x=s.instanceOf(a),S=s({Items:s({"[string]":s({"[string]":`string`,Identity:`string`,FullPath:`string`,RootDir:`string`,Filename:`string`,Extension:`string`,RelativeDir:`string`,Directory:`string`,RecursiveDir:`string`,ModifiedTime:`string`,CreatedTime:`string`,AccessedTime:`string`,DefiningProjectFullPath:`string`,DefiningProjectDirectory:`string`,DefiningProjectName:`string`,DefiningProjectExtension:`string`,"SubType?":` string | undefined`,"TargetFrameworkIdentifier?":`string | undefined`,"TargetPlatformMoniker?":`string | undefined`,"CopyUpToDateMarker?":`string | undefined`,"TargetPlatformIdentifier?":`string | undefined`,"TargetFrameworkVersion?":`string | undefined`,"ReferenceAssembly?":`string | undefined`}).array()}),Properties:s.Record(`string`,`string`).or(x),Targets:s.string.array(),TargetResults:g.get(`TargetResults`).exclude(`undefined`).array()}),C=s.scope({msbuildEvaluationOutput:g});function w(e){return c.isAbsolute(e)?e:c.resolve(e)}function T(e){if(t(e))if(`stderr`in e&&typeof e.stderr==`string`){let t=e.stderr.normalize(`NFKC`),n=/The process cannot access the file '[^']+' because it is being used by another process\./gm.test(t),r=/^CSC ?:.+CS2012:/gm.test(t),i=/AVLN9999:/gm.test(t)&&n;if(r||i||n)return}else throw e;else throw Error(`unknown error`,{cause:e})}function E(e){if(t(e)){if(`stderr`in e&&typeof e.stderr==`string`&&/^CSC ?:.+CS2012:/gm.test(e.stderr.normalize(`NFKC`)))return;throw e}else throw Error(`unknown error`,{cause:e})}export{v as EvaluationOptions,_ as MSBuildEvaluationOutput,y as MSBuildProject,C as _InternalMSBuildEvaluationTypes,E as catchCsc2012,T as catchEBUSY};
1
+ import { CaseInsensitiveMap } from "../CaseInsensitiveMap.mjs";
2
+ import { isError } from "../utils/isError.mjs";
3
+ import { execAsync } from "../utils/execAsync.mjs";
4
+ import { MSBuildProjectProperties } from "./MSBuildProjectProperties.mjs";
5
+ import { NPPGetterNames, NugetProjectProperties } from "./NugetProjectProperties.mjs";
6
+ import { warn } from "node:console";
7
+ import { type } from "arktype";
8
+ import * as path from "node:path";
9
+ import { readdir, realpath, stat } from "node:fs/promises";
10
+ import { setTimeout } from "node:timers/promises";
11
+ //#region src/dotnet/MSBuildProject.ts
12
+ /**
13
+ * See [MSBuild well-known item metadata](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata).
14
+ * Additional string-type properties may be present (e.g. `{ SubType: "designer" }`).
15
+ */
16
+ const interface_ItemMetadataBuiltIn = type({
17
+ "[string]": "string",
18
+ Identity: "string",
19
+ "SubType?": "string",
20
+ "TargetFrameworkIdentifier?": "string",
21
+ "TargetPlatformMoniker?": "string",
22
+ "CopyUpToDateMarker?": "string",
23
+ "TargetPlatformIdentifier?": "string",
24
+ "TargetFrameworkVersion?": "string",
25
+ "ReferenceAssembly?": "string",
26
+ FullPath: "string",
27
+ RootDir: "string",
28
+ Filename: "string",
29
+ Extension: "string",
30
+ RelativeDir: "string",
31
+ Directory: "string",
32
+ RecursiveDir: "string",
33
+ ModifiedTime: "string",
34
+ CreatedTime: "string",
35
+ AccessedTime: "string",
36
+ DefiningProjectFullPath: "string",
37
+ DefiningProjectDirectory: "string",
38
+ DefiningProjectName: "string",
39
+ DefiningProjectExtension: "string"
40
+ });
41
+ const targetSuccess = type({
42
+ Result: "'Success'",
43
+ Items: interface_ItemMetadataBuiltIn.array()
44
+ });
45
+ const targetFailure = type({
46
+ Result: "'Failure'",
47
+ Items: "never[]"
48
+ });
49
+ const msbuildEvaluationOutput = type({
50
+ "Properties?": type({ "[string]": "string" }),
51
+ "Items?": type({ "[string]": interface_ItemMetadataBuiltIn.array() }),
52
+ "TargetResults?": type({ "[string]": targetSuccess.or(targetFailure) })
53
+ });
54
+ var MSBuildEvaluationOutput = class {
55
+ /**
56
+ * @param rawMSBuildEvaluation The output of a CLI MSBuild project evaluation.
57
+ * May be the UTF-8 string-encoded JSON or the object decoded from that JSON.
58
+ */
59
+ constructor(rawMSBuildEvaluation) {
60
+ /** `.assert` instead of `.from` to allow `unknown` JSON.parse return type */
61
+ const knownObject = msbuildEvaluationOutput.assert(typeof rawMSBuildEvaluation === "string" ? JSON.parse(rawMSBuildEvaluation) : rawMSBuildEvaluation);
62
+ this.Properties = knownObject.Properties;
63
+ this.Items = knownObject.Items;
64
+ this.TargetResults = knownObject.TargetResults;
65
+ }
66
+ /**
67
+ * The specified properties and their values as evaluated by MSBuild Core.
68
+ * `-getProperty:{propertyName,...}`
69
+ */
70
+ Properties;
71
+ /**
72
+ * The specified items and their values and associated metadata as evaluated
73
+ * by MSBuild Core.
74
+ * `-getItem:{itemName,...}`
75
+ */
76
+ Items;
77
+ /**
78
+ * The specified Targets and their output values as evaluated by MSBuild
79
+ * Core.
80
+ * `-getTargetResult:{targetName,...}`
81
+ */
82
+ TargetResults;
83
+ };
84
+ const EvaluationOptions = Object.freeze(type({
85
+ FullName: "string",
86
+ Property: type({ "[string]": "string" }).as().partial(),
87
+ Targets: type.string.array().readonly().or("string[]"),
88
+ GetItem: type.string.array().readonly().or("string[]"),
89
+ GetProperty: type.string.array().readonly().or("string[]"),
90
+ GetTargetResult: type.string.array().readonly().or("string[]")
91
+ }));
92
+ var MSBuildProject = class MSBuildProject {
93
+ /**
94
+ * Properties for multi-targeting `dotnet publish` outputs.
95
+ * These are included in {@link NPPGetterNames.InstanceGettersRecursive}.
96
+ */
97
+ static MatrixProperties = Object.freeze([
98
+ "TargetFramework",
99
+ "TargetFrameworks",
100
+ "RuntimeIdentifier",
101
+ "RuntimeIdentifiers"
102
+ ]);
103
+ /**
104
+ * Creates an instance of MSBuildProject.
105
+ * @param opts The order-independent arguments for this constructor.
106
+ * Properties may be added or moved around in this definition without
107
+ * breaking compatibility.
108
+ * @param opts.fullPath The full path of the MSBuild project's file. This
109
+ * should have a '.csproj', '.fsproj', or '.vbproj' file extension.
110
+ * @param opts.projTargets A list of MSBuild Targets supported by the project.
111
+ * @param opts.evaluation The output of an MSBuild project evaluation. This
112
+ * comprises MSBuild Properties, Items, and Target results.
113
+ */
114
+ constructor(opts) {
115
+ this.Items = opts.evaluation.Items ?? {};
116
+ this.Properties = new NugetProjectProperties(opts.fullPath, new CaseInsensitiveMap(Object.entries(opts.evaluation.Properties ?? {})));
117
+ this.Targets = opts.projTargets;
118
+ this.TargetResults = opts.evaluation.TargetResults === void 0 ? [] : [opts.evaluation.TargetResults];
119
+ }
120
+ Items;
121
+ Properties;
122
+ Targets;
123
+ /**
124
+ * Allows appending subsequent target results.
125
+ */
126
+ TargetResults;
127
+ /**
128
+ * @param projectPath The full path of the project file or its directory. A
129
+ * relative path may be passed, but will resolve relative to the current
130
+ * working directory.
131
+ * @param includeNonPublic Include conventionally internal/private MSBuild
132
+ * targets in the result.
133
+ * @returns A string array of the project's MSBuild targets.
134
+ * @todo consider 'file' of -targets[:file]
135
+ * Prints a list of available targets without executing the
136
+ * actual build process. By default the output is written to
137
+ * the console window. If the path to an output file
138
+ * is provided that will be used instead.
139
+ * (Short form: -ts)
140
+ * Example:
141
+ * -ts:out.txt
142
+ */
143
+ static async GetTargets(projectPath, includeNonPublic = false) {
144
+ return execAsync(`dotnet msbuild ${projectPath} -targets`, true).then((v) => {
145
+ const targets = v.stdout.split("\n").filter((v, index) => v !== "" && index !== 0).map((v) => v.replaceAll("\r", "")).sort((a, b) => a.localeCompare(b));
146
+ return includeNonPublic ? targets : targets.filter((v) => !v.startsWith("_"));
147
+ });
148
+ }
149
+ /**
150
+ * Evaluate {@link Items}, {@link Properties}, and {@link TargetResults},
151
+ * returning them as an instance of {@link MSBuildProject}.\
152
+ * Note: MSBuild will probably fail if Restore is skipped and another
153
+ * target is specified. If you choose Pack, you must do ['Restore', 'Pack'].
154
+ * @param options The result of {@link EvaluationOptions.from}.
155
+ * @returns A promised {@link MSBuildProject} instance.
156
+ * @throws {Error} if the exec command fails -OR- the JSON parse fails -OR-
157
+ * MSBuildProject's constructor fails.
158
+ * @see {@link PackableProjectsToMSBuildProjects} for most use-cases.
159
+ */
160
+ static async Evaluate(options) {
161
+ if (options.GetProperty.length === 0 && options.GetItem.length === 0 && options.GetTargetResult.length === 0) throw new Error("No MSBuild Property, Item, or TargetResult queries were provided.");
162
+ options.FullName = MSBuildProjectProperties.GetFullPath(options.FullName);
163
+ const _pairs = Object.entries(options.Property).filter((p) => typeof p[1] === "string");
164
+ const property = _pairs.length === 0 ? "" : `-p:"${_pairs.map((pair) => pair[0] + "=" + pair[1]).join(";")}"`;
165
+ const target = options.Targets.length === 0 ? "" : `"-t:${options.Targets.join(";")}"`;
166
+ const getItem = options.GetItem.length === 0 ? "" : `-getItem:"${options.GetItem.join(",")}"`;
167
+ const getProperty = options.GetProperty.length === 0 ? "" : `-getProperty:"${options.GetProperty.join(",")}"`;
168
+ const getTargetResult = options.GetTargetResult.length === 0 ? "" : `-getTargetResult:"${options.GetTargetResult.join(",")}"`;
169
+ const cmdLine = [
170
+ "dotnet",
171
+ "msbuild",
172
+ `"${options.FullName}"`,
173
+ "-restore",
174
+ property,
175
+ target,
176
+ getItem,
177
+ getProperty,
178
+ getTargetResult
179
+ ].filter((v) => v !== "").join(" ");
180
+ let stdio = void 0;
181
+ while (stdio === void 0) stdio = await setTimeout(1e3, execAsync(cmdLine, true)).then(async (p) => await p).catch(catchEBUSY);
182
+ /**
183
+ * The following issues have triggered this code path:
184
+ * - BaseIntermediateOutputPath must use Unix path separators ('/') on all
185
+ * platforms. Even Windows. Otherwise, MSBuild/dotnet will error-exit with
186
+ * "The BaseIntermediateOutputPath must end with a trailing slash".
187
+ */
188
+ if (stdio.stdout.startsWith("MSBuild version")) {
189
+ warn(stdio.stdout);
190
+ throw new Error("dotnet msbuild was expected to output JSON, but output its version header instead.");
191
+ }
192
+ let rawOutput;
193
+ if (stdio.stdout.startsWith("{"))
194
+ /** stdout is JSON string */
195
+ rawOutput = stdio.stdout;
196
+ else if (options.GetProperty.length > 0 && options.GetProperty[0] !== void 0) rawOutput = { Properties: { [options.GetProperty[0]]: String(JSON.parse(stdio.stdout)) } };
197
+ else throw new Error("Dotnet/MSBuild evaluation output is not a string nor JSON object or array.");
198
+ const evaluation = new MSBuildEvaluationOutput(rawOutput);
199
+ return new MSBuildProject({
200
+ fullPath: options.FullName,
201
+ projTargets: await MSBuildProject.GetTargets(options.FullName),
202
+ evaluation
203
+ });
204
+ }
205
+ /**
206
+ * Evaluate multiple project paths with some default Evaluate options.
207
+ * @async
208
+ * @param projectsToPackAndPush An array of MSBuild projects' full file
209
+ * paths. If a path is a directory, files in that directory are filtered for
210
+ * `.csproj`, `.fsproj`, and `.vbproj` project files.
211
+ * See https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\
212
+ * @returns A promised array of {@link MSBuildProject} instances.
213
+ * All known MSBuild and NuGet properties are evaluated.
214
+ * If applicable, a project's "Pack" target is evaluated.
215
+ */
216
+ static async PackableProjectsToMSBuildProjects(projectsToPackAndPush) {
217
+ return await toDirEntries(typeof projectsToPackAndPush === "string" ? [projectsToPackAndPush] : projectsToPackAndPush).then((direntArray) => direntArray.map((element) => convertDirentToMSBuildProject(element)));
218
+ /**
219
+ * Map an array of filesystem paths to {@link Dirent} instances representing project files.
220
+ * @param projectsToPackAndPush An array of MSBuild projects' full file
221
+ * paths. If a path is a directory, files in that directory are filtered for
222
+ * `.csproj`, `.fsproj`, and `.vbproj` project files. See
223
+ * https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\
224
+ * @returns An promised array of Dirent instances for discovered project files.
225
+ */
226
+ async function toDirEntries(projectsToPackAndPush) {
227
+ return (await Promise.all(projectsToPackAndPush.map(async (proj) => {
228
+ proj = await realpath(makeAbsolute(proj));
229
+ const stats = await stat(proj);
230
+ let entries;
231
+ if (stats.isFile()) {
232
+ entries = await readdir(path.dirname(proj), { withFileTypes: true });
233
+ const dirent = entries.find((v) => path.join(("path" in v ? v.path : void 0) ?? v.parentPath, v.name) === proj);
234
+ if (dirent) return dirent;
235
+ else throw new Error(`file "${proj}" not found. It may have been moved or deleted.`);
236
+ }
237
+ if (!stats.isDirectory()) throw new Error(`"${proj}" is not a file or directory`);
238
+ entries = await readdir(proj, { withFileTypes: true });
239
+ return entries.filter((v) => v.isFile() && (v.name.endsWith(".csproj") || v.name.endsWith(".fsproj") || v.name.endsWith(".vbproj")));
240
+ }))).flat();
241
+ }
242
+ /**
243
+ * Map a {@link Dirent} instance to an {@link MSBuildProject} instance.
244
+ * @param dirent A {@link Dirent} instance. This instance should be an MSBuild project file.
245
+ * @returns An instance of {@link MSBuildProject} evaluated with the `Pack` target result, if applicable. Evaluated properties will be those whose names are returned by {@link NPPGetterNames.InstanceGettersRecursive}.
246
+ */
247
+ async function convertDirentToMSBuildProject(dirent) {
248
+ const fullPath = path.join(("path" in dirent ? dirent.path : void 0) ?? dirent.parentPath, dirent.name);
249
+ const evalTargets = await MSBuildProject.GetTargets(fullPath).then((v) => v.includes("Pack") ? ["Pack"] : []);
250
+ const getProperties = NPPGetterNames.InstanceGettersRecursive;
251
+ return await MSBuildProject.Evaluate(EvaluationOptions.from({
252
+ FullName: fullPath,
253
+ GetItem: [],
254
+ GetProperty: getProperties,
255
+ GetTargetResult: [],
256
+ Property: {},
257
+ Targets: evalTargets
258
+ }));
259
+ }
260
+ }
261
+ static fromJSON(json) {
262
+ const parsed = T_PseudoMSBPInstance.assert(JSON.parse(json));
263
+ type.true.assert(Reflect.setPrototypeOf(parsed, MSBuildProject.prototype));
264
+ type.true.assert(Reflect.setPrototypeOf(parsed.Properties, NugetProjectProperties.prototype));
265
+ parsed.Properties = T_NPP.assert(parsed.Properties);
266
+ return T_MSBuildProject.assert(parsed);
267
+ }
268
+ };
269
+ const T_MSBuildProject = type.instanceOf(MSBuildProject);
270
+ const T_NPP = type.instanceOf(NugetProjectProperties);
271
+ const T_PseudoMSBPInstance = type({
272
+ Items: type({ "[string]": type({
273
+ "[string]": "string",
274
+ Identity: "string",
275
+ FullPath: "string",
276
+ RootDir: "string",
277
+ Filename: "string",
278
+ Extension: "string",
279
+ RelativeDir: "string",
280
+ Directory: "string",
281
+ RecursiveDir: "string",
282
+ ModifiedTime: "string",
283
+ CreatedTime: "string",
284
+ AccessedTime: "string",
285
+ DefiningProjectFullPath: "string",
286
+ DefiningProjectDirectory: "string",
287
+ DefiningProjectName: "string",
288
+ DefiningProjectExtension: "string",
289
+ "SubType?": " string | undefined",
290
+ "TargetFrameworkIdentifier?": "string | undefined",
291
+ "TargetPlatformMoniker?": "string | undefined",
292
+ "CopyUpToDateMarker?": "string | undefined",
293
+ "TargetPlatformIdentifier?": "string | undefined",
294
+ "TargetFrameworkVersion?": "string | undefined",
295
+ "ReferenceAssembly?": "string | undefined"
296
+ }).array() }),
297
+ Properties: type.Record("string", "string").or(T_NPP),
298
+ Targets: type.string.array(),
299
+ TargetResults: msbuildEvaluationOutput.get("TargetResults").exclude("undefined").array()
300
+ });
301
+ /**
302
+ * ArkType type definitions for internal usage, but may be re-used elsewhere
303
+ * @internal
304
+ */
305
+ const _InternalMSBuildEvaluationTypes = type.scope({ msbuildEvaluationOutput });
306
+ /**
307
+ * Resolve a path if it is not already absolute.
308
+ * @param _path A filesystem path.
309
+ * @returns A full path to a filesystem entry. The path is unchecked for whether or not the path (or its parts) exist.
310
+ */
311
+ function makeAbsolute(_path) {
312
+ return path.isAbsolute(_path) ? _path : path.resolve(_path);
313
+ }
314
+ /**
315
+ * Use this in your catch statement or .catch call to return `undefined` when
316
+ * a "file in use by another process" (i.e. EBUSY/ERROR_SHARING_VIOLATION) error is reported.
317
+ * @param error Probably an Error object
318
+ * @returns `undefined` if file in use by another process
319
+ */
320
+ function catchEBUSY(error) {
321
+ if (isError(error)) if ("stderr" in error && typeof error.stderr === "string") {
322
+ const normalizedStderr = error.stderr.normalize("NFKC");
323
+ const hasErrMsgPattern = /The process cannot access the file '[^']+' because it is being used by another process\./gm.test(normalizedStderr);
324
+ const isCS2012 = /^CSC ?:.+CS2012:/gm.test(normalizedStderr);
325
+ const isAVLN9999 = /AVLN9999:/gm.test(normalizedStderr) && hasErrMsgPattern;
326
+ if (isCS2012 || isAVLN9999 || hasErrMsgPattern) return void 0;
327
+ } else throw error;
328
+ else throw new Error("unknown error", { cause: error });
329
+ }
330
+ /**
331
+ *
332
+ * Use this in your catch statement or .catch call to return `undefined` when
333
+ * MSBuild error CSC2012 (e.g. "file in use by another process") is reported.
334
+ * @param error Probably an Error object
335
+ * @returns `undefined` if CSC2012 (file in use by another process) occurs
336
+ * @deprecated Use {@link catchEBUSY}.
337
+ */
338
+ function catchCsc2012(error) {
339
+ if (isError(error)) if ("stderr" in error && typeof error.stderr === "string" && /^CSC ?:.+CS2012:/gm.test(error.stderr.normalize("NFKC"))) return;
340
+ else throw error;
341
+ else throw new Error("unknown error", { cause: error });
342
+ }
343
+ //#endregion
344
+ export { EvaluationOptions, MSBuildEvaluationOutput, MSBuildProject, _InternalMSBuildEvaluationTypes, catchCsc2012, catchEBUSY };
345
+
3
346
  //# sourceMappingURL=MSBuildProject.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MSBuildProject.mjs","names":[],"sources":["../../src/dotnet/MSBuildProject.ts"],"sourcesContent":["import { type, type Scope, type Type } from 'arktype';\nimport { warn } from 'node:console';\nimport { type Dirent } from 'node:fs';\nimport { readdir, realpath, stat } from 'node:fs/promises';\n// eslint-disable-next-line unicorn/import-style\nimport * as path from 'node:path';\nimport { setTimeout } from 'node:timers/promises';\nimport { CaseInsensitiveMap } from '../CaseInsensitiveMap.ts';\nimport { execAsync } from '../utils/execAsync.ts';\nimport { isError } from '../utils/isError.ts';\nimport { MSBuildProjectProperties } from './MSBuildProjectProperties.ts';\nimport {\n NPPGetterNames,\n NugetProjectProperties,\n} from './NugetProjectProperties.ts';\n\n/**\n * See [MSBuild well-known item metadata](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata).\n * Additional string-type properties may be present (e.g. `{ SubType: \"designer\" }`).\n */\nconst interface_ItemMetadataBuiltIn = type({\n '[string]': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\ConsoleApp1.dll\" */\n Identity: 'string',\n /** @example \"Designer\" */\n 'SubType?': 'string',\n /** @example \".NETCoreApp\" */\n 'TargetFrameworkIdentifier?': 'string',\n 'TargetPlatformMoniker?': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\obj\\\\Debug\\\\net6.0\\\\ConsoleApp1.csproj.CopyComplete\" */\n 'CopyUpToDateMarker?': 'string',\n 'TargetPlatformIdentifier?': 'string',\n /** @example \"6.0\" */\n 'TargetFrameworkVersion?': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\obj\\\\Debug\\\\net6.0\\\\ref\\\\ConsoleApp1.dll\" */\n 'ReferenceAssembly?': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\ConsoleApp1.dll\" */\n FullPath: 'string',\n /** @example \"c:\\\\\" */\n RootDir: 'string',\n /** @example \"ConsoleApp1\" */\n Filename: 'string',\n /** @example \".dll\" */\n Extension: 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\\" */\n RelativeDir: 'string',\n /** @example \"source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\\" */\n Directory: 'string',\n RecursiveDir: 'string',\n /** @example \"2023-11-30 13:38:06.5084339\" */\n ModifiedTime: 'string',\n /** @example \"2023-11-30 13:38:06.9308716\" */\n CreatedTime: 'string',\n /** @example \"2023-11-30 13:38:06.9318732\" */\n AccessedTime: 'string',\n /** @example \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Preview\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\Microsoft.Common.CurrentVersion.targets\" */\n DefiningProjectFullPath: 'string',\n /** @example \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Preview\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\\" */\n DefiningProjectDirectory: 'string',\n /** @example \"Microsoft.Common.CurrentVersion\" */\n DefiningProjectName: 'string',\n /** @example \".targets\" */\n DefiningProjectExtension: 'string',\n});\n\nconst targetSuccess = type({\n Result: '\\'Success\\'',\n Items: interface_ItemMetadataBuiltIn.array(),\n});\n\nconst targetFailure = type({\n Result: '\\'Failure\\'',\n Items: 'never[]',\n});\n\nconst msbuildEvaluationOutput: Type<{\n Properties?: Record<string, string> | undefined;\n Items?: Record<string, {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[]> | undefined;\n TargetResults?: Record<string, {\n Result: 'Success';\n Items: {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string | undefined;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[];\n } | {\n Result: 'Failure';\n Items: never[];\n }> | undefined;\n}> = type({\n 'Properties?': type({ '[string]': 'string' }),\n 'Items?': type({ '[string]': interface_ItemMetadataBuiltIn.array() }),\n 'TargetResults?': type({ '[string]': targetSuccess.or(targetFailure) }),\n});\n\nexport class MSBuildEvaluationOutput {\n /**\n * @param rawMSBuildEvaluation The output of a CLI MSBuild project evaluation.\n * May be the UTF-8 string-encoded JSON or the object decoded from that JSON.\n */\n constructor(rawMSBuildEvaluation: Parameters<typeof JSON.parse>[0] | Parameters<typeof msbuildEvaluationOutput.from>[0]) {\n /** `.assert` instead of `.from` to allow `unknown` JSON.parse return type */\n const knownObject = msbuildEvaluationOutput.assert(typeof rawMSBuildEvaluation === 'string' ? JSON.parse(rawMSBuildEvaluation) : rawMSBuildEvaluation);\n\n this.Properties = knownObject.Properties;\n this.Items = knownObject.Items;\n this.TargetResults = knownObject.TargetResults;\n }\n\n /**\n * The specified properties and their values as evaluated by MSBuild Core.\n * `-getProperty:{propertyName,...}`\n */\n Properties?: typeof msbuildEvaluationOutput.infer.Properties;\n /**\n * The specified items and their values and associated metadata as evaluated\n * by MSBuild Core.\n * `-getItem:{itemName,...}`\n */\n Items?: typeof msbuildEvaluationOutput.infer.Items;\n /**\n * The specified Targets and their output values as evaluated by MSBuild\n * Core.\n * `-getTargetResult:{targetName,...}`\n */\n TargetResults?: typeof msbuildEvaluationOutput.infer.TargetResults;\n}\n\nexport const EvaluationOptions: Type<{\n FullName: string;\n Property: {\n MSBuildProjectFullPath?: string | undefined;\n AssemblyName?: string | undefined;\n BaseIntermediateOutputPath?: string | undefined;\n BaseOutputPath?: string | undefined;\n Description?: string | undefined;\n IntermediateOutput?: string | undefined;\n OutDir?: string | undefined;\n OutputPath?: string | undefined;\n Version?: string | undefined;\n VersionPrefix?: string | undefined;\n VersionSuffix?: string | undefined;\n TargetFramework?: string | undefined;\n TargetFrameworks?: string | undefined;\n RuntimeIdentifier?: string | undefined;\n RuntimeIdentifiers?: string | undefined;\n };\n Targets: readonly string[] | string[];\n GetItem: readonly string[] | string[];\n GetProperty: readonly string[] | string[];\n GetTargetResult: readonly string[] | string[];\n}> = Object.freeze(\n type({\n /**\n * The project file's full path.\n */\n FullName: 'string',\n /**\n * User-defined Properties and their values.\n * { Configuration: \"Release\" } will cause the MSBuild to first set the\n * Configuration property to Release before evaluating the project\n * or the project's Target(s).\n * ```txt\n * -property:<n>=<v> Set or override these project-level properties. <n> is\n * the property name, and <v> is the property value. Use a\n * semicolon or a comma to separate multiple properties, or\n * specify each property separately. (Short form: -p)\n * Example:\n * -property:WarningLevel=2;OutDir=bin\\Debug\\\n * ```\n */\n Property: type({ '[string]': 'string' })\n .as<{ -readonly [P in keyof MSBuildProjectProperties]: MSBuildProjectProperties[P] }>()\n .partial(),\n /**\n * The MSBuild Targets to run for evaluation. [\"Pack\"] is recommended.\n * Property values may be changed by Targets such as those provided by\n * dependencies.\n *\n * ```txt\n * -target:<targets> Build these targets in this project. Use a semicolon or a\n * comma to separate multiple targets, or specify each\n * target separately. (Short form: -t)\n * Example:\n * -target:Resources;Compile\n * ```\n * @default []\n */\n Targets: type.string.array().readonly().or('string[]'),\n /**\n * MSBuild Items to evaluate. `[\"Compile\"]` will result in the MSBuild output\n * including {@link MSBuild}\n */\n GetItem: type.string.array().readonly().or('string[]'),\n GetProperty: type.string.array().readonly().or('string[]'),\n GetTargetResult: type.string.array().readonly().or('string[]'),\n }),\n);\n\nexport class MSBuildProject {\n /**\n * Properties for multi-targeting `dotnet publish` outputs.\n * These are included in {@link NPPGetterNames.InstanceGettersRecursive}.\n */\n public static readonly MatrixProperties: readonly string[] = Object.freeze([\n 'TargetFramework',\n 'TargetFrameworks',\n 'RuntimeIdentifier',\n 'RuntimeIdentifiers',\n ]);\n\n /**\n * Creates an instance of MSBuildProject.\n * @param opts The order-independent arguments for this constructor.\n * Properties may be added or moved around in this definition without\n * breaking compatibility.\n * @param opts.fullPath The full path of the MSBuild project's file. This\n * should have a '.csproj', '.fsproj', or '.vbproj' file extension.\n * @param opts.projTargets A list of MSBuild Targets supported by the project.\n * @param opts.evaluation The output of an MSBuild project evaluation. This\n * comprises MSBuild Properties, Items, and Target results.\n */\n public constructor(opts: {\n fullPath: string;\n projTargets: string[];\n evaluation: MSBuildEvaluationOutput;\n }) {\n this.Items = opts.evaluation.Items ?? {};\n this.Properties = new NugetProjectProperties(\n opts.fullPath,\n new CaseInsensitiveMap<string, string>(\n Object.entries(opts.evaluation.Properties ?? {}),\n ),\n );\n this.Targets = opts.projTargets;\n this.TargetResults\n = opts.evaluation.TargetResults === undefined\n ? []\n : [opts.evaluation.TargetResults];\n }\n\n readonly Items: Readonly<Required<MSBuildEvaluationOutput>['Items']>;\n readonly Properties: Readonly<NugetProjectProperties>;\n readonly Targets: readonly string[];\n /**\n * Allows appending subsequent target results.\n */\n readonly TargetResults: Required<MSBuildEvaluationOutput>['TargetResults'][];\n\n /**\n * @param projectPath The full path of the project file or its directory. A\n * relative path may be passed, but will resolve relative to the current\n * working directory.\n * @param includeNonPublic Include conventionally internal/private MSBuild\n * targets in the result.\n * @returns A string array of the project's MSBuild targets.\n * @todo consider 'file' of -targets[:file]\n * Prints a list of available targets without executing the\n * actual build process. By default the output is written to\n * the console window. If the path to an output file\n * is provided that will be used instead.\n * (Short form: -ts)\n * Example:\n * -ts:out.txt\n */\n static async GetTargets(\n projectPath: string,\n includeNonPublic = false,\n ): Promise<string[]> {\n return execAsync(`dotnet msbuild ${projectPath} -targets`, true)\n .then((v) => {\n const targets = v.stdout\n .split('\\n')\n .filter((v, index) => v !== '' && index !== 0)\n .map(v => v.replaceAll('\\r', ''))\n .sort((a, b) => a.localeCompare(b));\n return includeNonPublic\n ? targets\n : targets.filter(v => !v.startsWith('_'));\n });\n }\n\n /**\n * Evaluate {@link Items}, {@link Properties}, and {@link TargetResults},\n * returning them as an instance of {@link MSBuildProject}.\\\n * Note: MSBuild will probably fail if Restore is skipped and another\n * target is specified. If you choose Pack, you must do ['Restore', 'Pack'].\n * @param options The result of {@link EvaluationOptions.from}.\n * @returns A promised {@link MSBuildProject} instance.\n * @throws {Error} if the exec command fails -OR- the JSON parse fails -OR-\n * MSBuildProject's constructor fails.\n * @see {@link PackableProjectsToMSBuildProjects} for most use-cases.\n */\n public static async Evaluate(\n options: typeof EvaluationOptions.inferOut,\n ): Promise<MSBuildProject> {\n if (\n options.GetProperty.length === 0\n && options.GetItem.length === 0\n && options.GetTargetResult.length === 0\n ) {\n throw new Error(\n 'No MSBuild Property, Item, or TargetResult queries were provided.',\n );\n }\n // reminder: args containing spaces and semi-colons MUST be quote-enclosed!\n options.FullName = MSBuildProjectProperties.GetFullPath(options.FullName);\n const _pairs = Object.entries(options.Property).filter(p => typeof p[1] === 'string');\n const property\n = _pairs.length === 0\n ? ''\n : `-p:\"${_pairs.map(pair => pair[0] + '=' + pair[1]).join(';')}\"`;\n const target\n = options.Targets.length === 0\n ? ''\n : `\"-t:${options.Targets.join(';')}\"`;\n const getItem\n = options.GetItem.length === 0\n ? ''\n : `-getItem:\"${options.GetItem.join(',')}\"`;\n const getProperty\n = options.GetProperty.length === 0\n ? ''\n : `-getProperty:\"${options.GetProperty.join(',')}\"`;\n const getTargetResult\n = options.GetTargetResult.length === 0\n ? ''\n : `-getTargetResult:\"${options.GetTargetResult.join(',')}\"`;\n const cmdLine = [\n 'dotnet',\n 'msbuild',\n `\"${options.FullName}\"`,\n '-restore',\n property,\n target,\n getItem,\n getProperty,\n getTargetResult,\n ]\n .filter(v => v !== '')\n .join(' ');\n let stdio: Awaited<ReturnType<typeof execAsync>> | undefined = undefined;\n // may throw\n while (stdio === undefined) {\n stdio = await setTimeout(\n 1000,\n execAsync(cmdLine, true),\n )\n .then(async p => await p)\n .catch<undefined>(catchEBUSY);\n }\n\n // todo: consider -getResultOutputFile:file\n // Redirect output from get* into a file.\n //\n // Example:\n // -getProperty:Bar -getResultOutputFile:Biz.txt\n // This writes the value of property Bar into Biz.txt.\n\n /**\n * The following issues have triggered this code path:\n * - BaseIntermediateOutputPath must use Unix path separators ('/') on all\n * platforms. Even Windows. Otherwise, MSBuild/dotnet will error-exit with\n * \"The BaseIntermediateOutputPath must end with a trailing slash\".\n */\n if (stdio.stdout.startsWith('MSBuild version')) {\n warn(stdio.stdout);\n throw new Error(\n 'dotnet msbuild was expected to output JSON, but output its version header instead.',\n );\n }\n\n let rawOutput: ConstructorParameters<typeof MSBuildEvaluationOutput>[0];\n if (stdio.stdout.startsWith('{')) {\n /** stdout is JSON string */\n rawOutput = stdio.stdout;\n }\n else if (options.GetProperty.length > 0 && options.GetProperty[0] !== undefined) {\n rawOutput = {\n Properties: {\n [options.GetProperty[0]]: String(JSON.parse(stdio.stdout)),\n },\n };\n }\n else {\n throw new Error('Dotnet/MSBuild evaluation output is not a string nor JSON object or array.');\n }\n\n const evaluation = new MSBuildEvaluationOutput(rawOutput);\n\n return new MSBuildProject({\n fullPath: options.FullName,\n projTargets: await MSBuildProject.GetTargets(options.FullName),\n evaluation,\n });\n }\n\n /**\n * Evaluate multiple project paths with some default Evaluate options.\n * @async\n * @param projectsToPackAndPush An array of MSBuild projects' full file\n * paths. If a path is a directory, files in that directory are filtered for\n * `.csproj`, `.fsproj`, and `.vbproj` project files.\n * See https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\\\n * @returns A promised array of {@link MSBuildProject} instances.\n * All known MSBuild and NuGet properties are evaluated.\n * If applicable, a project's \"Pack\" target is evaluated.\n */\n public static async PackableProjectsToMSBuildProjects(\n projectsToPackAndPush: string[],\n ): Promise<Promise<MSBuildProject>[]> {\n const dirEntriesPromise = toDirEntries(typeof projectsToPackAndPush === 'string' ? [projectsToPackAndPush] : projectsToPackAndPush);\n const projectPromises: Promise<MSBuildProject>[] = await dirEntriesPromise\n .then(\n (direntArray: Dirent[]) =>\n direntArray.map(element => convertDirentToMSBuildProject(element)),\n );\n return projectPromises;\n\n /**\n * Map an array of filesystem paths to {@link Dirent} instances representing project files.\n * @param projectsToPackAndPush An array of MSBuild projects' full file\n * paths. If a path is a directory, files in that directory are filtered for\n * `.csproj`, `.fsproj`, and `.vbproj` project files. See\n * https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\\\n * @returns An promised array of Dirent instances for discovered project files.\n */\n async function toDirEntries(\n projectsToPackAndPush: string[],\n ): Promise<Dirent[]> {\n const dirEntries: (Dirent | Dirent[])[] = await Promise.all(\n projectsToPackAndPush.map(async (proj) => {\n proj = await realpath(makeAbsolute(proj));\n const stats = await stat(proj);\n let entries: Dirent[];\n\n if (stats.isFile()) {\n entries = await readdir(path.dirname(proj), { withFileTypes: true });\n const dirent: Dirent | undefined = entries.find(v =>\n path.join(\n // condition required for compatibility. `.path` was deprecated, but `.parentPath` is not available in our node minversion\n ('path' in v ? v.path as string | undefined : undefined) ?? (v as unknown as Omit<typeof v, 'path'> & { parentPath: string }).parentPath,\n v.name,\n ) === proj,\n );\n if (dirent)\n return dirent;\n else\n throw new Error(\n `file \"${proj}\" not found. It may have been moved or deleted.`,\n );\n }\n if (!stats.isDirectory())\n throw new Error(`\"${proj}\" is not a file or directory`);\n\n entries = await readdir(proj, { withFileTypes: true });\n return entries.filter(v =>\n v.isFile()\n && (v.name.endsWith('.csproj') || v.name.endsWith('.fsproj') || v.name.endsWith('.vbproj')),\n );\n }),\n );\n\n return dirEntries.flat();\n }\n\n /**\n * Map a {@link Dirent} instance to an {@link MSBuildProject} instance.\n * @param dirent A {@link Dirent} instance. This instance should be an MSBuild project file.\n * @returns An instance of {@link MSBuildProject} evaluated with the `Pack` target result, if applicable. Evaluated properties will be those whose names are returned by {@link NPPGetterNames.InstanceGettersRecursive}.\n */\n async function convertDirentToMSBuildProject(dirent: Dirent): Promise<MSBuildProject> {\n const fullPath = path.join(\n // condition required for compatibility. `.path` was deprecated, but `.parentPath` is not available in our node minversion\n ('path' in dirent ? dirent.path as string | undefined : undefined) ?? (dirent as unknown as Omit<typeof dirent, 'path'> & { parentPath: string }).parentPath,\n dirent.name,\n );\n const projTargets: Promise<string[]> = MSBuildProject.GetTargets(fullPath);\n const evalTargets = await projTargets.then(v =>\n v.includes('Pack') ? ['Pack'] : [],\n );\n // this might be too long for a command line. What was it on Windows?\n // 2^15 (32,768) character limit for command lines?\n const getProperties = NPPGetterNames.InstanceGettersRecursive;\n\n return await MSBuildProject.Evaluate(\n EvaluationOptions.from({\n FullName: fullPath,\n GetItem: [],\n GetProperty: getProperties,\n GetTargetResult: [],\n Property: {},\n Targets: evalTargets,\n }),\n );\n }\n }\n\n public static fromJSON(json: string): MSBuildProject {\n const parsed = T_PseudoMSBPInstance.assert(JSON.parse(json));\n\n type.true.assert(\n Reflect.setPrototypeOf(parsed, MSBuildProject.prototype),\n );\n type.true.assert(\n Reflect.setPrototypeOf(parsed.Properties, NugetProjectProperties.prototype),\n );\n parsed.Properties = T_NPP.assert(parsed.Properties);\n return T_MSBuildProject.assert(parsed);\n }\n}\n\nconst T_MSBuildProject = type.instanceOf(MSBuildProject);\nconst T_NPP = type.instanceOf(NugetProjectProperties);\nconst T_PseudoMSBPInstance = type({\n Items: type({\n '[string]': type({\n '[string]': 'string',\n Identity: 'string',\n FullPath: 'string',\n RootDir: 'string',\n Filename: 'string',\n Extension: 'string',\n RelativeDir: 'string',\n Directory: 'string',\n RecursiveDir: 'string',\n ModifiedTime: 'string',\n CreatedTime: 'string',\n AccessedTime: 'string',\n DefiningProjectFullPath: 'string',\n DefiningProjectDirectory: 'string',\n DefiningProjectName: 'string',\n DefiningProjectExtension: 'string',\n 'SubType?': ' string | undefined',\n 'TargetFrameworkIdentifier?': 'string | undefined',\n 'TargetPlatformMoniker?': 'string | undefined',\n 'CopyUpToDateMarker?': 'string | undefined',\n 'TargetPlatformIdentifier?': 'string | undefined',\n 'TargetFrameworkVersion?': 'string | undefined',\n 'ReferenceAssembly?': 'string | undefined',\n }).array(),\n }),\n Properties: type.Record('string', 'string').or(T_NPP),\n Targets: type.string.array(),\n TargetResults: msbuildEvaluationOutput.get('TargetResults').exclude('undefined').array(),\n\n});\n\n/**\n * ArkType type definitions for internal usage, but may be re-used elsewhere\n * @internal\n */\nexport const _InternalMSBuildEvaluationTypes: Scope<{\n msbuildEvaluationOutput: {\n Properties?: Record<string, string> | undefined;\n Items?: Record<string, {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string | undefined;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[]> | undefined;\n TargetResults?: Record<string, {\n Result: 'Success';\n Items: {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string | undefined;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[];\n } | {\n Result: 'Failure';\n Items: never[];\n }> | undefined;\n };\n}> = type.scope({\n msbuildEvaluationOutput,\n});\n\n/**\n * Resolve a path if it is not already absolute.\n * @param _path A filesystem path.\n * @returns A full path to a filesystem entry. The path is unchecked for whether or not the path (or its parts) exist.\n */\nfunction makeAbsolute(_path: string) {\n return path.isAbsolute(_path) ? _path : path.resolve(_path);\n}\n\n/**\n * Use this in your catch statement or .catch call to return `undefined` when\n * a \"file in use by another process\" (i.e. EBUSY/ERROR_SHARING_VIOLATION) error is reported.\n * @param error Probably an Error object\n * @returns `undefined` if file in use by another process\n */\nexport function catchEBUSY(error: unknown): undefined {\n if (isError(error)) {\n if ('stderr' in error && typeof error.stderr === 'string') {\n // Normalize colon-like chars: '\\uFF1A'.normalize('NFKC') === ':' === true;\n const normalizedStderr = error.stderr.normalize('NFKC');\n const patternEN = /The process cannot access the file '[^']+' because it is being used by another process\\./gm;\n const hasErrMsgPattern = patternEN.test(normalizedStderr);\n const isCS2012 = /^CSC ?:.+CS2012:/gm.test(normalizedStderr);\n // generic error code; error message must be checked.\n const isAVLN9999 = /AVLN9999:/gm.test(normalizedStderr)\n && hasErrMsgPattern;\n if (isCS2012 || isAVLN9999 || hasErrMsgPattern)\n return undefined; /* retry */\n }\n /**\n * some known warnings/errors:\n * - warning MSB3073:\n * The command \"dotnet tool list kuinox.nupkgdeterministicator\"\n * exited with code 145.\n * > $ dotnet tool list kuinox.nupkgdeterministicator\n * > The command could not be loaded, possibly because:\n * > * You intended to execute a .NET application:\n * > The application 'tool' does not exist.\n * > * You intended to execute a .NET SDK command:\n * > No .NET SDKs were found.\n * >\n * > Download a .NET SDK:\n * > https://aka.ms/dotnet/download\n * >\n * > Learn about SDK resolution:\n * > https://aka.ms/dotnet/sdk-not-found\n */\n else throw error;\n }\n else throw new Error('unknown error', { cause: error });\n}\n\n/**\n *\n * Use this in your catch statement or .catch call to return `undefined` when\n * MSBuild error CSC2012 (e.g. \"file in use by another process\") is reported.\n * @param error Probably an Error object\n * @returns `undefined` if CSC2012 (file in use by another process) occurs\n * @deprecated Use {@link catchEBUSY}.\n */\nexport function catchCsc2012(error: unknown): undefined {\n if (isError(error)) {\n // check for error reported when \"file in use by another process\" i.e. EBUSY\n // (UNIX), NTSTATUS.ERROR_SHARING_VIOLATION == 0x20 == 32 (Windows)\n if ('stderr' in error && typeof error.stderr === 'string'\n && /^CSC ?:.+CS2012:/gm.test(\n // '\\uFF1A'.normalize('NFKC') === ':' === true;\n error.stderr.normalize('NFKC'),\n )\n ) {\n return undefined; /* retry */\n }\n /**\n * some known warnings/errors:\n * - warning MSB3073:\n * The command \"dotnet tool list kuinox.nupkgdeterministicator\"\n * exited with code 145.\n * > $ dotnet tool list kuinox.nupkgdeterministicator\n * > The command could not be loaded, possibly because:\n * > * You intended to execute a .NET application:\n * > The application 'tool' does not exist.\n * > * You intended to execute a .NET SDK command:\n * > No .NET SDKs were found.\n * >\n * > Download a .NET SDK:\n * > https://aka.ms/dotnet/download\n * >\n * > Learn about SDK resolution:\n * > https://aka.ms/dotnet/sdk-not-found\n */\n else throw error;\n }\n else throw new Error('unknown error', { cause: error });\n}\n"],"mappings":"yhBAoBA,MAAM,EAAgC,EAAK,CACzC,WAAY,SAEZ,SAAU,SAEV,WAAY,SAEZ,6BAA8B,SAC9B,yBAA0B,SAE1B,sBAAuB,SACvB,4BAA6B,SAE7B,0BAA2B,SAE3B,qBAAsB,SAEtB,SAAU,SAEV,QAAS,SAET,SAAU,SAEV,UAAW,SAEX,YAAa,SAEb,UAAW,SACX,aAAc,SAEd,aAAc,SAEd,YAAa,SAEb,aAAc,SAEd,wBAAyB,SAEzB,yBAA0B,SAE1B,oBAAqB,SAErB,yBAA0B,SAC3B,CAAC,CAEI,EAAgB,EAAK,CACzB,OAAQ,YACR,MAAO,EAA8B,OAAO,CAC7C,CAAC,CAEI,EAAgB,EAAK,CACzB,OAAQ,YACR,MAAO,UACR,CAAC,CAEI,EA0DD,EAAK,CACR,cAAe,EAAK,CAAE,WAAY,SAAU,CAAC,CAC7C,SAAU,EAAK,CAAE,WAAY,EAA8B,OAAO,CAAE,CAAC,CACrE,iBAAkB,EAAK,CAAE,WAAY,EAAc,GAAG,EAAc,CAAE,CAAC,CACxE,CAAC,CAEF,IAAa,EAAb,KAAqC,CAKnC,YAAY,EAA6G,CAEvH,IAAM,EAAc,EAAwB,OAAO,OAAO,GAAyB,SAAW,KAAK,MAAM,EAAqB,CAAG,EAAqB,CAEtJ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M,CACd,0BACD,CAAC,CAOF,SAAS,EAAa,EAAe,CACnC,OAAO,EAAK,WAAW,EAAM,CAAG,EAAQ,EAAK,QAAQ,EAAM,CAS7D,SAAgB,EAAW,EAA2B,CACpD,GAAI,EAAQ,EAAM,CAChB,GAAI,WAAY,GAAS,OAAO,EAAM,QAAW,SAAU,CAEzD,IAAM,EAAmB,EAAM,OAAO,UAAU,OAAO,CAEjD,EADY,6FACiB,KAAK,EAAiB,CACnD,EAAW,qBAAqB,KAAK,EAAiB,CAEtD,EAAa,cAAc,KAAK,EAAiB,EAClD,EACL,GAAI,GAAY,GAAc,EAC5B,YAoBC,MAAM,OAER,MAAU,MAAM,gBAAiB,CAAE,MAAO,EAAO,CAAC,CAWzD,SAAgB,EAAa,EAA2B,CACtD,GAAI,EAAQ,EAAM,CAGhB,IAAI,WAAY,GAAS,OAAO,EAAM,QAAW,UAC5C,qBAAqB,KAEtB,EAAM,OAAO,UAAU,OAAO,CAC/B,CAED,OAoBG,MAAM,OAER,MAAU,MAAM,gBAAiB,CAAE,MAAO,EAAO,CAAC"}
1
+ {"version":3,"file":"MSBuildProject.mjs","names":[],"sources":["../../src/dotnet/MSBuildProject.ts"],"sourcesContent":["import { type, type Scope, type Type } from 'arktype';\nimport { warn } from 'node:console';\nimport { type Dirent } from 'node:fs';\nimport { readdir, realpath, stat } from 'node:fs/promises';\n// eslint-disable-next-line unicorn/import-style\nimport * as path from 'node:path';\nimport { setTimeout } from 'node:timers/promises';\nimport { CaseInsensitiveMap } from '../CaseInsensitiveMap.ts';\nimport { execAsync } from '../utils/execAsync.ts';\nimport { isError } from '../utils/isError.ts';\nimport { MSBuildProjectProperties } from './MSBuildProjectProperties.ts';\nimport {\n NPPGetterNames,\n NugetProjectProperties,\n} from './NugetProjectProperties.ts';\n\n/**\n * See [MSBuild well-known item metadata](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata).\n * Additional string-type properties may be present (e.g. `{ SubType: \"designer\" }`).\n */\nconst interface_ItemMetadataBuiltIn = type({\n '[string]': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\ConsoleApp1.dll\" */\n Identity: 'string',\n /** @example \"Designer\" */\n 'SubType?': 'string',\n /** @example \".NETCoreApp\" */\n 'TargetFrameworkIdentifier?': 'string',\n 'TargetPlatformMoniker?': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\obj\\\\Debug\\\\net6.0\\\\ConsoleApp1.csproj.CopyComplete\" */\n 'CopyUpToDateMarker?': 'string',\n 'TargetPlatformIdentifier?': 'string',\n /** @example \"6.0\" */\n 'TargetFrameworkVersion?': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\obj\\\\Debug\\\\net6.0\\\\ref\\\\ConsoleApp1.dll\" */\n 'ReferenceAssembly?': 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\ConsoleApp1.dll\" */\n FullPath: 'string',\n /** @example \"c:\\\\\" */\n RootDir: 'string',\n /** @example \"ConsoleApp1\" */\n Filename: 'string',\n /** @example \".dll\" */\n Extension: 'string',\n /** @example \"c:\\\\source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\\" */\n RelativeDir: 'string',\n /** @example \"source\\\\repos\\\\ConsoleApp1\\\\ConsoleApp1\\\\bin\\\\Debug\\\\net6.0\\\\\" */\n Directory: 'string',\n RecursiveDir: 'string',\n /** @example \"2023-11-30 13:38:06.5084339\" */\n ModifiedTime: 'string',\n /** @example \"2023-11-30 13:38:06.9308716\" */\n CreatedTime: 'string',\n /** @example \"2023-11-30 13:38:06.9318732\" */\n AccessedTime: 'string',\n /** @example \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Preview\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\Microsoft.Common.CurrentVersion.targets\" */\n DefiningProjectFullPath: 'string',\n /** @example \"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Preview\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\\" */\n DefiningProjectDirectory: 'string',\n /** @example \"Microsoft.Common.CurrentVersion\" */\n DefiningProjectName: 'string',\n /** @example \".targets\" */\n DefiningProjectExtension: 'string',\n});\n\nconst targetSuccess = type({\n Result: '\\'Success\\'',\n Items: interface_ItemMetadataBuiltIn.array(),\n});\n\nconst targetFailure = type({\n Result: '\\'Failure\\'',\n Items: 'never[]',\n});\n\nconst msbuildEvaluationOutput: Type<{\n Properties?: Record<string, string> | undefined;\n Items?: Record<string, {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[]> | undefined;\n TargetResults?: Record<string, {\n Result: 'Success';\n Items: {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string | undefined;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[];\n } | {\n Result: 'Failure';\n Items: never[];\n }> | undefined;\n}> = type({\n 'Properties?': type({ '[string]': 'string' }),\n 'Items?': type({ '[string]': interface_ItemMetadataBuiltIn.array() }),\n 'TargetResults?': type({ '[string]': targetSuccess.or(targetFailure) }),\n});\n\nexport class MSBuildEvaluationOutput {\n /**\n * @param rawMSBuildEvaluation The output of a CLI MSBuild project evaluation.\n * May be the UTF-8 string-encoded JSON or the object decoded from that JSON.\n */\n constructor(rawMSBuildEvaluation: Parameters<typeof JSON.parse>[0] | Parameters<typeof msbuildEvaluationOutput.from>[0]) {\n /** `.assert` instead of `.from` to allow `unknown` JSON.parse return type */\n const knownObject = msbuildEvaluationOutput.assert(typeof rawMSBuildEvaluation === 'string' ? JSON.parse(rawMSBuildEvaluation) : rawMSBuildEvaluation);\n\n this.Properties = knownObject.Properties;\n this.Items = knownObject.Items;\n this.TargetResults = knownObject.TargetResults;\n }\n\n /**\n * The specified properties and their values as evaluated by MSBuild Core.\n * `-getProperty:{propertyName,...}`\n */\n Properties?: typeof msbuildEvaluationOutput.infer.Properties;\n /**\n * The specified items and their values and associated metadata as evaluated\n * by MSBuild Core.\n * `-getItem:{itemName,...}`\n */\n Items?: typeof msbuildEvaluationOutput.infer.Items;\n /**\n * The specified Targets and their output values as evaluated by MSBuild\n * Core.\n * `-getTargetResult:{targetName,...}`\n */\n TargetResults?: typeof msbuildEvaluationOutput.infer.TargetResults;\n}\n\nexport const EvaluationOptions: Type<{\n FullName: string;\n Property: {\n MSBuildProjectFullPath?: string | undefined;\n AssemblyName?: string | undefined;\n BaseIntermediateOutputPath?: string | undefined;\n BaseOutputPath?: string | undefined;\n Description?: string | undefined;\n IntermediateOutput?: string | undefined;\n OutDir?: string | undefined;\n OutputPath?: string | undefined;\n Version?: string | undefined;\n VersionPrefix?: string | undefined;\n VersionSuffix?: string | undefined;\n TargetFramework?: string | undefined;\n TargetFrameworks?: string | undefined;\n RuntimeIdentifier?: string | undefined;\n RuntimeIdentifiers?: string | undefined;\n };\n Targets: readonly string[] | string[];\n GetItem: readonly string[] | string[];\n GetProperty: readonly string[] | string[];\n GetTargetResult: readonly string[] | string[];\n}> = Object.freeze(\n type({\n /**\n * The project file's full path.\n */\n FullName: 'string',\n /**\n * User-defined Properties and their values.\n * { Configuration: \"Release\" } will cause the MSBuild to first set the\n * Configuration property to Release before evaluating the project\n * or the project's Target(s).\n * ```txt\n * -property:<n>=<v> Set or override these project-level properties. <n> is\n * the property name, and <v> is the property value. Use a\n * semicolon or a comma to separate multiple properties, or\n * specify each property separately. (Short form: -p)\n * Example:\n * -property:WarningLevel=2;OutDir=bin\\Debug\\\n * ```\n */\n Property: type({ '[string]': 'string' })\n .as<{ -readonly [P in keyof MSBuildProjectProperties]: MSBuildProjectProperties[P] }>()\n .partial(),\n /**\n * The MSBuild Targets to run for evaluation. [\"Pack\"] is recommended.\n * Property values may be changed by Targets such as those provided by\n * dependencies.\n *\n * ```txt\n * -target:<targets> Build these targets in this project. Use a semicolon or a\n * comma to separate multiple targets, or specify each\n * target separately. (Short form: -t)\n * Example:\n * -target:Resources;Compile\n * ```\n * @default []\n */\n Targets: type.string.array().readonly().or('string[]'),\n /**\n * MSBuild Items to evaluate. `[\"Compile\"]` will result in the MSBuild output\n * including {@link MSBuild}\n */\n GetItem: type.string.array().readonly().or('string[]'),\n GetProperty: type.string.array().readonly().or('string[]'),\n GetTargetResult: type.string.array().readonly().or('string[]'),\n }),\n);\n\nexport class MSBuildProject {\n /**\n * Properties for multi-targeting `dotnet publish` outputs.\n * These are included in {@link NPPGetterNames.InstanceGettersRecursive}.\n */\n public static readonly MatrixProperties: readonly string[] = Object.freeze([\n 'TargetFramework',\n 'TargetFrameworks',\n 'RuntimeIdentifier',\n 'RuntimeIdentifiers',\n ]);\n\n /**\n * Creates an instance of MSBuildProject.\n * @param opts The order-independent arguments for this constructor.\n * Properties may be added or moved around in this definition without\n * breaking compatibility.\n * @param opts.fullPath The full path of the MSBuild project's file. This\n * should have a '.csproj', '.fsproj', or '.vbproj' file extension.\n * @param opts.projTargets A list of MSBuild Targets supported by the project.\n * @param opts.evaluation The output of an MSBuild project evaluation. This\n * comprises MSBuild Properties, Items, and Target results.\n */\n public constructor(opts: {\n fullPath: string;\n projTargets: string[];\n evaluation: MSBuildEvaluationOutput;\n }) {\n this.Items = opts.evaluation.Items ?? {};\n this.Properties = new NugetProjectProperties(\n opts.fullPath,\n new CaseInsensitiveMap<string, string>(\n Object.entries(opts.evaluation.Properties ?? {}),\n ),\n );\n this.Targets = opts.projTargets;\n this.TargetResults\n = opts.evaluation.TargetResults === undefined\n ? []\n : [opts.evaluation.TargetResults];\n }\n\n readonly Items: Readonly<Required<MSBuildEvaluationOutput>['Items']>;\n readonly Properties: Readonly<NugetProjectProperties>;\n readonly Targets: readonly string[];\n /**\n * Allows appending subsequent target results.\n */\n readonly TargetResults: Required<MSBuildEvaluationOutput>['TargetResults'][];\n\n /**\n * @param projectPath The full path of the project file or its directory. A\n * relative path may be passed, but will resolve relative to the current\n * working directory.\n * @param includeNonPublic Include conventionally internal/private MSBuild\n * targets in the result.\n * @returns A string array of the project's MSBuild targets.\n * @todo consider 'file' of -targets[:file]\n * Prints a list of available targets without executing the\n * actual build process. By default the output is written to\n * the console window. If the path to an output file\n * is provided that will be used instead.\n * (Short form: -ts)\n * Example:\n * -ts:out.txt\n */\n static async GetTargets(\n projectPath: string,\n includeNonPublic = false,\n ): Promise<string[]> {\n return execAsync(`dotnet msbuild ${projectPath} -targets`, true)\n .then((v) => {\n const targets = v.stdout\n .split('\\n')\n .filter((v, index) => v !== '' && index !== 0)\n .map(v => v.replaceAll('\\r', ''))\n .sort((a, b) => a.localeCompare(b));\n return includeNonPublic\n ? targets\n : targets.filter(v => !v.startsWith('_'));\n });\n }\n\n /**\n * Evaluate {@link Items}, {@link Properties}, and {@link TargetResults},\n * returning them as an instance of {@link MSBuildProject}.\\\n * Note: MSBuild will probably fail if Restore is skipped and another\n * target is specified. If you choose Pack, you must do ['Restore', 'Pack'].\n * @param options The result of {@link EvaluationOptions.from}.\n * @returns A promised {@link MSBuildProject} instance.\n * @throws {Error} if the exec command fails -OR- the JSON parse fails -OR-\n * MSBuildProject's constructor fails.\n * @see {@link PackableProjectsToMSBuildProjects} for most use-cases.\n */\n public static async Evaluate(\n options: typeof EvaluationOptions.inferOut,\n ): Promise<MSBuildProject> {\n if (\n options.GetProperty.length === 0\n && options.GetItem.length === 0\n && options.GetTargetResult.length === 0\n ) {\n throw new Error(\n 'No MSBuild Property, Item, or TargetResult queries were provided.',\n );\n }\n // reminder: args containing spaces and semi-colons MUST be quote-enclosed!\n options.FullName = MSBuildProjectProperties.GetFullPath(options.FullName);\n const _pairs = Object.entries(options.Property).filter(p => typeof p[1] === 'string');\n const property\n = _pairs.length === 0\n ? ''\n : `-p:\"${_pairs.map(pair => pair[0] + '=' + pair[1]).join(';')}\"`;\n const target\n = options.Targets.length === 0\n ? ''\n : `\"-t:${options.Targets.join(';')}\"`;\n const getItem\n = options.GetItem.length === 0\n ? ''\n : `-getItem:\"${options.GetItem.join(',')}\"`;\n const getProperty\n = options.GetProperty.length === 0\n ? ''\n : `-getProperty:\"${options.GetProperty.join(',')}\"`;\n const getTargetResult\n = options.GetTargetResult.length === 0\n ? ''\n : `-getTargetResult:\"${options.GetTargetResult.join(',')}\"`;\n const cmdLine = [\n 'dotnet',\n 'msbuild',\n `\"${options.FullName}\"`,\n '-restore',\n property,\n target,\n getItem,\n getProperty,\n getTargetResult,\n ]\n .filter(v => v !== '')\n .join(' ');\n let stdio: Awaited<ReturnType<typeof execAsync>> | undefined = undefined;\n // may throw\n while (stdio === undefined) {\n stdio = await setTimeout(\n 1000,\n execAsync(cmdLine, true),\n )\n .then(async p => await p)\n .catch<undefined>(catchEBUSY);\n }\n\n // todo: consider -getResultOutputFile:file\n // Redirect output from get* into a file.\n //\n // Example:\n // -getProperty:Bar -getResultOutputFile:Biz.txt\n // This writes the value of property Bar into Biz.txt.\n\n /**\n * The following issues have triggered this code path:\n * - BaseIntermediateOutputPath must use Unix path separators ('/') on all\n * platforms. Even Windows. Otherwise, MSBuild/dotnet will error-exit with\n * \"The BaseIntermediateOutputPath must end with a trailing slash\".\n */\n if (stdio.stdout.startsWith('MSBuild version')) {\n warn(stdio.stdout);\n throw new Error(\n 'dotnet msbuild was expected to output JSON, but output its version header instead.',\n );\n }\n\n let rawOutput: ConstructorParameters<typeof MSBuildEvaluationOutput>[0];\n if (stdio.stdout.startsWith('{')) {\n /** stdout is JSON string */\n rawOutput = stdio.stdout;\n }\n else if (options.GetProperty.length > 0 && options.GetProperty[0] !== undefined) {\n rawOutput = {\n Properties: {\n [options.GetProperty[0]]: String(JSON.parse(stdio.stdout)),\n },\n };\n }\n else {\n throw new Error('Dotnet/MSBuild evaluation output is not a string nor JSON object or array.');\n }\n\n const evaluation = new MSBuildEvaluationOutput(rawOutput);\n\n return new MSBuildProject({\n fullPath: options.FullName,\n projTargets: await MSBuildProject.GetTargets(options.FullName),\n evaluation,\n });\n }\n\n /**\n * Evaluate multiple project paths with some default Evaluate options.\n * @async\n * @param projectsToPackAndPush An array of MSBuild projects' full file\n * paths. If a path is a directory, files in that directory are filtered for\n * `.csproj`, `.fsproj`, and `.vbproj` project files.\n * See https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\\\n * @returns A promised array of {@link MSBuildProject} instances.\n * All known MSBuild and NuGet properties are evaluated.\n * If applicable, a project's \"Pack\" target is evaluated.\n */\n public static async PackableProjectsToMSBuildProjects(\n projectsToPackAndPush: string[],\n ): Promise<Promise<MSBuildProject>[]> {\n const dirEntriesPromise = toDirEntries(typeof projectsToPackAndPush === 'string' ? [projectsToPackAndPush] : projectsToPackAndPush);\n const projectPromises: Promise<MSBuildProject>[] = await dirEntriesPromise\n .then(\n (direntArray: Dirent[]) =>\n direntArray.map(element => convertDirentToMSBuildProject(element)),\n );\n return projectPromises;\n\n /**\n * Map an array of filesystem paths to {@link Dirent} instances representing project files.\n * @param projectsToPackAndPush An array of MSBuild projects' full file\n * paths. If a path is a directory, files in that directory are filtered for\n * `.csproj`, `.fsproj`, and `.vbproj` project files. See\n * https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\\\n * @returns An promised array of Dirent instances for discovered project files.\n */\n async function toDirEntries(\n projectsToPackAndPush: string[],\n ): Promise<Dirent[]> {\n const dirEntries: (Dirent | Dirent[])[] = await Promise.all(\n projectsToPackAndPush.map(async (proj) => {\n proj = await realpath(makeAbsolute(proj));\n const stats = await stat(proj);\n let entries: Dirent[];\n\n if (stats.isFile()) {\n entries = await readdir(path.dirname(proj), { withFileTypes: true });\n const dirent: Dirent | undefined = entries.find(v =>\n path.join(\n // condition required for compatibility. `.path` was deprecated, but `.parentPath` is not available in our node minversion\n ('path' in v ? v.path as string | undefined : undefined) ?? (v as unknown as Omit<typeof v, 'path'> & { parentPath: string }).parentPath,\n v.name,\n ) === proj,\n );\n if (dirent)\n return dirent;\n else\n throw new Error(\n `file \"${proj}\" not found. It may have been moved or deleted.`,\n );\n }\n if (!stats.isDirectory())\n throw new Error(`\"${proj}\" is not a file or directory`);\n\n entries = await readdir(proj, { withFileTypes: true });\n return entries.filter(v =>\n v.isFile()\n && (v.name.endsWith('.csproj') || v.name.endsWith('.fsproj') || v.name.endsWith('.vbproj')),\n );\n }),\n );\n\n return dirEntries.flat();\n }\n\n /**\n * Map a {@link Dirent} instance to an {@link MSBuildProject} instance.\n * @param dirent A {@link Dirent} instance. This instance should be an MSBuild project file.\n * @returns An instance of {@link MSBuildProject} evaluated with the `Pack` target result, if applicable. Evaluated properties will be those whose names are returned by {@link NPPGetterNames.InstanceGettersRecursive}.\n */\n async function convertDirentToMSBuildProject(dirent: Dirent): Promise<MSBuildProject> {\n const fullPath = path.join(\n // condition required for compatibility. `.path` was deprecated, but `.parentPath` is not available in our node minversion\n ('path' in dirent ? dirent.path as string | undefined : undefined) ?? (dirent as unknown as Omit<typeof dirent, 'path'> & { parentPath: string }).parentPath,\n dirent.name,\n );\n const projTargets: Promise<string[]> = MSBuildProject.GetTargets(fullPath);\n const evalTargets = await projTargets.then(v =>\n v.includes('Pack') ? ['Pack'] : [],\n );\n // this might be too long for a command line. What was it on Windows?\n // 2^15 (32,768) character limit for command lines?\n const getProperties = NPPGetterNames.InstanceGettersRecursive;\n\n return await MSBuildProject.Evaluate(\n EvaluationOptions.from({\n FullName: fullPath,\n GetItem: [],\n GetProperty: getProperties,\n GetTargetResult: [],\n Property: {},\n Targets: evalTargets,\n }),\n );\n }\n }\n\n public static fromJSON(json: string): MSBuildProject {\n const parsed = T_PseudoMSBPInstance.assert(JSON.parse(json));\n\n type.true.assert(\n Reflect.setPrototypeOf(parsed, MSBuildProject.prototype),\n );\n type.true.assert(\n Reflect.setPrototypeOf(parsed.Properties, NugetProjectProperties.prototype),\n );\n parsed.Properties = T_NPP.assert(parsed.Properties);\n return T_MSBuildProject.assert(parsed);\n }\n}\n\nconst T_MSBuildProject = type.instanceOf(MSBuildProject);\nconst T_NPP = type.instanceOf(NugetProjectProperties);\nconst T_PseudoMSBPInstance = type({\n Items: type({\n '[string]': type({\n '[string]': 'string',\n Identity: 'string',\n FullPath: 'string',\n RootDir: 'string',\n Filename: 'string',\n Extension: 'string',\n RelativeDir: 'string',\n Directory: 'string',\n RecursiveDir: 'string',\n ModifiedTime: 'string',\n CreatedTime: 'string',\n AccessedTime: 'string',\n DefiningProjectFullPath: 'string',\n DefiningProjectDirectory: 'string',\n DefiningProjectName: 'string',\n DefiningProjectExtension: 'string',\n 'SubType?': ' string | undefined',\n 'TargetFrameworkIdentifier?': 'string | undefined',\n 'TargetPlatformMoniker?': 'string | undefined',\n 'CopyUpToDateMarker?': 'string | undefined',\n 'TargetPlatformIdentifier?': 'string | undefined',\n 'TargetFrameworkVersion?': 'string | undefined',\n 'ReferenceAssembly?': 'string | undefined',\n }).array(),\n }),\n Properties: type.Record('string', 'string').or(T_NPP),\n Targets: type.string.array(),\n TargetResults: msbuildEvaluationOutput.get('TargetResults').exclude('undefined').array(),\n\n});\n\n/**\n * ArkType type definitions for internal usage, but may be re-used elsewhere\n * @internal\n */\nexport const _InternalMSBuildEvaluationTypes: Scope<{\n msbuildEvaluationOutput: {\n Properties?: Record<string, string> | undefined;\n Items?: Record<string, {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string | undefined;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[]> | undefined;\n TargetResults?: Record<string, {\n Result: 'Success';\n Items: {\n [x: string]: string | undefined;\n Identity: string;\n FullPath: string;\n RootDir: string;\n Filename: string;\n Extension: string;\n RelativeDir: string;\n Directory: string;\n RecursiveDir: string;\n ModifiedTime: string;\n CreatedTime: string;\n AccessedTime: string;\n DefiningProjectFullPath: string;\n DefiningProjectDirectory: string;\n DefiningProjectName: string;\n DefiningProjectExtension: string;\n SubType?: string | undefined;\n TargetFrameworkIdentifier?: string | undefined;\n TargetPlatformMoniker?: string | undefined;\n CopyUpToDateMarker?: string | undefined;\n TargetPlatformIdentifier?: string | undefined;\n TargetFrameworkVersion?: string | undefined;\n ReferenceAssembly?: string | undefined;\n }[];\n } | {\n Result: 'Failure';\n Items: never[];\n }> | undefined;\n };\n}> = type.scope({\n msbuildEvaluationOutput,\n});\n\n/**\n * Resolve a path if it is not already absolute.\n * @param _path A filesystem path.\n * @returns A full path to a filesystem entry. The path is unchecked for whether or not the path (or its parts) exist.\n */\nfunction makeAbsolute(_path: string) {\n return path.isAbsolute(_path) ? _path : path.resolve(_path);\n}\n\n/**\n * Use this in your catch statement or .catch call to return `undefined` when\n * a \"file in use by another process\" (i.e. EBUSY/ERROR_SHARING_VIOLATION) error is reported.\n * @param error Probably an Error object\n * @returns `undefined` if file in use by another process\n */\nexport function catchEBUSY(error: unknown): undefined {\n if (isError(error)) {\n if ('stderr' in error && typeof error.stderr === 'string') {\n // Normalize colon-like chars: '\\uFF1A'.normalize('NFKC') === ':' === true;\n const normalizedStderr = error.stderr.normalize('NFKC');\n const patternEN = /The process cannot access the file '[^']+' because it is being used by another process\\./gm;\n const hasErrMsgPattern = patternEN.test(normalizedStderr);\n const isCS2012 = /^CSC ?:.+CS2012:/gm.test(normalizedStderr);\n // generic error code; error message must be checked.\n const isAVLN9999 = /AVLN9999:/gm.test(normalizedStderr)\n && hasErrMsgPattern;\n if (isCS2012 || isAVLN9999 || hasErrMsgPattern)\n return undefined; /* retry */\n }\n /**\n * some known warnings/errors:\n * - warning MSB3073:\n * The command \"dotnet tool list kuinox.nupkgdeterministicator\"\n * exited with code 145.\n * > $ dotnet tool list kuinox.nupkgdeterministicator\n * > The command could not be loaded, possibly because:\n * > * You intended to execute a .NET application:\n * > The application 'tool' does not exist.\n * > * You intended to execute a .NET SDK command:\n * > No .NET SDKs were found.\n * >\n * > Download a .NET SDK:\n * > https://aka.ms/dotnet/download\n * >\n * > Learn about SDK resolution:\n * > https://aka.ms/dotnet/sdk-not-found\n */\n else throw error;\n }\n else throw new Error('unknown error', { cause: error });\n}\n\n/**\n *\n * Use this in your catch statement or .catch call to return `undefined` when\n * MSBuild error CSC2012 (e.g. \"file in use by another process\") is reported.\n * @param error Probably an Error object\n * @returns `undefined` if CSC2012 (file in use by another process) occurs\n * @deprecated Use {@link catchEBUSY}.\n */\nexport function catchCsc2012(error: unknown): undefined {\n if (isError(error)) {\n // check for error reported when \"file in use by another process\" i.e. EBUSY\n // (UNIX), NTSTATUS.ERROR_SHARING_VIOLATION == 0x20 == 32 (Windows)\n if ('stderr' in error && typeof error.stderr === 'string'\n && /^CSC ?:.+CS2012:/gm.test(\n // '\\uFF1A'.normalize('NFKC') === ':' === true;\n error.stderr.normalize('NFKC'),\n )\n ) {\n return undefined; /* retry */\n }\n /**\n * some known warnings/errors:\n * - warning MSB3073:\n * The command \"dotnet tool list kuinox.nupkgdeterministicator\"\n * exited with code 145.\n * > $ dotnet tool list kuinox.nupkgdeterministicator\n * > The command could not be loaded, possibly because:\n * > * You intended to execute a .NET application:\n * > The application 'tool' does not exist.\n * > * You intended to execute a .NET SDK command:\n * > No .NET SDKs were found.\n * >\n * > Download a .NET SDK:\n * > https://aka.ms/dotnet/download\n * >\n * > Learn about SDK resolution:\n * > https://aka.ms/dotnet/sdk-not-found\n */\n else throw error;\n }\n else throw new Error('unknown error', { cause: error });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,gCAAgC,KAAK;CACzC,YAAY;CAEZ,UAAU;CAEV,YAAY;CAEZ,8BAA8B;CAC9B,0BAA0B;CAE1B,uBAAuB;CACvB,6BAA6B;CAE7B,2BAA2B;CAE3B,sBAAsB;CAEtB,UAAU;CAEV,SAAS;CAET,UAAU;CAEV,WAAW;CAEX,aAAa;CAEb,WAAW;CACX,cAAc;CAEd,cAAc;CAEd,aAAa;CAEb,cAAc;CAEd,yBAAyB;CAEzB,0BAA0B;CAE1B,qBAAqB;CAErB,0BAA0B;CAC3B,CAAC;AAEF,MAAM,gBAAgB,KAAK;CACzB,QAAQ;CACR,OAAO,8BAA8B,OAAO;CAC7C,CAAC;AAEF,MAAM,gBAAgB,KAAK;CACzB,QAAQ;CACR,OAAO;CACR,CAAC;AAEF,MAAM,0BA0DD,KAAK;CACR,eAAe,KAAK,EAAE,YAAY,UAAU,CAAC;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