UNPKG

@nx-dotnet/core

Version:

- Have an existing nx workspace. For creating this, see [nrwl's documentation](https://nx.dev/latest/angular/getting-started/nx-setup). - .NET SDK is installed, and `dotnet` is available on the path. For help on this, see [Microsoft's documentation](https

43 lines (41 loc) 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildStartupAssemblyPath = buildStartupAssemblyPath; const devkit_1 = require("@nx/devkit"); const child_process_1 = require("child_process"); const fast_glob_1 = require("fast-glob"); const fs_1 = require("fs"); const path_1 = require("path"); function buildStartupAssemblyPath(projectName, project, csProjFilePath) { const [target, configuration] = findBuildTarget(project); let outputDirectory = configuration?.outputs?.[0]; if (!outputDirectory) { throw new Error(`Specify the output directory for ${project.root} To generate swagger with Nx, the outputs must be captured. This is also necessary for Nx's caching mechanism. Simply update the outputs array in project.json with the location of your build artifacts. `); } outputDirectory = (0, path_1.resolve)(outputDirectory .replace('{workspaceRoot}', devkit_1.workspaceRoot) .replace('{projectRoot}', project.root)); if (!(0, fs_1.existsSync)(outputDirectory)) { (0, child_process_1.execSync)(`${(0, devkit_1.getPackageManagerCommand)().exec} nx ${target} ${projectName}`, { windowsHide: true, }); } const dllName = (0, path_1.basename)(csProjFilePath).replace(/(?:\.csproj|\.vbproj|\.fsproj)$/, '.dll'); const matchingDlls = (0, fast_glob_1.sync)(`**/${dllName}`, { cwd: outputDirectory }); if (!matchingDlls.length) { throw new Error(`[nx-dotnet] Unable to locate ${dllName} in ${(0, path_1.relative)(devkit_1.workspaceRoot, outputDirectory)}`); } if (matchingDlls.length > 1) { throw new Error(`[nx-dotnet] Located multiple matching dlls for ${projectName}. You may need to clean old build artifacts from your outputs, or manually specify the path to the output assembly within ${project.root}/project.json.`); } return (0, devkit_1.joinPathFragments)(outputDirectory, matchingDlls[0]); } function findBuildTarget(project) { return (Object.entries(project?.targets || {}).find(([, x]) => x.executor === '@nx-dotnet/core:build') ?? []); } //# sourceMappingURL=get-path-to-startup-assembly.js.map