From b9e62cd4c954cd7f155c17f99631ee31362ac80d Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Tue, 23 May 2017 11:18:51 +0100 Subject: [PATCH] Fix "dotnet new" postAction issues (and disable the "npm install" action) --- templates/package-builder/src/build/build.ts | 49 ++++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/templates/package-builder/src/build/build.ts b/templates/package-builder/src/build/build.ts index 2830335..d1858b6 100644 --- a/templates/package-builder/src/build/build.ts +++ b/templates/package-builder/src/build/build.ts @@ -164,27 +164,46 @@ function buildDotNetNewNuGetPackage() { } ], defaultValue: 'netcoreapp1.1' + }, + skipRestore: { + type: 'parameter', + datatype: 'bool', + description: 'If specified, skips the automatic restore of packages on project creation.', + defaultValue: 'false' } }, tags: { language: 'C#', type: 'project' }, - postActions: [{ - condition: '(!skipRestore)', - description: 'Restores NuGet packages required by this project.', - manualInstructions: [{ text: 'Run \'dotnet restore\'' }], - actionId: '210D431B-A78B-4D2F-B762-4ED3E3EA9025', - continueOnError: true - }, { - condition: '(!skipRestore)', - description: 'Restores NPM packages required by this project.', - manualInstructions: [{ text: 'Run \'npm install\'' }], - actionId: '3A7C4B45-1F5D-4A30-959A-51B88E82B5D2', - args: { executable: 'npm', args: 'install' }, - continueOnError: false - }], + postActions: [ + { + condition: '(!skipRestore)', + description: 'Restores NuGet packages required by this project.', + manualInstructions: [{ text: 'Run \'dotnet restore\'' }], + actionId: '210D431B-A78B-4D2F-B762-4ED3E3EA9025', + continueOnError: true + }, + /* + // Currently it doesn't appear to be possible to run `npm install` from a + // postAction, due to https://github.com/dotnet/templating/issues/849 + // We will re-enable this when that bug is fixed. + { + condition: '(!skipRestore)', + description: 'Restores NPM packages required by this project.', + manualInstructions: [{ text: 'Run \'npm install\'' }], + actionId: '3A7C4B45-1F5D-4A30-959A-51B88E82B5D2', + args: { executable: 'npm', args: 'install' }, + continueOnError: false + } + */ + ], }, null, 2)); fs.writeFileSync(path.join(templateConfigDir, 'dotnetcli.host.json'), JSON.stringify({ - symbolInfo: {} + symbolInfo: { + skipRestore: { + longName: 'no-restore', + shortName: '' + } + } }, null, 2)); fs.writeFileSync(path.join(templateConfigDir, 'vs-2017.3.host.json'), JSON.stringify({