C# 如何在Yeoman generator中创建新的.net核心项目
我在写一个约曼发电机。我怎么打电话C# 如何在Yeoman generator中创建新的.net核心项目,c#,.net,asp.net-core,yeoman,yeoman-generator,C#,.net,Asp.net Core,Yeoman,Yeoman Generator,我在写一个约曼发电机。我怎么打电话 dotnet new 在我的发电机里? 有没有更好的方法在yeoman generator中创建新的.net核心项目?一种可能是直接调用dotnet new const { execSync, exec } = require('child_process'); function formated_exec_sync(command) { console.log("exec->" + command); execSync(comman
dotnet new
在我的发电机里?
有没有更好的方法在yeoman generator中创建新的.net核心项目?一种可能是直接调用
dotnet new
const { execSync, exec } = require('child_process');
function formated_exec_sync(command) {
console.log("exec->" + command);
execSync(command, {stdio: 'inherit'});
}
function new_solution(name) {
formated_exec_sync(`dotnet new sln --name ${name}`);
}
function new_console_project(name) {
formated_exec_sync(`dotnet new console -lang "C#" --name ${name}`);
}
function add_project_to_solution(project_name, solution_name) {
formated_exec_sync(`dotnet sln ${solution_name}.sln add ${project_name}`);
}
function add_package_to_project(package, project, version = null) {
let command = `dotnet add ${project} package`;
if (version != null)
command += ` --version ${version}`;
command += ` ${package}`
formated_exec_sync(command);
}
module.exports = {
new_solution,
new_console_project,
add_project_to_solution,
add_package_to_project,
}