@halospv3/hce.shared-config 2.6.4 → 3.0.0-develop.10

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 (310) hide show
  1. package/CHANGELOG.md +452 -101
  2. package/README.md +100 -87
  3. package/dotnet/.github/workflows/_unit_test.yml +3 -3
  4. package/dotnet/.github/workflows/ci.yml +2 -2
  5. package/dotnet/.github/workflows/dotnet-release.yml +28 -28
  6. package/dotnet/.github/workflows/sample-dotnet-build.yml +13 -11
  7. package/dotnet/ExecNupkgDeterministicator.README.md +20 -0
  8. package/dotnet/ExecNupkgDeterministicator.targets +173 -0
  9. package/dotnet/GitVersion.yml +3 -1
  10. package/dotnet/GitVersion6.0.yml +3 -1
  11. package/dotnet/HCE.Shared.sln +34 -0
  12. package/dotnet/HCE.Shared.targets +1 -0
  13. package/dotnet/PublishAll.targets +2 -0
  14. package/dotnet/SignAfterPack.targets +104 -0
  15. package/dotnet/samples/HCE.Shared.DeterministicNupkg/Dummy.cs +6 -0
  16. package/dotnet/samples/HCE.Shared.DeterministicNupkg/HCE.Shared.DeterministicNupkg.csproj +21 -0
  17. package/dotnet/samples/HCE.Shared.SignAfterPack/Class1.cs +6 -0
  18. package/dotnet/samples/HCE.Shared.SignAfterPack/HCE.Shared.SignAfterPack.csproj +21 -0
  19. package/dotnet/samples/HCE.Shared.SignAfterPack/sampleCert.samplepfx +0 -0
  20. package/dotnet/samples/README.md +7 -0
  21. package/mjs/CaseInsensitiveMap.d.ts +12 -0
  22. package/mjs/CaseInsensitiveMap.d.ts.map +1 -0
  23. package/mjs/CaseInsensitiveMap.mjs +33 -0
  24. package/mjs/CaseInsensitiveMap.mjs.map +1 -0
  25. package/mjs/commitlintConfig.d.ts +12 -0
  26. package/mjs/commitlintConfig.d.ts.map +1 -0
  27. package/{cjs/commitlintConfig.cjs → mjs/commitlintConfig.mjs} +3 -4
  28. package/mjs/commitlintConfig.mjs.map +1 -0
  29. package/mjs/debug.d.ts +4 -0
  30. package/{cjs → mjs}/debug.d.ts.map +1 -1
  31. package/mjs/debug.mjs +7 -0
  32. package/mjs/debug.mjs.map +1 -0
  33. package/mjs/dotnet/GithubNugetRegistryInfo.d.ts +38 -0
  34. package/mjs/dotnet/GithubNugetRegistryInfo.d.ts.map +1 -0
  35. package/mjs/dotnet/GithubNugetRegistryInfo.mjs +43 -0
  36. package/mjs/dotnet/GithubNugetRegistryInfo.mjs.map +1 -0
  37. package/mjs/dotnet/GitlabNugetRegistryInfo.d.ts +62 -0
  38. package/mjs/dotnet/GitlabNugetRegistryInfo.d.ts.map +1 -0
  39. package/mjs/dotnet/GitlabNugetRegistryInfo.mjs +99 -0
  40. package/mjs/dotnet/GitlabNugetRegistryInfo.mjs.map +1 -0
  41. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.d.ts +2 -0
  42. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.d.ts.map +1 -0
  43. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs +26 -0
  44. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs.map +1 -0
  45. package/mjs/dotnet/MSBuildProject.d.ts +256 -0
  46. package/mjs/dotnet/MSBuildProject.d.ts.map +1 -0
  47. package/mjs/dotnet/MSBuildProject.mjs +447 -0
  48. package/mjs/dotnet/MSBuildProject.mjs.map +1 -0
  49. package/mjs/dotnet/MSBuildProjectProperties.d.ts +170 -0
  50. package/mjs/dotnet/MSBuildProjectProperties.d.ts.map +1 -0
  51. package/mjs/dotnet/MSBuildProjectProperties.mjs +260 -0
  52. package/mjs/dotnet/MSBuildProjectProperties.mjs.map +1 -0
  53. package/mjs/dotnet/NugetProjectProperties.d.ts +379 -0
  54. package/mjs/dotnet/NugetProjectProperties.d.ts.map +1 -0
  55. package/mjs/dotnet/NugetProjectProperties.mjs +577 -0
  56. package/mjs/dotnet/NugetProjectProperties.mjs.map +1 -0
  57. package/mjs/dotnet/NugetRegistryInfo.d.ts +384 -0
  58. package/mjs/dotnet/NugetRegistryInfo.d.ts.map +1 -0
  59. package/mjs/dotnet/NugetRegistryInfo.mjs +752 -0
  60. package/mjs/dotnet/NugetRegistryInfo.mjs.map +1 -0
  61. package/mjs/dotnet/helpers.d.ts +63 -0
  62. package/mjs/dotnet/helpers.d.ts.map +1 -0
  63. package/mjs/dotnet/helpers.mjs +354 -0
  64. package/mjs/dotnet/helpers.mjs.map +1 -0
  65. package/mjs/dotnet/index.d.ts +17 -0
  66. package/mjs/dotnet/index.d.ts.map +1 -0
  67. package/mjs/dotnet/index.mjs +9 -0
  68. package/mjs/dotnet/index.mjs.map +1 -0
  69. package/mjs/dotnet.d.ts +3 -0
  70. package/mjs/dotnet.d.ts.map +1 -0
  71. package/mjs/dotnet.mjs +9 -0
  72. package/mjs/dotnet.mjs.map +1 -0
  73. package/mjs/eslintConfig.d.ts +4 -0
  74. package/mjs/eslintConfig.d.ts.map +1 -0
  75. package/mjs/eslintConfig.mjs +98 -0
  76. package/mjs/eslintConfig.mjs.map +1 -0
  77. package/mjs/index.d.ts +3 -0
  78. package/mjs/index.d.ts.map +1 -0
  79. package/mjs/index.mjs +4 -0
  80. package/mjs/index.mjs.map +1 -0
  81. package/mjs/insertPlugins.d.ts +18 -0
  82. package/mjs/insertPlugins.d.ts.map +1 -0
  83. package/mjs/insertPlugins.mjs +73 -0
  84. package/mjs/insertPlugins.mjs.map +1 -0
  85. package/mjs/semantic-release__commit-analyzer.d.mjs +2 -0
  86. package/mjs/semantic-release__commit-analyzer.d.mjs.map +1 -0
  87. package/mjs/semantic-release__exec.d.mjs +2 -0
  88. package/mjs/semantic-release__exec.d.mjs.map +1 -0
  89. package/mjs/semantic-release__git.d.mjs +2 -0
  90. package/mjs/semantic-release__git.d.mjs.map +1 -0
  91. package/mjs/semantic-release__github.d.mjs +2 -0
  92. package/mjs/semantic-release__github.d.mjs.map +1 -0
  93. package/mjs/semanticReleaseConfig.d.ts +97 -0
  94. package/mjs/semanticReleaseConfig.d.ts.map +1 -0
  95. package/mjs/semanticReleaseConfig.mjs +63 -0
  96. package/mjs/semanticReleaseConfig.mjs.map +1 -0
  97. package/mjs/semanticReleaseConfigDotnet.d.ts +109 -0
  98. package/mjs/semanticReleaseConfigDotnet.d.ts.map +1 -0
  99. package/mjs/semanticReleaseConfigDotnet.mjs +267 -0
  100. package/mjs/semanticReleaseConfigDotnet.mjs.map +1 -0
  101. package/mjs/setupGitPluginSpec.d.ts +22 -0
  102. package/mjs/setupGitPluginSpec.d.ts.map +1 -0
  103. package/mjs/setupGitPluginSpec.mjs +144 -0
  104. package/mjs/setupGitPluginSpec.mjs.map +1 -0
  105. package/mjs/utils/Exact.d.ts +20 -0
  106. package/mjs/utils/Exact.d.ts.map +1 -0
  107. package/mjs/utils/Exact.mjs +75 -0
  108. package/mjs/utils/Exact.mjs.map +1 -0
  109. package/mjs/utils/GracefulRecursion.d.mjs +2 -0
  110. package/mjs/utils/GracefulRecursion.d.mjs.map +1 -0
  111. package/mjs/utils/env.d.ts +24 -0
  112. package/mjs/utils/env.d.ts.map +1 -0
  113. package/mjs/utils/env.mjs +39 -0
  114. package/mjs/utils/env.mjs.map +1 -0
  115. package/mjs/utils/execAsync.d.ts +37 -0
  116. package/mjs/utils/execAsync.d.ts.map +1 -0
  117. package/mjs/utils/execAsync.mjs +59 -0
  118. package/mjs/utils/execAsync.mjs.map +1 -0
  119. package/mjs/utils/miscTypes.d.ts +13 -0
  120. package/mjs/utils/miscTypes.d.ts.map +1 -0
  121. package/mjs/utils/miscTypes.mjs +10 -0
  122. package/mjs/utils/miscTypes.mjs.map +1 -0
  123. package/mjs/utils/reflection/FunctionLike.d.mjs +2 -0
  124. package/mjs/utils/reflection/FunctionLike.d.mjs.map +1 -0
  125. package/mjs/utils/reflection/GetterDescriptor.d.mjs +2 -0
  126. package/mjs/utils/reflection/GetterDescriptor.d.mjs.map +1 -0
  127. package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mjs +2 -0
  128. package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mjs.map +1 -0
  129. package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mjs +2 -0
  130. package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mjs.map +1 -0
  131. package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mjs +2 -0
  132. package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mjs.map +1 -0
  133. package/mjs/utils/reflection/OwnKeyOf.d.mjs +2 -0
  134. package/mjs/utils/reflection/OwnKeyOf.d.mjs.map +1 -0
  135. package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mjs +2 -0
  136. package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mjs.map +1 -0
  137. package/mjs/utils/reflection/PropertyDescriptorMap.d.mjs +2 -0
  138. package/mjs/utils/reflection/PropertyDescriptorMap.d.mjs.map +1 -0
  139. package/mjs/utils/reflection/filterForGetters.d.ts +7 -0
  140. package/mjs/utils/reflection/filterForGetters.d.ts.map +1 -0
  141. package/mjs/utils/reflection/filterForGetters.mjs +27 -0
  142. package/mjs/utils/reflection/filterForGetters.mjs.map +1 -0
  143. package/mjs/utils/reflection/getOwnPropertyDescriptors.d.ts +22 -0
  144. package/mjs/utils/reflection/getOwnPropertyDescriptors.d.ts.map +1 -0
  145. package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs +34 -0
  146. package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs.map +1 -0
  147. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.ts +56 -0
  148. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.ts.map +1 -0
  149. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs +72 -0
  150. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs.map +1 -0
  151. package/mjs/utils/reflection/getPrototypeChainOf.d.ts +16 -0
  152. package/mjs/utils/reflection/getPrototypeChainOf.d.ts.map +1 -0
  153. package/mjs/utils/reflection/getPrototypeChainOf.mjs +55 -0
  154. package/mjs/utils/reflection/getPrototypeChainOf.mjs.map +1 -0
  155. package/mjs/utils/reflection/getPrototypeOf.d.ts +8 -0
  156. package/mjs/utils/reflection/getPrototypeOf.d.ts.map +1 -0
  157. package/mjs/utils/reflection/getPrototypeOf.mjs +10 -0
  158. package/mjs/utils/reflection/getPrototypeOf.mjs.map +1 -0
  159. package/mjs/utils/reflection/inheritance.d.ts +180 -0
  160. package/mjs/utils/reflection/inheritance.d.ts.map +1 -0
  161. package/mjs/utils/reflection/inheritance.mjs +148 -0
  162. package/mjs/utils/reflection/inheritance.mjs.map +1 -0
  163. package/mjs/utils/reflection/isConstructor.d.ts +17 -0
  164. package/mjs/utils/reflection/isConstructor.d.ts.map +1 -0
  165. package/mjs/utils/reflection/isConstructor.mjs +63 -0
  166. package/mjs/utils/reflection/isConstructor.mjs.map +1 -0
  167. package/mjs/utils/reflection/isGetterDescriptor.d.ts +9 -0
  168. package/mjs/utils/reflection/isGetterDescriptor.d.ts.map +1 -0
  169. package/mjs/utils/reflection/isGetterDescriptor.mjs +12 -0
  170. package/mjs/utils/reflection/isGetterDescriptor.mjs.map +1 -0
  171. package/mjs/utils/reflection/listOwnGetters.d.ts +26 -0
  172. package/mjs/utils/reflection/listOwnGetters.d.ts.map +1 -0
  173. package/mjs/utils/reflection/listOwnGetters.mjs +39 -0
  174. package/mjs/utils/reflection/listOwnGetters.mjs.map +1 -0
  175. package/mjs/utils/reflection.d.ts +18 -0
  176. package/mjs/utils/reflection.d.ts.map +1 -0
  177. package/mjs/utils/reflection.mjs +10 -0
  178. package/mjs/utils/reflection.mjs.map +1 -0
  179. package/package.json +77 -78
  180. package/src/CaseInsensitiveMap.ts +34 -0
  181. package/src/commitlintConfig.ts +17 -9
  182. package/src/debug.ts +4 -4
  183. package/src/dotnet/GithubNugetRegistryInfo.ts +68 -0
  184. package/src/dotnet/GitlabNugetRegistryInfo.ts +126 -0
  185. package/src/dotnet/IsNextVersionAlreadyPublished.cli.ts +44 -0
  186. package/src/dotnet/MSBuildProject.ts +702 -76
  187. package/src/dotnet/MSBuildProjectProperties.ts +281 -15
  188. package/src/dotnet/NugetProjectProperties.ts +609 -0
  189. package/src/dotnet/NugetRegistryInfo.ts +1025 -0
  190. package/src/dotnet/helpers.ts +479 -0
  191. package/src/dotnet/index.ts +17 -0
  192. package/src/dotnet.ts +2 -6
  193. package/src/eslintConfig.ts +174 -71
  194. package/src/index.ts +1 -3
  195. package/src/insertPlugins.ts +116 -0
  196. package/src/semantic-release__commit-analyzer.d.ts +44 -38
  197. package/src/semantic-release__exec.d.ts +15 -0
  198. package/src/semantic-release__git.d.ts +85 -88
  199. package/src/semantic-release__github.d.ts +139 -139
  200. package/src/semanticReleaseConfig.ts +111 -47
  201. package/src/semanticReleaseConfigDotnet.ts +397 -104
  202. package/src/setupGitPluginSpec.ts +153 -58
  203. package/src/tsconfig.json +8 -8
  204. package/src/utils/Exact.ts +49 -0
  205. package/src/utils/GracefulRecursion.d.ts +12 -0
  206. package/src/utils/env.ts +44 -0
  207. package/src/utils/execAsync.ts +89 -0
  208. package/src/utils/miscTypes.ts +18 -0
  209. package/src/utils/reflection/FunctionLike.d.ts +17 -0
  210. package/src/utils/reflection/GetterDescriptor.d.ts +8 -0
  211. package/src/utils/reflection/InstancePropertyDescriptorMap.d.ts +32 -0
  212. package/src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts +20 -0
  213. package/src/utils/reflection/OwnGetterDescriptorMap.d.ts +17 -0
  214. package/src/utils/reflection/OwnKeyOf.d.ts +20 -0
  215. package/src/utils/reflection/OwnPropertyDescriptorMap.d.ts +82 -0
  216. package/src/utils/reflection/PropertyDescriptorMap.d.ts +15 -0
  217. package/src/utils/reflection/filterForGetters.ts +59 -0
  218. package/src/utils/reflection/getOwnPropertyDescriptors.ts +52 -0
  219. package/src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts +127 -0
  220. package/src/utils/reflection/getPrototypeChainOf.ts +85 -0
  221. package/src/utils/reflection/getPrototypeOf.ts +12 -0
  222. package/src/utils/reflection/inheritance.ts +262 -0
  223. package/src/utils/reflection/isConstructor.ts +74 -0
  224. package/src/utils/reflection/isGetterDescriptor.ts +11 -0
  225. package/src/utils/reflection/listOwnGetters.ts +80 -0
  226. package/src/utils/reflection.ts +18 -0
  227. package/cjs/commitlintConfig-wrapper.mjs +0 -6
  228. package/cjs/commitlintConfig.cjs.map +0 -1
  229. package/cjs/commitlintConfig.d.ts +0 -4
  230. package/cjs/commitlintConfig.d.ts.map +0 -1
  231. package/cjs/debug.cjs +0 -13
  232. package/cjs/debug.cjs.map +0 -1
  233. package/cjs/debug.d.ts +0 -4
  234. package/cjs/dotnet/MSBuildProject.cjs +0 -84
  235. package/cjs/dotnet/MSBuildProject.cjs.map +0 -1
  236. package/cjs/dotnet/MSBuildProject.d.ts +0 -42
  237. package/cjs/dotnet/MSBuildProject.d.ts.map +0 -1
  238. package/cjs/dotnet/MSBuildProjectProperties.cjs +0 -22
  239. package/cjs/dotnet/MSBuildProjectProperties.cjs.map +0 -1
  240. package/cjs/dotnet/MSBuildProjectProperties.d.ts +0 -13
  241. package/cjs/dotnet/MSBuildProjectProperties.d.ts.map +0 -1
  242. package/cjs/dotnet/createDummyNupkg.cjs +0 -26
  243. package/cjs/dotnet/createDummyNupkg.cjs.map +0 -1
  244. package/cjs/dotnet/createDummyNupkg.d.ts +0 -2
  245. package/cjs/dotnet/createDummyNupkg.d.ts.map +0 -1
  246. package/cjs/dotnet/dotnetGHPR.cjs +0 -173
  247. package/cjs/dotnet/dotnetGHPR.cjs.map +0 -1
  248. package/cjs/dotnet/dotnetGHPR.d.ts +0 -37
  249. package/cjs/dotnet/dotnetGHPR.d.ts.map +0 -1
  250. package/cjs/dotnet/dotnetGLPR.cjs +0 -41
  251. package/cjs/dotnet/dotnetGLPR.cjs.map +0 -1
  252. package/cjs/dotnet/dotnetGLPR.d.ts +0 -13
  253. package/cjs/dotnet/dotnetGLPR.d.ts.map +0 -1
  254. package/cjs/dotnet/dotnetHelpers.cjs +0 -141
  255. package/cjs/dotnet/dotnetHelpers.cjs.map +0 -1
  256. package/cjs/dotnet/dotnetHelpers.d.ts +0 -26
  257. package/cjs/dotnet/dotnetHelpers.d.ts.map +0 -1
  258. package/cjs/dotnet-wrapper.mjs +0 -6
  259. package/cjs/dotnet.cjs +0 -15
  260. package/cjs/dotnet.cjs.map +0 -1
  261. package/cjs/dotnet.d.ts +0 -7
  262. package/cjs/dotnet.d.ts.map +0 -1
  263. package/cjs/envUtils-wrapper.mjs +0 -6
  264. package/cjs/envUtils.cjs +0 -37
  265. package/cjs/envUtils.cjs.map +0 -1
  266. package/cjs/envUtils.d.ts +0 -15
  267. package/cjs/envUtils.d.ts.map +0 -1
  268. package/cjs/eslintConfig-wrapper.mjs +0 -6
  269. package/cjs/eslintConfig.cjs +0 -52
  270. package/cjs/eslintConfig.cjs.map +0 -1
  271. package/cjs/eslintConfig.d.ts +0 -3
  272. package/cjs/eslintConfig.d.ts.map +0 -1
  273. package/cjs/findStaticConfig-wrapper.mjs +0 -6
  274. package/cjs/findStaticConfig.cjs +0 -34
  275. package/cjs/findStaticConfig.cjs.map +0 -1
  276. package/cjs/findStaticConfig.d.ts +0 -2
  277. package/cjs/findStaticConfig.d.ts.map +0 -1
  278. package/cjs/index-wrapper.mjs +0 -6
  279. package/cjs/index.cjs +0 -10
  280. package/cjs/index.cjs.map +0 -1
  281. package/cjs/index.d.ts +0 -5
  282. package/cjs/index.d.ts.map +0 -1
  283. package/cjs/semantic-release__commit-analyzer.d.cjs +0 -2
  284. package/cjs/semantic-release__commit-analyzer.d.cjs.map +0 -1
  285. package/cjs/semantic-release__git.d.cjs +0 -2
  286. package/cjs/semantic-release__git.d.cjs.map +0 -1
  287. package/cjs/semantic-release__github.d.cjs +0 -2
  288. package/cjs/semantic-release__github.d.cjs.map +0 -1
  289. package/cjs/semanticReleaseConfig-wrapper.mjs +0 -6
  290. package/cjs/semanticReleaseConfig.cjs +0 -33
  291. package/cjs/semanticReleaseConfig.cjs.map +0 -1
  292. package/cjs/semanticReleaseConfig.d.ts +0 -4
  293. package/cjs/semanticReleaseConfig.d.ts.map +0 -1
  294. package/cjs/semanticReleaseConfigDotnet-wrapper.mjs +0 -7
  295. package/cjs/semanticReleaseConfigDotnet.cjs +0 -112
  296. package/cjs/semanticReleaseConfigDotnet.cjs.map +0 -1
  297. package/cjs/semanticReleaseConfigDotnet.d.ts +0 -51
  298. package/cjs/semanticReleaseConfigDotnet.d.ts.map +0 -1
  299. package/cjs/setupGitPluginSpec-wrapper.mjs +0 -6
  300. package/cjs/setupGitPluginSpec.cjs +0 -67
  301. package/cjs/setupGitPluginSpec.cjs.map +0 -1
  302. package/cjs/setupGitPluginSpec.d.ts +0 -19
  303. package/cjs/setupGitPluginSpec.d.ts.map +0 -1
  304. package/src/dotnet/createDummyNupkg.ts +0 -30
  305. package/src/dotnet/dotnetGHPR.ts +0 -232
  306. package/src/dotnet/dotnetGLPR.ts +0 -46
  307. package/src/dotnet/dotnetHelpers.ts +0 -184
  308. package/src/envUtils.ts +0 -36
  309. package/src/findStaticConfig.ts +0 -31
  310. package/static/.releaserc.yml +0 -35
@@ -1,83 +1,709 @@
1
- import { execFileSync } from 'node:child_process';
1
+ import { type, type Scope } from 'arktype';
2
+ import { warn } from 'node:console';
3
+ import { type Dirent } from 'node:fs';
4
+ import { readdir, realpath, stat } from 'node:fs/promises';
5
+ import path from 'node:path';
6
+ import { setTimeout } from 'node:timers/promises';
7
+ import { isNativeError } from 'node:util/types';
8
+ import { CaseInsensitiveMap } from '../CaseInsensitiveMap.js';
9
+ import { execAsync } from '../utils/execAsync.js';
2
10
  import { MSBuildProjectProperties } from './MSBuildProjectProperties.js';
11
+ import {
12
+ NPPGetterNames,
13
+ NugetProjectProperties,
14
+ } from './NugetProjectProperties.js';
15
+ import type { ObjectType } from 'arktype/internal/methods/object.ts';
3
16
 
4
17
  /**
5
- * All pre-defined properties of {@link MSBuildProjectProperties} except FullPath
18
+ * See [MSBuild well-known item metadata](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata).
19
+ * Additional string-type properties may be present (e.g. `{ SubType: "designer" }`).
6
20
  */
7
- export const MSBuildProjectPreDefinedProperties = Object.keys(
8
- new MSBuildProjectProperties('', false),
9
- ).filter((p) => p !== 'FullPath');
10
- /** @todo Experimental and may be removed in a later release.
11
- * A cache for your evaluated MSBuild Projects.
12
- */
13
- export const MSBuildEvaluatedProjects: MSBuildProject[] = [];
21
+ const interface_ItemMetadataBuiltIn = type({
22
+ '[string]': 'string',
23
+ /** @example "c:\\source\\repos\\ConsoleApp1\\ConsoleApp1\\bin\\Debug\\net6.0\\ConsoleApp1.dll" */
24
+ Identity: 'string',
25
+ /** @example "Designer" */
26
+ 'SubType?': 'string',
27
+ /** @example ".NETCoreApp" */
28
+ 'TargetFrameworkIdentifier?': 'string',
29
+ 'TargetPlatformMoniker?': 'string',
30
+ /** @example "c:\\source\\repos\\ConsoleApp1\\ConsoleApp1\\obj\\Debug\\net6.0\\ConsoleApp1.csproj.CopyComplete" */
31
+ 'CopyUpToDateMarker?': 'string',
32
+ 'TargetPlatformIdentifier?': 'string',
33
+ /** @example "6.0" */
34
+ 'TargetFrameworkVersion?': 'string',
35
+ /** @example "c:\\source\\repos\\ConsoleApp1\\ConsoleApp1\\obj\\Debug\\net6.0\\ref\\ConsoleApp1.dll" */
36
+ 'ReferenceAssembly?': 'string',
37
+ /** @example "c:\\source\\repos\\ConsoleApp1\\ConsoleApp1\\bin\\Debug\\net6.0\\ConsoleApp1.dll" */
38
+ FullPath: 'string',
39
+ /** @example "c:\\" */
40
+ RootDir: 'string',
41
+ /** @example "ConsoleApp1" */
42
+ Filename: 'string',
43
+ /** @example ".dll" */
44
+ Extension: 'string',
45
+ /** @example "c:\\source\\repos\\ConsoleApp1\\ConsoleApp1\\bin\\Debug\\net6.0\\" */
46
+ RelativeDir: 'string',
47
+ /** @example "source\\repos\\ConsoleApp1\\ConsoleApp1\\bin\\Debug\\net6.0\\" */
48
+ Directory: 'string',
49
+ RecursiveDir: 'string',
50
+ /** @example "2023-11-30 13:38:06.5084339" */
51
+ ModifiedTime: 'string',
52
+ /** @example "2023-11-30 13:38:06.9308716" */
53
+ CreatedTime: 'string',
54
+ /** @example "2023-11-30 13:38:06.9318732" */
55
+ AccessedTime: 'string',
56
+ /** @example "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\MSBuild\\Current\\Bin\\amd64\\Microsoft.Common.CurrentVersion.targets" */
57
+ DefiningProjectFullPath: 'string',
58
+ /** @example "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\MSBuild\\Current\\Bin\\amd64\\" */
59
+ DefiningProjectDirectory: 'string',
60
+ /** @example "Microsoft.Common.CurrentVersion" */
61
+ DefiningProjectName: 'string',
62
+ /** @example ".targets" */
63
+ DefiningProjectExtension: 'string',
64
+ });
65
+
66
+ const targetSuccess = type({
67
+ Result: '\'Success\'',
68
+ Items: interface_ItemMetadataBuiltIn.array(),
69
+ });
70
+
71
+ const targetFailure = type({
72
+ Result: '\'Failure\'',
73
+ Items: 'never[]',
74
+ });
75
+
76
+ const msbuildEvaluationOutput: ObjectType<{
77
+ Properties?: Record<string, string> | undefined;
78
+ Items?: Record<string, {
79
+ [x: string]: string | undefined;
80
+ Identity: string;
81
+ FullPath: string;
82
+ RootDir: string;
83
+ Filename: string;
84
+ Extension: string;
85
+ RelativeDir: string;
86
+ Directory: string;
87
+ RecursiveDir: string;
88
+ ModifiedTime: string;
89
+ CreatedTime: string;
90
+ AccessedTime: string;
91
+ DefiningProjectFullPath: string;
92
+ DefiningProjectDirectory: string;
93
+ DefiningProjectName: string;
94
+ DefiningProjectExtension: string;
95
+ SubType?: string;
96
+ TargetFrameworkIdentifier?: string | undefined;
97
+ TargetPlatformMoniker?: string | undefined;
98
+ CopyUpToDateMarker?: string | undefined;
99
+ TargetPlatformIdentifier?: string | undefined;
100
+ TargetFrameworkVersion?: string | undefined;
101
+ ReferenceAssembly?: string | undefined;
102
+ }[]> | undefined;
103
+ TargetResults?: Record<string, {
104
+ Result: 'Success';
105
+ Items: {
106
+ [x: string]: string | undefined;
107
+ Identity: string;
108
+ FullPath: string;
109
+ RootDir: string;
110
+ Filename: string;
111
+ Extension: string;
112
+ RelativeDir: string;
113
+ Directory: string;
114
+ RecursiveDir: string;
115
+ ModifiedTime: string;
116
+ CreatedTime: string;
117
+ AccessedTime: string;
118
+ DefiningProjectFullPath: string;
119
+ DefiningProjectDirectory: string;
120
+ DefiningProjectName: string;
121
+ DefiningProjectExtension: string;
122
+ SubType?: string | undefined;
123
+ TargetFrameworkIdentifier?: string | undefined;
124
+ TargetPlatformMoniker?: string | undefined;
125
+ CopyUpToDateMarker?: string | undefined;
126
+ TargetPlatformIdentifier?: string | undefined;
127
+ TargetFrameworkVersion?: string | undefined;
128
+ ReferenceAssembly?: string | undefined;
129
+ }[];
130
+ } | {
131
+ Result: 'Failure';
132
+ Items: never[];
133
+ }> | undefined;
134
+ }> = type({
135
+ 'Properties?': type({ '[string]': 'string' }),
136
+ 'Items?': type({ '[string]': interface_ItemMetadataBuiltIn.array() }),
137
+ 'TargetResults?': type({ '[string]': targetSuccess.or(targetFailure) }),
138
+ });
139
+
140
+ export class MSBuildEvaluationOutput {
141
+ /**
142
+ * @param rawMSBuildEvaluation The output of a CLI MSBuild project evaluation.
143
+ * May be the UTF-8 string-encoded JSON or the object decoded from that JSON.
144
+ */
145
+ constructor(rawMSBuildEvaluation: Parameters<typeof JSON.parse>[0] | Parameters<typeof msbuildEvaluationOutput.from>[0]) {
146
+ /** `.assert` instead of `.from` to allow `unknown` JSON.parse return type */
147
+ const knownObject = msbuildEvaluationOutput.assert(typeof rawMSBuildEvaluation === 'string' ? JSON.parse(rawMSBuildEvaluation) : rawMSBuildEvaluation);
148
+
149
+ this.Properties = knownObject.Properties;
150
+ this.Items = knownObject.Items;
151
+ this.TargetResults = knownObject.TargetResults;
152
+ }
153
+
154
+ /**
155
+ * The specified properties and their values as evaluated by MSBuild Core.
156
+ * `-getProperty:{propertyName,...}`
157
+ */
158
+ Properties?: typeof msbuildEvaluationOutput.infer.Properties;
159
+ /**
160
+ * The specified items and their values and associated metadata as evaluated
161
+ * by MSBuild Core.
162
+ * `-getItem:{itemName,...}`
163
+ */
164
+ Items?: typeof msbuildEvaluationOutput.infer.Items;
165
+ /**
166
+ * The specified Targets and their output values as evaluated by MSBuild
167
+ * Core.
168
+ * `-getTargetResult:{targetName,...}`
169
+ */
170
+ TargetResults?: typeof msbuildEvaluationOutput.infer.TargetResults;
171
+ }
172
+
173
+ export const EvaluationOptions: ObjectType<{
174
+ FullName: string;
175
+ Property: {
176
+ MSBuildProjectFullPath?: string | undefined;
177
+ AssemblyName?: string | undefined;
178
+ BaseIntermediateOutputPath?: string | undefined;
179
+ BaseOutputPath?: string | undefined;
180
+ Description?: string | undefined;
181
+ IntermediateOutput?: string | undefined;
182
+ OutDir?: string | undefined;
183
+ OutputPath?: string | undefined;
184
+ Version?: string | undefined;
185
+ VersionPrefix?: string | undefined;
186
+ VersionSuffix?: string | undefined;
187
+ TargetFramework?: string | undefined;
188
+ TargetFrameworks?: string | undefined;
189
+ RuntimeIdentifier?: string | undefined;
190
+ RuntimeIdentifiers?: string | undefined;
191
+ };
192
+ Targets: readonly string[] | string[];
193
+ GetItem: readonly string[] | string[];
194
+ GetProperty: readonly string[] | string[];
195
+ GetTargetResult: readonly string[] | string[];
196
+ }> = Object.freeze(
197
+ type({
198
+ /**
199
+ * The project file's full path.
200
+ */
201
+ FullName: 'string',
202
+ /**
203
+ * User-defined Properties and their values.
204
+ * { Configuration: "Release" } will cause the MSBuild to first set the
205
+ * Configuration property to Release before evaluating the project
206
+ * or the project's Target(s).
207
+ * ```txt
208
+ * -property:<n>=<v> Set or override these project-level properties. <n> is
209
+ * the property name, and <v> is the property value. Use a
210
+ * semicolon or a comma to separate multiple properties, or
211
+ * specify each property separately. (Short form: -p)
212
+ * Example:
213
+ * -property:WarningLevel=2;OutDir=bin\Debug\
214
+ * ```
215
+ */
216
+ Property: type({ '[string]': 'string' })
217
+ .as<{ -readonly [P in keyof MSBuildProjectProperties]: MSBuildProjectProperties[P] }>()
218
+ .partial(),
219
+ /**
220
+ * The MSBuild Targets to run for evaluation. ["Pack"] is recommended.
221
+ * Property values may be changed by Targets such as those provided by
222
+ * dependencies.
223
+ *
224
+ * ```txt
225
+ * -target:<targets> Build these targets in this project. Use a semicolon or a
226
+ * comma to separate multiple targets, or specify each
227
+ * target separately. (Short form: -t)
228
+ * Example:
229
+ * -target:Resources;Compile
230
+ * ```
231
+ * @default []
232
+ */
233
+ Targets: type.string.array().readonly().or('string[]'),
234
+ /**
235
+ * MSBuild Items to evaluate. `["Compile"]` will result in the MSBuild output
236
+ * including {@link MSBuild}
237
+ */
238
+ GetItem: type.string.array().readonly().or('string[]'),
239
+ GetProperty: type.string.array().readonly().or('string[]'),
240
+ GetTargetResult: type.string.array().readonly().or('string[]'),
241
+ }),
242
+ );
14
243
 
15
244
  export class MSBuildProject {
16
- Properties: MSBuildProjectProperties;
17
-
18
- /**
19
- *
20
- * @param fullPath The full path of the .NET MSBuild project file.
21
- * @param customProperties MSBuild properties to evaluate in addition to those pre-defined in {@link MSBuildProjectProperties}
22
- */
23
- constructor(fullPath: string, customProperties?: string[]) {
24
- // super();
25
- this.Properties = MSBuildProject.evaluateProperties(fullPath, customProperties ?? []);
26
- }
27
-
28
- /**
29
- *
30
- * `dotnet msbuild src -getProperty:TargetFramework -getProperty:TargetFrameworks -getProperty:RuntimeIdentifiers -getProperty:IsTrimmable`
31
- *
32
- * ...produces...
33
- *
34
- * ```json
35
- * {
36
- * "Properties": {
37
- * "TargetFramework": "net6.0",
38
- * "TargetFrameworks": "",
39
- * "RuntimeIdentifiers": "win7-x64;win7-x86;win-arm64;linux-x64;linux-arm64",
40
- * "IsTrimmable": "true",
41
- * }
42
- * }
43
- * ```
44
- *
45
- * ...which can can be parsed like...
46
- * ```js
47
- * var ridArray = JSON.parse(out).Properties.RuntimeIdentifiers.split(';');
48
- * ```
49
- */
50
- static evaluateProperties(fullPath: string, properties: string[]): MSBuildProjectProperties {
51
- const evaluatedProps: MSBuildProjectProperties = new MSBuildProjectProperties(fullPath);
52
-
53
- // if a default prop isn't in properties, add it
54
- const defaultProps = MSBuildProjectPreDefinedProperties;
55
- for (const defaultProp of defaultProps) {
56
- if (!properties.includes(defaultProp)) properties.push(defaultProp);
57
- }
58
- const getPropArgs: string[] = properties.map((propName) => `-getProperty:${propName}`);
59
- // should return a single value OR string-encoded JSON object with 'Properties' object-type property.
60
- const out = execFileSync('dotnet', ['msbuild', evaluatedProps.FullPath, ...getPropArgs], {
61
- encoding: 'utf8',
62
- stdio: 'pipe',
63
- }).trim();
64
- if (out.startsWith('MSBUILD : error'))
65
- throw new Error(out);
66
-
67
- let props: Record<string, string>;
68
- if (out.startsWith('{')) {
69
- const obj = JSON.parse(out) as object;
70
- if ("Properties" in obj && typeof obj.Properties === 'object' && obj.Properties !== null)
71
- props = obj.Properties as Record<string, string>;
72
- else throw new Error('When evaluating properties with MSBuild, "Properties" could not be found in the deserialized JSON object...\n' + JSON.stringify(obj))
73
- }
74
- else {
75
- props = { [properties[0]]: out.trim() }
76
- }
77
-
78
- return {
79
- ...evaluatedProps,
80
- ...props,
81
- };
82
- }
245
+ /**
246
+ * Properties for multi-targeting `dotnet publish` outputs.
247
+ * These are included in {@link NPPGetterNames.InstanceGettersRecursive}.
248
+ */
249
+ public static readonly MatrixProperties: readonly string[] = Object.freeze([
250
+ 'TargetFramework',
251
+ 'TargetFrameworks',
252
+ 'RuntimeIdentifier',
253
+ 'RuntimeIdentifiers',
254
+ ]);
255
+
256
+ /**
257
+ * Creates an instance of MSBuildProject.
258
+ * @param opts The order-independent arguments for this constructor.
259
+ * Properties may be added or moved around in this definition without
260
+ * breaking compatibility.
261
+ * @param opts.fullPath The full path of the MSBuild project's file. This
262
+ * should have a '.csproj', '.fsproj', or '.vbproj' file extension.
263
+ * @param opts.projTargets A list of MSBuild Targets supported by the project.
264
+ * @param opts.evaluation The output of an MSBuild project evaluation. This
265
+ * comprises MSBuild Properties, Items, and Target results.
266
+ */
267
+ public constructor(opts: {
268
+ fullPath: string;
269
+ projTargets: string[];
270
+ evaluation: MSBuildEvaluationOutput;
271
+ }) {
272
+ this.Items = opts.evaluation.Items ?? {};
273
+ this.Properties = new NugetProjectProperties(
274
+ opts.fullPath,
275
+ new CaseInsensitiveMap<string, string>(
276
+ Object.entries(opts.evaluation.Properties ?? {}),
277
+ ),
278
+ );
279
+ this.Targets = opts.projTargets;
280
+ this.TargetResults
281
+ = opts.evaluation.TargetResults === undefined
282
+ ? []
283
+ : [opts.evaluation.TargetResults];
284
+ }
285
+
286
+ readonly Items: Readonly<Required<MSBuildEvaluationOutput>['Items']>;
287
+ readonly Properties: Readonly<NugetProjectProperties>;
288
+ readonly Targets: readonly string[];
289
+ /**
290
+ * Allows appending subsequent target results.
291
+ */
292
+ readonly TargetResults: Required<MSBuildEvaluationOutput>['TargetResults'][];
293
+
294
+ /**
295
+ * @param projectPath The full path of the project file or its directory. A
296
+ * relative path may be passed, but will resolve relative to the current
297
+ * working directory.
298
+ * @param includeNonPublic Include conventionally internal/private MSBuild
299
+ * targets in the result.
300
+ * @returns A string array of the project's MSBuild targets.
301
+ * @todo consider 'file' of -targets[:file]
302
+ * Prints a list of available targets without executing the
303
+ * actual build process. By default the output is written to
304
+ * the console window. If the path to an output file
305
+ * is provided that will be used instead.
306
+ * (Short form: -ts)
307
+ * Example:
308
+ * -ts:out.txt
309
+ */
310
+ static async GetTargets(
311
+ projectPath: string,
312
+ includeNonPublic = false,
313
+ ): Promise<string[]> {
314
+ return execAsync(`dotnet msbuild ${projectPath} -targets`, true)
315
+ .then((v) => {
316
+ const targets = v.stdout
317
+ .split('\n')
318
+ .filter((v, index) => v !== '' && index !== 0)
319
+ .map(v => v.replace('\r', ''))
320
+ .sort((a, b) => a.localeCompare(b));
321
+ return includeNonPublic
322
+ ? targets
323
+ : targets.filter(v => !v.startsWith('_'));
324
+ });
325
+ }
326
+
327
+ /**
328
+ * Evaluate {@link Items}, {@link Properties}, and {@link TargetResults},
329
+ * returning them as an instance of {@link MSBuildProject}.\
330
+ * Note: MSBuild will probably fail if Restore is skipped and another
331
+ * target is specified. If you choose Pack, you must do ['Restore', 'Pack'].
332
+ * @param options The result of {@link EvaluationOptions.from}.
333
+ * @returns A promised {@link MSBuildProject} instance.
334
+ * @throws if the exec command fails -OR- the JSON parse fails -OR-
335
+ * MSBuildProject's constructor fails.
336
+ * @see {@link PackableProjectsToMSBuildProjects} for most use-cases.
337
+ */
338
+ public static async Evaluate(
339
+ options: typeof EvaluationOptions.inferOut,
340
+ ): Promise<MSBuildProject> {
341
+ if (
342
+ options.GetProperty.length === 0
343
+ && options.GetItem.length === 0
344
+ && options.GetTargetResult.length === 0
345
+ ) {
346
+ throw new Error(
347
+ 'No MSBuild Property, Item, or TargetResult queries were provided.',
348
+ );
349
+ }
350
+ // reminder: args containing spaces and semi-colons MUST be quote-enclosed!
351
+ options.FullName = MSBuildProjectProperties.GetFullPath(options.FullName);
352
+ const _pairs = Object.entries(options.Property).filter(p => typeof p[1] === 'string');
353
+ const property
354
+ = _pairs.length === 0
355
+ ? ''
356
+ : `-p:"${_pairs.map(pair => pair[0] + '=' + pair[1]).join(';')}"`;
357
+ const target
358
+ = options.Targets.length === 0
359
+ ? ''
360
+ : `"-t:${options.Targets.join(';')}"`;
361
+ const getItem
362
+ = options.GetItem.length === 0
363
+ ? ''
364
+ : `-getItem:"${options.GetItem.join(',')}"`;
365
+ const getProperty
366
+ = options.GetProperty.length === 0
367
+ ? ''
368
+ : `-getProperty:"${options.GetProperty.join(',')}"`;
369
+ const getTargetResult
370
+ = options.GetTargetResult.length === 0
371
+ ? ''
372
+ : `-getTargetResult:"${options.GetTargetResult.join(',')}"`;
373
+ const cmdLine = [
374
+ 'dotnet',
375
+ 'msbuild',
376
+ `"${options.FullName}"`,
377
+ '-restore',
378
+ property,
379
+ target,
380
+ getItem,
381
+ getProperty,
382
+ getTargetResult,
383
+ ]
384
+ .filter(v => v !== '')
385
+ .join(' ');
386
+ let stdio: Awaited<ReturnType<typeof execAsync>> | undefined = undefined;
387
+ // may throw
388
+ while (stdio === undefined) {
389
+ stdio = await setTimeout(
390
+ 1000,
391
+ execAsync(cmdLine, true),
392
+ )
393
+ .then(async p => await p)
394
+ .catch<undefined>(catchCsc2012);
395
+ }
396
+
397
+ // todo: consider -getResultOutputFile:file
398
+ // Redirect output from get* into a file.
399
+ //
400
+ // Example:
401
+ // -getProperty:Bar -getResultOutputFile:Biz.txt
402
+ // This writes the value of property Bar into Biz.txt.
403
+
404
+ /**
405
+ * The following issues have triggered this code path:
406
+ * - BaseIntermediateOutputPath must use Unix path separators ('/') on all
407
+ * platforms. Even Windows. Otherwise, MSBuild/dotnet will error-exit with
408
+ * "The BaseIntermediateOutputPath must end with a trailing slash".
409
+ */
410
+ if (stdio.stdout.startsWith('MSBuild version')) {
411
+ warn(stdio.stdout);
412
+ throw new Error(
413
+ 'dotnet msbuild was expected to output JSON, but output its version header instead.',
414
+ );
415
+ }
416
+
417
+ let rawOutput = undefined;
418
+ if (stdio.stdout.startsWith('{')) {
419
+ /** stdout is JSON string */
420
+ rawOutput = stdio.stdout;
421
+ }
422
+ else if (options.GetProperty.length > 0 && options.GetProperty[0] !== undefined) {
423
+ rawOutput = {
424
+ Properties: {
425
+ [options.GetProperty[0]]: String(JSON.parse(stdio.stdout)),
426
+ },
427
+ };
428
+ }
429
+ else {
430
+ throw new Error('Dotnet/MSBuild evaluation output is not a string nor JSON object or array.');
431
+ }
432
+
433
+ const evaluation = new MSBuildEvaluationOutput(rawOutput);
434
+
435
+ return new MSBuildProject({
436
+ fullPath: options.FullName,
437
+ projTargets: await MSBuildProject.GetTargets(options.FullName),
438
+ evaluation,
439
+ });
440
+ }
441
+
442
+ /**
443
+ * Evaluate multiple project paths with some default Evaluate options.
444
+ * @async
445
+ * @param projectsToPackAndPush An array of MSBuild projects' full file
446
+ * paths. If a path is a directory, files in that directory are filtered for
447
+ * `.csproj`, `.fsproj`, and `.vbproj` project files.
448
+ * See https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\
449
+ * @returns A promised array of {@link MSBuildProject} instances.
450
+ * All known MSBuild and NuGet properties are evaluated.
451
+ * If applicable, a project's "Pack" target is evaluated.
452
+ */
453
+ public static async PackableProjectsToMSBuildProjects(
454
+ projectsToPackAndPush: string[],
455
+ ): Promise<Promise<MSBuildProject>[]> {
456
+ const dirEntriesPromise = toDirEntries(typeof projectsToPackAndPush === 'string' ? [projectsToPackAndPush] : projectsToPackAndPush);
457
+ const projectPromises: Promise<MSBuildProject>[] = await dirEntriesPromise
458
+ .then(
459
+ (direntArray: Dirent[]) =>
460
+ direntArray.map(element => convertDirentToMSBuildProject(element)),
461
+ );
462
+ return projectPromises;
463
+
464
+ /**
465
+ * Map an array of filesystem paths to {@link Dirent} instances representing project files.
466
+ * @param projectsToPackAndPush An array of MSBuild projects' full file
467
+ * paths. If a path is a directory, files in that directory are filtered for
468
+ * `.csproj`, `.fsproj`, and `.vbproj` project files. See
469
+ * https://github.com/dotnet/sdk/blob/497f334b2862bdf98b30c00ede2fd259ea5f624d/src/Cli/dotnet/Commands/New/MSBuildEvaluation/MSBuildEvaluationResult.cs#L19-L32.\
470
+ * @returns An promised array of Dirent instances for discovered project files.
471
+ */
472
+ async function toDirEntries(
473
+ projectsToPackAndPush: string[],
474
+ ): Promise<Dirent[]> {
475
+ const dirEntries: (Dirent | Dirent[])[] = await Promise.all(
476
+ projectsToPackAndPush.map(async (proj) => {
477
+ proj = await realpath(makeAbsolute(proj));
478
+ const stats = await stat(proj);
479
+ let entries: Dirent[];
480
+
481
+ if (stats.isFile()) {
482
+ entries = await readdir(path.dirname(proj), { withFileTypes: true });
483
+ const dirent: Dirent | undefined = entries.find(v =>
484
+ path.join(
485
+ // condition required for compatibility. `.path` was deprecated, but `.parentPath` is not available in our node minversion
486
+ v.path as string | undefined ?? (v as unknown as Omit<typeof v, 'path'> & { parentPath: string }).parentPath,
487
+ v.name,
488
+ ) === proj,
489
+ );
490
+ if (dirent)
491
+ return dirent;
492
+ else
493
+ throw new Error(
494
+ `file "${proj}" not found. It may have been moved or deleted.`,
495
+ );
496
+ }
497
+ if (!stats.isDirectory())
498
+ throw new Error(`"${proj}" is not a file or directory`);
499
+
500
+ entries = await readdir(proj, { withFileTypes: true });
501
+ return entries.filter(v =>
502
+ v.isFile()
503
+ && (v.name.endsWith('.csproj') || v.name.endsWith('.fsproj') || v.name.endsWith('.vbproj')),
504
+ );
505
+ }),
506
+ );
507
+
508
+ return dirEntries.flat();
509
+ }
510
+
511
+ /**
512
+ * Map a {@link Dirent} instance to an {@link MSBuildProject} instance.
513
+ * @param dirent A {@link Dirent} instance. This instance should be an MSBuild project file.
514
+ * @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}.
515
+ */
516
+ async function convertDirentToMSBuildProject(dirent: Dirent): Promise<MSBuildProject> {
517
+ const fullPath = path.join(
518
+ // condition required for compatibility. `.path` was deprecated, but `.parentPath` is not available in our node minversion
519
+ dirent.path as string | undefined ?? (dirent as unknown as Omit<typeof dirent, 'path'> & { parentPath: string }).parentPath,
520
+ dirent.name,
521
+ );
522
+ const projTargets: Promise<string[]> = MSBuildProject.GetTargets(fullPath);
523
+ const evalTargets = await projTargets.then(v =>
524
+ v.includes('Pack') ? ['Pack'] : [],
525
+ );
526
+ // this might be too long for a command line. What was it on Windows?
527
+ // 2^15 (32,768) character limit for command lines?
528
+ const getProperties = NPPGetterNames.InstanceGettersRecursive;
529
+
530
+ return await MSBuildProject.Evaluate(
531
+ EvaluationOptions.from({
532
+ FullName: fullPath,
533
+ GetItem: [],
534
+ GetProperty: getProperties,
535
+ GetTargetResult: [],
536
+ Property: {},
537
+ Targets: evalTargets,
538
+ }),
539
+ );
540
+ }
541
+ }
542
+
543
+ public static fromJSON(json: string): MSBuildProject {
544
+ const parsed = T_PseudoMSBPInstance.assert(JSON.parse(json));
545
+
546
+ type.true.assert(
547
+ Reflect.setPrototypeOf(parsed, MSBuildProject.prototype),
548
+ );
549
+ type.true.assert(
550
+ Reflect.setPrototypeOf(parsed.Properties, NugetProjectProperties.prototype),
551
+ );
552
+ parsed.Properties = T_NPP.assert(parsed.Properties);
553
+ return T_MSBuildProject.assert(parsed);
554
+ }
555
+ }
556
+
557
+ const T_MSBuildProject = type.instanceOf(MSBuildProject);
558
+ const T_NPP = type.instanceOf(NugetProjectProperties);
559
+ const T_PseudoMSBPInstance = type({
560
+ Items: type({
561
+ '[string]': type({
562
+ '[string]': 'string',
563
+ Identity: 'string',
564
+ FullPath: 'string',
565
+ RootDir: 'string',
566
+ Filename: 'string',
567
+ Extension: 'string',
568
+ RelativeDir: 'string',
569
+ Directory: 'string',
570
+ RecursiveDir: 'string',
571
+ ModifiedTime: 'string',
572
+ CreatedTime: 'string',
573
+ AccessedTime: 'string',
574
+ DefiningProjectFullPath: 'string',
575
+ DefiningProjectDirectory: 'string',
576
+ DefiningProjectName: 'string',
577
+ DefiningProjectExtension: 'string',
578
+ 'SubType?': ' string | undefined',
579
+ 'TargetFrameworkIdentifier?': 'string | undefined',
580
+ 'TargetPlatformMoniker?': 'string | undefined',
581
+ 'CopyUpToDateMarker?': 'string | undefined',
582
+ 'TargetPlatformIdentifier?': 'string | undefined',
583
+ 'TargetFrameworkVersion?': 'string | undefined',
584
+ 'ReferenceAssembly?': 'string | undefined',
585
+ }).array(),
586
+ }),
587
+ Properties: type.Record('string', 'string').or(T_NPP),
588
+ Targets: type.string.array(),
589
+ TargetResults: msbuildEvaluationOutput.get('TargetResults').exclude('undefined').array(),
590
+
591
+ });
592
+
593
+ /**
594
+ * ArkType type definitions for internal usage, but may be re-used elsewhere
595
+ * @internal
596
+ */
597
+ export const _InternalMSBuildEvaluationTypes: Scope<{
598
+ msbuildEvaluationOutput: {
599
+ Properties?: Record<string, string> | undefined;
600
+ Items?: Record<string, {
601
+ [x: string]: string | undefined;
602
+ Identity: string;
603
+ FullPath: string;
604
+ RootDir: string;
605
+ Filename: string;
606
+ Extension: string;
607
+ RelativeDir: string;
608
+ Directory: string;
609
+ RecursiveDir: string;
610
+ ModifiedTime: string;
611
+ CreatedTime: string;
612
+ AccessedTime: string;
613
+ DefiningProjectFullPath: string;
614
+ DefiningProjectDirectory: string;
615
+ DefiningProjectName: string;
616
+ DefiningProjectExtension: string;
617
+ SubType?: string | undefined;
618
+ TargetFrameworkIdentifier?: string | undefined;
619
+ TargetPlatformMoniker?: string | undefined;
620
+ CopyUpToDateMarker?: string | undefined;
621
+ TargetPlatformIdentifier?: string | undefined;
622
+ TargetFrameworkVersion?: string | undefined;
623
+ ReferenceAssembly?: string | undefined;
624
+ }[]> | undefined;
625
+ TargetResults?: Record<string, {
626
+ Result: 'Success';
627
+ Items: {
628
+ [x: string]: string | undefined;
629
+ Identity: string;
630
+ FullPath: string;
631
+ RootDir: string;
632
+ Filename: string;
633
+ Extension: string;
634
+ RelativeDir: string;
635
+ Directory: string;
636
+ RecursiveDir: string;
637
+ ModifiedTime: string;
638
+ CreatedTime: string;
639
+ AccessedTime: string;
640
+ DefiningProjectFullPath: string;
641
+ DefiningProjectDirectory: string;
642
+ DefiningProjectName: string;
643
+ DefiningProjectExtension: string;
644
+ SubType?: string | undefined;
645
+ TargetFrameworkIdentifier?: string | undefined;
646
+ TargetPlatformMoniker?: string | undefined;
647
+ CopyUpToDateMarker?: string | undefined;
648
+ TargetPlatformIdentifier?: string | undefined;
649
+ TargetFrameworkVersion?: string | undefined;
650
+ ReferenceAssembly?: string | undefined;
651
+ }[];
652
+ } | {
653
+ Result: 'Failure';
654
+ Items: never[];
655
+ }> | undefined;
656
+ };
657
+ }> = type.scope({
658
+ msbuildEvaluationOutput,
659
+ });
660
+
661
+ /**
662
+ * Resolve a path if it is not already absolute.
663
+ * @param _path A filesystem path.
664
+ * @returns A full path to a filesystem entry. The path is unchecked for whether or not the path (or its parts) exist.
665
+ */
666
+ function makeAbsolute(_path: string) {
667
+ return path.isAbsolute(_path) ? _path : path.resolve(_path);
668
+ }
669
+
670
+ /**
671
+ * Use this in your catch statement or .catch call to return `undefined` when
672
+ * MSBuild error CSC2012 (e.g. "file in use by another process") is reported.
673
+ * @param error Probably an Error object
674
+ * @returns `undefined` if CSC2012 (file in use by another process) occurs
675
+ */
676
+ export function catchCsc2012(error: unknown): undefined {
677
+ if (isNativeError(error)) {
678
+ // check for error reported when "file in use by another process" i.e. EBUSY
679
+ // (UNIX), NTSTATUS.ERROR_SHARING_VIOLATION == 0x20 == 32 (Windows)
680
+ if ('stderr' in error && typeof error.stderr === 'string'
681
+ && /^CSC ?:.+CS2012:/gm.test(
682
+ // '\uFF1A'.normalize('NFKC') === ':' === true;
683
+ error.stderr.normalize('NFKC'),
684
+ )
685
+ ) {
686
+ return undefined; /* retry */
687
+ }
688
+ /**
689
+ * some known warnings/errors:
690
+ * - warning MSB3073:
691
+ * The command "dotnet tool list kuinox.nupkgdeterministicator"
692
+ * exited with code 145.
693
+ * > $ dotnet tool list kuinox.nupkgdeterministicator
694
+ * > The command could not be loaded, possibly because:
695
+ * > * You intended to execute a .NET application:
696
+ * > The application 'tool' does not exist.
697
+ * > * You intended to execute a .NET SDK command:
698
+ * > No .NET SDKs were found.
699
+ * >
700
+ * > Download a .NET SDK:
701
+ * > https://aka.ms/dotnet/download
702
+ * >
703
+ * > Learn about SDK resolution:
704
+ * > https://aka.ms/dotnet/sdk-not-found
705
+ */
706
+ else throw error;
707
+ }
708
+ else throw new Error('unknown error', { cause: error });
83
709
  }