Skip to content

Commit 9176b7d

Browse files
authored
Merge pull request #1619 from paulvanbrenk/ctiFixes
Cti fixes
2 parents c8b0978 + ec11bcd commit 9176b7d

File tree

13 files changed

+285
-247
lines changed

13 files changed

+285
-247
lines changed

Nodejs/Product/InteractiveWindow/InteractiveWindow.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</Reference>
6262
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
6363
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
64-
<Private>True</Private>
64+
<Private>False</Private>
6565
</Reference>
6666
<Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
6767
<EmbedInteropTypes>True</EmbedInteropTypes>
@@ -156,7 +156,7 @@
156156
</ItemGroup>
157157
<ItemGroup>
158158
<FilesToLocalize Include="$(OutDir)\$(AssemblyName).dll">
159-
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).lcl</TranslationFile>
159+
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).dll.lcl</TranslationFile>
160160
<LciCommentFile>$(BuildRoot)\loc\lci\$(AssemblyName).dll.lci</LciCommentFile>
161161
<SettingsFile>$(LSBuildRoot)\MCP_excludeBaml.lss</SettingsFile>
162162
<InProject>false</InProject>

Nodejs/Product/Nodejs/Nodejs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@
10141014
</ItemGroup>
10151015
<ItemGroup>
10161016
<FilesToLocalize Include="$(OutDir)\$(AssemblyName).dll">
1017-
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).lcl</TranslationFile>
1017+
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).dll.lcl</TranslationFile>
10181018
<LciCommentFile>$(BuildRoot)\loc\lci\$(AssemblyName).dll.lci</LciCommentFile>
10191019
<SettingsFile>$(LSBuildRoot)\MCP_excludeBaml.lss</SettingsFile>
10201020
<InProject>false</InProject>

Nodejs/Product/Nodejs/Repl/NpmReplCommand.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,17 @@ public async Task<ExecutionResult> Execute(IReplWindow window, string arguments)
111111
}
112112

113113
Tuple<string, IVsHierarchy> projectInfo;
114-
NodejsProjectNode nodejsProject = null;
115114
if (string.IsNullOrEmpty(projectPath) && projectNameToDirectoryDictionary.Count == 1)
116115
{
117116
projectInfo = projectNameToDirectoryDictionary.Values.First();
118117
}
119-
else if (projectNameToDirectoryDictionary.TryGetValue(projectPath, out projectInfo))
118+
else
119+
{
120+
projectNameToDirectoryDictionary.TryGetValue(projectPath, out projectInfo);
121+
}
122+
123+
NodejsProjectNode nodejsProject = null;
124+
if (projectInfo != null)
120125
{
121126
projectPath = projectInfo.Item1;
122127
if (projectInfo.Item2 != null)
@@ -138,7 +143,7 @@ public async Task<ExecutionResult> Execute(IReplWindow window, string arguments)
138143

139144
if (!isGlobalCommand && !Directory.Exists(projectDirectoryPath))
140145
{
141-
window.WriteError("Please specify a valid Node.js project or project directory. If your solution contains multiple projects, specify a target project using .npm [ProjectName or ProjectDir] <npm arguments> For example: .npm [MyApp] list");
146+
window.WriteError(Resources.NpmSpecifyValidProject);
142147
return ExecutionResult.Failure;
143148
}
144149

@@ -183,9 +188,12 @@ await ExecuteNpmCommandAsync(
183188
return ExecutionResult.Success;
184189
}
185190

186-
public string Description => "Executes npm command. If solution contains multiple projects, specify target project using .npm [ProjectName] <npm arguments>";
191+
public string Description => Resources.NpmExecuteCommand;
192+
187193
public string Command => "npm";
194+
188195
public object ButtonContent => null;
196+
189197
// TODO: This is duplicated from Npm project
190198
// We should consider using InternalsVisibleTo to avoid code duplication
191199
internal static async Task<IEnumerable<string>> ExecuteNpmCommandAsync(
@@ -271,7 +279,8 @@ public NpmReplRedirector(IReplWindow window)
271279
this._window = window;
272280
this.HasErrors = false;
273281
}
274-
public bool HasErrors { get; set; }
282+
283+
public bool HasErrors { get; private set; }
275284

276285
public override void WriteLine(string decodedString)
277286
{

Nodejs/Product/Nodejs/Resources.Designer.cs

Lines changed: 217 additions & 199 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Nodejs/Product/Nodejs/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,10 @@ Error retrieving websocket debug proxy information from web.config.</value>
662662
<data name="PackageJsonNotCheckedOutMessage" xml:space="preserve">
663663
<value>Failed to check out 'package.json'. Please ensure the file is checked out, before adding or removing NPM packages.</value>
664664
</data>
665+
<data name="NpmSpecifyValidProject" xml:space="preserve">
666+
<value>Please specify a valid Node.js project or project directory. If your solution contains multiple projects, specify a target project using .npm [ProjectName or ProjectDir] &lt;npm arguments&gt; For example: .npm [MyApp] list.</value>
667+
</data>
668+
<data name="NpmExecuteCommand" xml:space="preserve">
669+
<value>Executes npm command. If solution contains multiple projects, specify target project using .npm [ProjectName] &lt;npm arguments&gt;</value>
670+
</data>
665671
</root>

Nodejs/Product/Nodejs/TestFrameworks/TestFrameworkDirectories.cs

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,64 @@
33
using System;
44
using System.Collections.Generic;
55
using System.IO;
6+
using System.Linq;
67

78
namespace Microsoft.NodejsTools.TestFrameworks
89
{
910
internal class TestFrameworkDirectories
1011
{
1112
public const string ExportRunnerFramework = "ExportRunner";
1213
private const string TestFrameworksDirectory = "TestFrameworks";
14+
private const string TestAdapterDirectory = "TestAdapter";
1315

14-
private readonly Dictionary<string, string> _frameworkDirectories;
16+
private readonly Dictionary<string, string> frameworkDirectories;
1517

1618
public TestFrameworkDirectories()
1719
{
18-
this._frameworkDirectories = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
19-
foreach (var directory in Directory.GetDirectories(GetBaseTestframeworkFolder()))
20+
this.frameworkDirectories = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
21+
22+
var testFrameworkRoot = GetTestframeworkFolderRoot();
23+
if(!Directory.Exists(testFrameworkRoot))
24+
{
25+
throw new InvalidOperationException("Unable to find test framework folder");
26+
}
27+
28+
foreach (var directory in Directory.GetDirectories(testFrameworkRoot))
2029
{
2130
var name = Path.GetFileName(directory);
22-
this._frameworkDirectories.Add(name, directory);
31+
this.frameworkDirectories.Add(name, directory);
2332
}
24-
string defaultFx;
25-
this._frameworkDirectories.TryGetValue(ExportRunnerFramework, out defaultFx);
26-
if (defaultFx == null)
33+
34+
if (!this.frameworkDirectories.TryGetValue(ExportRunnerFramework, out var defaultFx) || string.IsNullOrEmpty(defaultFx))
2735
{
2836
throw new InvalidOperationException("Missing generic test framework");
2937
}
3038
}
3139

32-
public List<string> GetFrameworkNames()
33-
{
34-
return new List<string>(this._frameworkDirectories.Keys);
35-
}
40+
public List<string> GetFrameworkNames() => this.frameworkDirectories.Keys.ToList();
3641

37-
public List<string> GetFrameworkDirectories()
38-
{
39-
return new List<string>(this._frameworkDirectories.Values);
40-
}
42+
public List<string> GetFrameworkDirectories() => this.frameworkDirectories.Values.ToList();
4143

42-
private static string GetBaseTestframeworkFolder()
44+
private static string GetTestframeworkFolderRoot()
4345
{
44-
var installFolder = GetExecutingAssemblyPath();
45-
var baseDirectory = Path.Combine(installFolder, TestFrameworksDirectory);
46+
// This class is used in 2 different assemblies, installed in 2 locations:
47+
//
48+
// "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\Extensions\Microsoft\NodeJsTools\NodeJsTools\Microsoft.NodejsTools.dll"
49+
// and
50+
// "C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\Extensions\Microsoft\NodeJsTools\TestAdapter\Microsoft.NodejsTools.TestAdapter.dll"
51+
//
52+
// However in both cases, we should just go up a folder to the nodejstools root, and then into the TestAdapter folder.
53+
54+
var currentAssembly = typeof(TestFrameworkDirectories).Assembly;
55+
var currentAssemblyFolder = Path.GetDirectoryName(currentAssembly.Location);
56+
var nodejsRootFolder = Path.GetDirectoryName(currentAssemblyFolder);
57+
58+
var baseDirectory = Path.Combine(nodejsRootFolder, TestAdapterDirectory, TestFrameworksDirectory);
4659
#if DEBUG
4760
// To allow easier debugging of the test adapter, try to use the local directory as a fallback.
4861
baseDirectory = Directory.Exists(baseDirectory) ? baseDirectory : Path.Combine(Directory.GetCurrentDirectory(), TestFrameworksDirectory);
4962
#endif
5063
return baseDirectory;
5164
}
52-
53-
private static string GetExecutingAssemblyPath()
54-
{
55-
var codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
56-
var uri = new UriBuilder(codeBase);
57-
var path = Uri.UnescapeDataString(uri.Path);
58-
return Path.GetDirectoryName(path);
59-
}
6065
}
6166
}

Nodejs/Product/Npm/Npm.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<ItemGroup>
3535
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3636
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
37-
<Private>True</Private>
37+
<Private>False</Private>
3838
</Reference>
3939
<Reference Include="System" />
4040
<Reference Include="System.Core" />
@@ -143,7 +143,7 @@
143143
</ItemGroup>
144144
<ItemGroup>
145145
<FilesToLocalize Include="$(OutDir)\$(AssemblyName).dll">
146-
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).lcl</TranslationFile>
146+
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).dll.lcl</TranslationFile>
147147
<LciCommentFile>$(BuildRoot)\loc\lci\$(AssemblyName).dll.lci</LciCommentFile>
148148
<SettingsFile>$(LSBuildRoot)\MCP_excludeBaml.lss</SettingsFile>
149149
<InProject>false</InProject>

Nodejs/Product/ProjectWizard/ProjectWizard.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
</ItemGroup>
108108
<ItemGroup>
109109
<FilesToLocalize Include="$(OutDir)\$(AssemblyName).dll">
110-
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).lcl</TranslationFile>
110+
<TranslationFile>$(BuildRoot)\loc\lcl\{lang}\$(AssemblyName).dll.lcl</TranslationFile>
111111
<LciCommentFile>$(BuildRoot)\loc\lci\$(AssemblyName).dll.lci</LciCommentFile>
112112
<SettingsFile>$(LSBuildRoot)\MCP_excludeBaml.lss</SettingsFile>
113113
<InProject>false</InProject>

Nodejs/Product/TestAdapter/TestAdapter.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props" />
3+
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props" Condition="Exists('..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props')" />
44
<PropertyGroup>
55
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
66
<NuGetPackageImportStamp>
@@ -82,7 +82,7 @@
8282
</Reference>
8383
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
8484
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
85-
<Private>True</Private>
85+
<Private>False</Private>
8686
</Reference>
8787
<Reference Include="PresentationCore" />
8888
<Reference Include="PresentationFramework" />
@@ -191,5 +191,5 @@
191191
<Error Condition="!Exists('..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.props'))" />
192192
<Error Condition="!Exists('..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets'))" />
193193
</Target>
194-
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets" />
194+
<Import Project="..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets" Condition="Exists('..\..\packages\MicroBuild.Core.0.2.0\build\MicroBuild.Core.targets')" />
195195
</Project>

Nodejs/Product/TestAdapterShim/AssemblyResolver.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static string GetVSInstallDir()
2020
var vsTestFrameworkAssembly = typeof(ITestExecutor).Assembly;
2121
var testAdapterPath = vsTestFrameworkAssembly.Location;
2222

23-
// C:\Program Files (x86)\Microsoft Visual Studio\2017\VSUJSLT\Common7\IDE\CommonExtensions\Microsoft\NodeJs Tools Unit Test Adapter\Microsoft.nodejstools.TestAdapter.dll
23+
// C:\Program Files (x86)\Microsoft Visual Studio\2017\VSUJSLT\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
2424
var indexOfCommon7Ide = testAdapterPath.IndexOf("common7", StringComparison.OrdinalIgnoreCase);
2525
string vsInstallDir = testAdapterPath.Substring(0, indexOfCommon7Ide);
2626

@@ -31,12 +31,12 @@ private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
3131
{
3232
// Use the setup API to find the VS install Dir, then build paths to the Private and Public Assemblies folders
3333
var installPath = GetVSInstallDir();
34-
var ideFolder = Path.Combine(installPath, "Common7\\IDE");
34+
var ideFolder = Path.Combine(installPath, "Common7", "IDE");
3535
var paths = new[] {
3636
Path.Combine(ideFolder, "PrivateAssemblies"),
3737
Path.Combine(ideFolder, "PublicAssemblies"),
38-
Path.Combine(installPath, "MSBuild\\15.0\\Bin"),
39-
Path.Combine(ideFolder, "CommonExtensions\\Microsoft\\WebClient\\Project System") };
38+
Path.Combine(installPath, "MSBuild","15.0","Bin"),
39+
Path.Combine(ideFolder, "CommonExtensions","Microsoft","WebClient","Project System") };
4040

4141
// This is what comes in for args.Name, but we really just want the dll file name:
4242
// "Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
@@ -45,7 +45,7 @@ private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
4545
foreach (var path in paths)
4646
{
4747
// Check under privateAssemblies
48-
if (AssemblyResolver.ResolveAssemblyPath(path, resolveTargetAssemblyName, out var resolvedAssembly))
48+
if (ResolveAssemblyPath(path, resolveTargetAssemblyName, out var resolvedAssembly))
4949
{
5050
return resolvedAssembly;
5151
}

0 commit comments

Comments
 (0)