@nx/dotnet 23.0.0-beta.2 → 23.0.0-beta.20

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.
@@ -27,7 +27,7 @@ export interface DotNetAnalyzerOptions {
27
27
  * Results are cached based on the content hash of all project files.
28
28
  * This should be called by createNodes to populate the cache.
29
29
  */
30
- export declare function analyzeProjects(projectFiles: string[], options?: DotNetAnalyzerOptions): Promise<AnalysisResult>;
30
+ export declare function analyzeProjects(files: string[], options?: DotNetAnalyzerOptions): Promise<AnalysisResult>;
31
31
  /**
32
32
  * Read the cached analysis results without running the analyzer.
33
33
  * This should be called by createDependencies, which always runs after createNodes.
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer-client.d.ts","sourceRoot":"","sources":["../../src/analyzer/analyzer-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMzE,MAAM,WAAW,qBAAqB;IAEpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAElD,gBAAgB,EAAE,MAAM,CACtB,MAAM,EACN;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAC7C,CAAC;CACH;AACD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,CAAC;CACd;AACD,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AA2BzE;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAgJD;;;;GAIG;AACH,wBAAsB,eAAe,C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AC,cAAc,CAAC,CA2DzB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CASzD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,GACrB,MAAM,IAAI,mBAAmB,CAE/B;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,GACrB,MAAM,IAAI,qBAAqB,CAEjC"}
@@ -13,22 +13,6 @@ const workspace_context_1 = require("nx/src/utils/workspace-context");
13
13
  const cache_directory_1 = require("nx/src/utils/cache-directory");
14
14
  const file_hasher_1 = require("nx/src/hasher/file-hasher");
15
15
  const plugin_cache_utils_1 = require("nx/src/utils/plugin-cache-utils");
16
- const analyzerCaches = new Map();
17
- function getCachePathForOptionsHash(optionsHash) {
18
- return (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `dotnet-${optionsHash}.hash`);
19
- }
20
- function readAnalyzerCache(optionsHash) {
21
- if (analyzerCaches.has(optionsHash)) {
22
- return analyzerCaches.get(optionsHash);
23
- }
24
- const cacheFilePath = getCachePathForOptionsHash(optionsHash);
25
- return new plugin_cache_utils_1.PluginCache(cacheFilePath);
26
- }
27
- function writeAnalyzerCache(optionsHash, cache) {
28
- analyzerCaches.set(optionsHash, cache);
29
- const cacheFilePath = getCachePathForOptionsHash(optionsHash);
30
- cache.writeToDisk(cacheFilePath);
31
- }
32
16
  let cache = null;
33
17
  /**
34
18
  * Get the path to the msbuild-analyzer executable
@@ -46,21 +30,22 @@ function getAnalyzerPath() {
46
30
  return path;
47
31
  }
48
32
  }
49
- throw new Error(`msbuild-analyzer not found at any expected location. Please build it first with: nx run dotnet:build-analyzer`);
33
+ throw new Error(`msbuild-analyzer not found at any expected location. Please build it first with: nx run dotnet:copy-assets`);
50
34
  }
51
35
  /**
52
- * Calculate a hash of all project files and Directory.Build.* files to determine if we need to re-analyze
36
+ * Hash every file that affects MSBuild evaluation project files plus the Directory.*
37
+ * matches surfaced by the createNodesV2 glob. The analyzer partitions the same list on
38
+ * its side, so we don't classify it here.
53
39
  */
54
- async function calculateProjectFilesHash(projectFiles) {
55
- const hash = await (0, workspace_context_1.hashWithWorkspaceContext)(devkit_1.workspaceRoot, projectFiles.concat('Directory.Build.*', '**/Directory.Build.*'));
56
- return hash;
40
+ async function calculateProjectFilesHash(files) {
41
+ return await (0, workspace_context_1.hashWithWorkspaceContext)(devkit_1.workspaceRoot, files);
57
42
  }
58
43
  /**
59
44
  * Run the msbuild-analyzer and return the results.
60
45
  * Uses stdin for large file lists to avoid ARG_MAX issues.
61
46
  */
62
- function runAnalyzer(projectFiles, options) {
63
- if (projectFiles.length === 0) {
47
+ function runAnalyzer(files, options) {
48
+ if (files.length === 0) {
64
49
  return { nodesByFile: {}, referencesByRoot: {} };
65
50
  }
66
51
  const analyzerPath = getAnalyzerPath();
@@ -98,8 +83,9 @@ function runAnalyzer(projectFiles, options) {
98
83
  if (options) {
99
84
  args.push(JSON.stringify(options));
100
85
  }
101
- // Use stdin mode for large file lists to avoid ARG_MAX issues
102
- const input = projectFiles.join('\n');
86
+ // Use stdin mode for large file lists to avoid ARG_MAX issues. The analyzer
87
+ // partitions paths by filename, so we just stream everything in one block.
88
+ const input = files.join('\n');
103
89
  const result = (0, node_child_process_1.spawnSync)('dotnet', args, {
104
90
  input,
105
91
  encoding: 'utf-8',
@@ -134,8 +120,8 @@ function runAnalyzer(projectFiles, options) {
134
120
  * Results are cached based on the content hash of all project files.
135
121
  * This should be called by createNodes to populate the cache.
136
122
  */
137
- async function analyzeProjects(projectFiles, options) {
138
- const filesHash = await calculateProjectFilesHash(projectFiles);
123
+ async function analyzeProjects(files, options) {
124
+ const filesHash = await calculateProjectFilesHash(files);
139
125
  // Return cached results if the hash matches
140
126
  if (cache &&
141
127
  cache.hash === filesHash &&
@@ -146,7 +132,7 @@ async function analyzeProjects(projectFiles, options) {
146
132
  return cache.result;
147
133
  }
148
134
  const optionsHash = (0, file_hasher_1.hashObject)(options);
149
- const analyzerCache = readAnalyzerCache(optionsHash);
135
+ const analyzerCache = new plugin_cache_utils_1.PluginCache((0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `dotnet-${optionsHash}.hash`));
150
136
  const cachedResult = analyzerCache.get(filesHash);
151
137
  if (cachedResult) {
152
138
  // Update cache
@@ -158,7 +144,7 @@ async function analyzeProjects(projectFiles, options) {
158
144
  }
159
145
  // Run the analyzer
160
146
  try {
161
- const result = runAnalyzer(projectFiles, options);
147
+ const result = runAnalyzer(files, options);
162
148
  // Update local cache
163
149
  cache = {
164
150
  hash: filesHash,
@@ -166,7 +152,7 @@ async function analyzeProjects(projectFiles, options) {
166
152
  };
167
153
  // Update persistent cache
168
154
  analyzerCache.set(filesHash, result);
169
- writeAnalyzerCache(optionsHash, analyzerCache);
155
+ analyzerCache.writeToDisk();
170
156
  return result;
171
157
  }
172
158
  catch (error) {
Binary file
@@ -6,7 +6,7 @@
6
6
  "compilationOptions": {},
7
7
  "targets": {
8
8
  ".NETCoreApp,Version=v8.0": {
9
- "MsbuildAnalyzer/1.0.0": {
9
+ "MsbuildAnalyzer/23.0.0-beta.20": {
10
10
  "dependencies": {
11
11
  "Microsoft.Build": "17.0.0",
12
12
  "Microsoft.Build.Framework": "17.0.0",
@@ -222,7 +222,7 @@
222
222
  }
223
223
  },
224
224
  "libraries": {
225
- "MsbuildAnalyzer/1.0.0": {
225
+ "MsbuildAnalyzer/23.0.0-beta.20": {
226
226
  "type": "project",
227
227
  "serviceable": false,
228
228
  "sha512": ""
Binary file
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"create-nodes.d.ts","sourceRoot":"","sources":["../../src/plugins/create-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGb,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAOpB,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG;IACvE;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,C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OAGG;IACH,OAAO,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;IAC9C;;;OAGG;IACH,OAAO,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;IAC9C;;;OAGG;IACH,IAAI,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;IAC3C;;;OAGG;IACH,KAAK,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,2BAA2B,GAAG,KAAK,CAAC;CAC3C;AAqFD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CA6E5D,CAAC"}
@@ -4,7 +4,15 @@ exports.createNodesV2 = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const analyzer_client_1 = require("../analyzer/analyzer-client");
6
6
  const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
7
- const dotnetProjectGlob = '**/*.{csproj,fsproj,vbproj}';
7
+ // MSBuild auto-imports Directory.Build.props/.targets from each ancestor of a project file,
8
+ // reads Directory.Build.rsp from ancestors during CLI builds, applies Directory.Solution.*
9
+ // when building a .sln, and reads Directory.Packages.props from the nearest ancestor when
10
+ // Central Package Management is in use. Matching them here causes createNodesV2 to re-run
11
+ // (and the analyzer's cache to invalidate) when any of them change, and gives us the file
12
+ // list to hand to the analyzer so it can declare per-project ancestor inputs.
13
+ // The analyzer partitions matched paths into project vs directory files by filename, so we
14
+ // don't have to repeat that classification on this side.
15
+ const dotnetProjectGlob = '**/{*.{csproj,fsproj,vbproj},Directory.Build.{props,targets,rsp},Directory.Solution.{props,targets},Directory.Packages.props}';
8
16
  /**
9
17
  * Merge user-specified target configurations with the generated targets from the analyzer
10
18
  */
@@ -91,9 +99,12 @@ exports.createNodesV2 = [
91
99
  return configFilePaths.map((configFile) => {
92
100
  const node = nodesByFile[configFile];
93
101
  if (!node) {
102
+ // Directory.Build.* / Directory.Solution.* files contribute no projects of
103
+ // their own; returning an empty config is the conventional "skip" response.
94
104
  return [configFile, {}];
95
105
  }
96
- // Merge user-specified target configurations with generated targets
106
+ // Merge user-specified target configurations with generated targets. The analyzer
107
+ // has already written the Directory.* inputs onto each cacheable target's Inputs.
97
108
  const mergedNode = mergeUserTargetConfigurations(node, normalizedOptions);
98
109
  return [
99
110
  configFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/dotnet",
3
- "version": "23.0.0-beta.2",
3
+ "version": "23.0.0-beta.20",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for .NET containing graph support for working with .NET projects in an Nx workspace.",
6
6
  "keywords": [
@@ -50,16 +50,16 @@
50
50
  "!dist/tsconfig.lib.tsbuildinfo"
51
51
  ],
52
52
  "dependencies": {
53
- "@nx/devkit": "23.0.0-beta.2",
53
+ "@nx/devkit": "23.0.0-beta.20",
54
54
  "tslib": "^2.3.0",
55
55
  "ignore": "^7.0.5"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/jest": "30.0.0",
59
- "@types/node": "^20.19.10",
60
- "jest": "^30.0.2",
59
+ "@types/node": "^24.11.0",
60
+ "jest": "30.3.0",
61
61
  "memfs": "^4.9.2",
62
- "nx": "23.0.0-beta.2",
62
+ "nx": "23.0.0-beta.20",
63
63
  "ts-jest": "^29.4.0",
64
64
  "typescript": "~5.9.2"
65
65
  },
@@ -1,5 +0,0 @@
1
- import { ProjectConfiguration } from '@nx/devkit';
2
- export type DotNetTargets = Pick<ProjectConfiguration, 'targets' | 'metadata'>;
3
- export declare function readTargetsCache(cachePath: string): Record<string, DotNetTargets>;
4
- export declare function writeTargetsToCache(cachePath: string, results: Record<string, DotNetTargets>): void;
5
- //# sourceMappingURL=cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA+B,MAAM,YAAY,CAAC;AAG/E,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;AAE/E,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAI/B;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,QAGvC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readTargetsCache = readTargetsCache;
4
- exports.writeTargetsToCache = writeTargetsToCache;
5
- const devkit_1 = require("@nx/devkit");
6
- const fs_1 = require("fs");
7
- function readTargetsCache(cachePath) {
8
- return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, fs_1.existsSync)(cachePath)
9
- ? (0, devkit_1.readJsonFile)(cachePath)
10
- : {};
11
- }
12
- function writeTargetsToCache(cachePath, results) {
13
- (0, devkit_1.writeJsonFile)(cachePath, results);
14
- }