@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
34 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addToSolutionFile = addToSolutionFile;
const devkit_1 = require("@nx/devkit");
const path_1 = require("path");
const dotnet_1 = require("@nx-dotnet/dotnet");
const utils_1 = require("@nx-dotnet/utils");
const get_scope_1 = require("./get-scope");
const dotnet_new_1 = require("./dotnet-new");
const dotnet_add_1 = require("./dotnet-add");
const try_read_json_1 = require("./try-read-json");
function addToSolutionFile(host, projectRoot, dotnetClient = new dotnet_1.DotNetClient((0, dotnet_1.dotnetFactory)()), solutionFile) {
const scope = (0, get_scope_1.getWorkspaceScope)((0, devkit_1.readNxJson)(host), (0, try_read_json_1.tryReadJson)(host, 'package.json'));
const defaultFilePath = (0, utils_1.readConfigSection)(host, 'solutionFile')?.replace(/(\{npmScope\}|\{scope\})/g, scope || '');
if (typeof solutionFile === 'boolean' && solutionFile) {
solutionFile = defaultFilePath;
}
else if (solutionFile === null || solutionFile === undefined) {
if (defaultFilePath && host.exists(defaultFilePath)) {
solutionFile = defaultFilePath;
}
}
if (solutionFile) {
if (!host.exists(solutionFile)) {
const { name, dir } = (0, path_1.parse)(solutionFile);
(0, dotnet_new_1.runDotnetNew)(host, dotnetClient, 'sln', {
name,
output: dir,
});
}
(0, dotnet_add_1.runDotnetAddProjectToSolution)(host, dotnetClient, projectRoot, solutionFile);
}
}
//# sourceMappingURL=add-to-sln.js.map