diff --git a/Nodejs/Product/Nodejs/Guids.cs b/Nodejs/Product/Nodejs/Guids.cs
index 700eb8ec3..ca407914f 100644
--- a/Nodejs/Product/Nodejs/Guids.cs
+++ b/Nodejs/Product/Nodejs/Guids.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// MUST match guids.h
diff --git a/Nodejs/Product/Nodejs/Nodejs.csproj b/Nodejs/Product/Nodejs/Nodejs.csproj
index 81b4ff7fa..496ecb15d 100644
--- a/Nodejs/Product/Nodejs/Nodejs.csproj
+++ b/Nodejs/Product/Nodejs/Nodejs.csproj
@@ -676,6 +676,36 @@
+
+ Resources\Icons\NewProjectDialogIconsICO\JSAzureApplication.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\JSConsole.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\JSWeb.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\JSWorker.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\NodeJSApplication.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\NodeTSApplication.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\TSAzureApplication.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\TSConsole.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\TSWeb.ico
+
+
+ Resources\Icons\NewProjectDialogIconsICO\TSWorker.ico
+ PreserveNewesttrue
diff --git a/Nodejs/Product/Nodejs/NodejsTools.vsct b/Nodejs/Product/Nodejs/NodejsTools.vsct
index 3e0759ff2..5c6beb2a7 100644
--- a/Nodejs/Product/Nodejs/NodejsTools.vsct
+++ b/Nodejs/Product/Nodejs/NodejsTools.vsct
@@ -209,6 +209,17 @@
Attach Node.js Debugger
+
+
+
diff --git a/Nodejs/Product/ProjectWizard/ImportWizard.cs b/Nodejs/Product/ProjectWizard/ImportWizard.cs
index c4983009c..50691fa5e 100644
--- a/Nodejs/Product/ProjectWizard/ImportWizard.cs
+++ b/Nodejs/Product/ProjectWizard/ImportWizard.cs
@@ -1,10 +1,9 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
-using EnvDTE;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
@@ -15,7 +14,7 @@ namespace Microsoft.NodejsTools.ProjectWizard
{
public sealed class NewProjectFromExistingWizard : IWizard
{
- public static Boolean IsAddNewProjectCmd { get; set; }
+ public static bool IsAddNewProjectCmd { get; set; }
public void BeforeOpeningFile(EnvDTE.ProjectItem projectItem) { }
public void ProjectFinishedGenerating(EnvDTE.Project project) { }
public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem) { }
@@ -23,66 +22,66 @@ public void RunFinished() { }
public void RunStarted(object automationObject, Dictionary replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
- var dte = automationObject as DTE;
- if (dte == null)
+ var provider = automationObject as Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
+ if (provider == null)
{
- var provider = automationObject as Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
- if (provider != null)
- {
- dte = new ServiceProvider(provider).GetService(typeof(DTE)) as DTE;
- }
+ MessageBox.Show(ProjectWizardResources.ErrorNoDte, SR.ProductName);
+ throw new WizardBackoutException();
}
- bool addingNewProject = false;
- if (dte == null)
+ using (var serviceProvider = new ServiceProvider(provider))
{
- MessageBox.Show(ProjectWizardResources.ImportWizzardCouldNotStartNotAutomationObjectErrorMessage, SR.ProductName);
- }
- else
- {
- // https://nodejstools.codeplex.com/workitem/462
- // we need to make sure our package is loaded before invoking our command
- Guid packageGuid = new Guid(Guids.NodejsPackageString);
- IVsPackage package;
- ((IVsShell)Package.GetGlobalService(typeof(SVsShell))).LoadPackage(
- ref packageGuid,
- out package
- );
+ var hr = EnsurePackageLoaded(serviceProvider);
+ if (ErrorHandler.Failed(hr))
+ {
+ MessageBox.Show(string.Format(ProjectWizardResources.ImportWizardCouldNotStartFailedToLoadPackage, hr), SR.ProductName);
+ throw new WizardBackoutException();
+ }
+ var uiShell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
- System.Threading.Tasks.Task.Factory.StartNew(() =>
+ string directory;
+ var projName = replacementsDictionary["$projectname$"];
+ if (!replacementsDictionary.TryGetValue("$specifiedsolutionname$", out var solnName) || string.IsNullOrWhiteSpace(solnName))
+ {
+ // Create directory is unchecked, destinationdirectory is the
+ // directory name the user entered plus the project name, we want
+ // to remove the solution directory.
+ directory = Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]);
+ }
+ else
{
- string projName = replacementsDictionary["$projectname$"];
- string solnName = replacementsDictionary["$specifiedsolutionname$"];
- string directory;
- if (string.IsNullOrWhiteSpace(solnName))
- {
- // Create directory is unchecked, destinationdirectory is the
- // directory name the user entered plus the project name, we want
- // to remove the solution directory.
- directory = Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]);
- }
- else
- {
- // Create directory is checked, the destinationdirectory is the
- // directory the user entered plus the project name plus the
- // solution name.
- directory = Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]);
- }
+ // Create directory is checked, the destinationdirectory is the
+ // directory the user entered plus the project name plus the
+ // solution name - we want to remove both extra folders
+ directory = Path.GetDirectoryName(Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]));
+ }
- var context = addingNewProject ?
- (int)VSConstants.VSStd97CmdID.AddExistingProject :
- (int)VSConstants.VSStd97CmdID.OpenProject;
- object inObj = projName + "|" + directory + "|" + context, outObj = null;
- dte.Commands.Raise(Guids.NodejsCmdSet.ToString("B"), (int)PkgCmdId.cmdidImportWizard, ref inObj, ref outObj);
- });
+ var context = IsAddNewProjectCmd ? (int)VSConstants.VSStd97CmdID.AddExistingProject : (int)VSConstants.VSStd97CmdID.OpenProject;
+
+ object inObj = projName + "|" + directory + "|" + context;
+ var guid = Guids.NodejsCmdSet;
+ hr = uiShell.PostExecCommand(ref guid, (uint)PkgCmdId.cmdidImportWizard, 0, ref inObj);
+ if (ErrorHandler.Failed(hr))
+ {
+ MessageBox.Show(string.Format(ProjectWizardResources.ImportWizardCouldNotStartUnexpectedError, hr), SR.ProductName);
+ }
}
- addingNewProject = IsAddNewProjectCmd;
+
throw new WizardCancelledException();
}
- public bool ShouldAddProjectItem(string filePath)
+ private static int EnsurePackageLoaded(IServiceProvider serviceProvider)
{
- return false;
+ var shell = (IVsShell)serviceProvider.GetService(typeof(SVsShell));
+ var pkgGuid = new Guid(Guids.NodejsPackageString);
+
+ if (ErrorHandler.Failed(shell.IsPackageLoaded(ref pkgGuid, out var pkg)) || pkg == null)
+ {
+ return shell.LoadPackage(ref pkgGuid, out pkg);
+ }
+ return VSConstants.S_OK;
}
+
+ public bool ShouldAddProjectItem(string filePath) => false;
}
}
diff --git a/Nodejs/Product/ProjectWizard/ProjectWizardResources.Designer.cs b/Nodejs/Product/ProjectWizard/ProjectWizardResources.Designer.cs
index 5bd08fabb..fecfc57f3 100644
--- a/Nodejs/Product/ProjectWizard/ProjectWizardResources.Designer.cs
+++ b/Nodejs/Product/ProjectWizard/ProjectWizardResources.Designer.cs
@@ -19,7 +19,7 @@ namespace Microsoft.NodejsTools.ProjectWizard {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class ProjectWizardResources {
@@ -137,11 +137,20 @@ internal static string ErrorNoDte {
}
///
- /// Looks up a localized string similar to Unable to start wizard: no automation object available..
+ /// Looks up a localized string similar to Unable to start wizard: failed to load Node Tools support Package (0x{0:X08}).
+ ///
+ internal static string ImportWizardCouldNotStartFailedToLoadPackage {
+ get {
+ return ResourceManager.GetString("ImportWizardCouldNotStartFailedToLoadPackage", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Unable to start wizard: Unexpected error 0x{0:X08}.
///
- internal static string ImportWizzardCouldNotStartNotAutomationObjectErrorMessage {
+ internal static string ImportWizardCouldNotStartUnexpectedError {
get {
- return ResourceManager.GetString("ImportWizzardCouldNotStartNotAutomationObjectErrorMessage", resourceCulture);
+ return ResourceManager.GetString("ImportWizardCouldNotStartUnexpectedError", resourceCulture);
}
}
}
diff --git a/Nodejs/Product/ProjectWizard/ProjectWizardResources.resx b/Nodejs/Product/ProjectWizard/ProjectWizardResources.resx
index 77818efcb..46b0cac2d 100644
--- a/Nodejs/Product/ProjectWizard/ProjectWizardResources.resx
+++ b/Nodejs/Product/ProjectWizard/ProjectWizardResources.resx
@@ -117,9 +117,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- Unable to start wizard: no automation object available.
-
These tools are a free download for your version of Visual Studio that allow you to write, deploy and debug applications for Microsoft Azure in a range of programming languages.
@@ -145,7 +142,13 @@ Some manual steps will be required to configure your project.
&Download and install now
You will need to restart Visual Studio after installation.
-
+
+ Unable to start wizard: failed to load Node Tools support Package (0x{0:X08})
+
+
+ Unable to start wizard: Unexpected error 0x{0:X08}
+
+
Unable to start wizard: no automation object available.
\ No newline at end of file