Merge pull request #414 from nguerrera/vs-dev-server
* Move source files out of roots and tidy tsconfig * Use local build of adl-server when debugging VS extension
This commit is contained in:
Коммит
8568e3c2dc
|
@ -9,3 +9,8 @@ charset = utf-8
|
|||
|
||||
[*.cs]
|
||||
csharp_new_line_before_open_brace = none
|
||||
csharp_new_line_before_catch = false
|
||||
csharp_new_line_before_else = false
|
||||
csharp_new_line_before_finally = false
|
||||
csharp_new_line_before_members_in_anonymous_types = false
|
||||
csharp_new_line_before_members_in_object_initializers = false
|
||||
|
|
|
@ -4,17 +4,18 @@
|
|||
<TargetFramework>net472</TargetFramework>
|
||||
<DebugType>Embedded</DebugType>
|
||||
<EmbedAllSources>true</EmbedAllSources>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
|
||||
<StartArguments>/rootsuffix Exp</StartArguments>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<DeployExtension Condition="'$(Configuration)' != 'Debug'">false</DeployExtension>
|
||||
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="LICENSE" />
|
||||
<Content Include="adl.pkgdef" />
|
||||
<Content Include="node_modules/adl-vscode/dist/adl.tmLanguage" Link="TextMate/adl.tmLanguage" />
|
||||
<Content Include="$(IntermediateOutputPath)DebugSourceDirectory.txt" Link="DebugSourceDirectory.txt" Condition="'$(Configuration)' == 'Debug'"/>
|
||||
<Content Update="@(Content)" IncludeInVSIX="true" CopyToOutputDirectory="PreserveNewest" />
|
||||
<None Include="*;Properties\*" Exclude="@(Content);*.sln" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.0.206" ExcludeAssets="runtime" />
|
||||
|
@ -25,4 +26,7 @@
|
|||
<Target Name="WarnAboutDotnetBuildAndVsix" Condition="'$(MSBuildRuntimeType)' == 'Core'" AfterTargets="AfterBuild">
|
||||
<Message Importance="High" Text="VSIX packaging skipped: not supported by `dotnet build`, use Visual Studio `msbuild` to package VSIX." />
|
||||
</Target>
|
||||
<Target Name="WriteDebugSourceDirectory" Condition="'$(Configuration)' == 'Debug'" BeforeTargets="BeforeBuild">
|
||||
<WriteLinesToFile File="$(IntermediateOutputPath)DebugSourceDirectory.txt" Lines="$(MSBuildThisFileDirectory)" WriteOnlyWhenDifferent="true" Overwrite="true" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"profiles": {
|
||||
"Microsoft.Adl.VisualStudio": {
|
||||
"commandName": "Executable",
|
||||
"executablePath": "devenv.exe",
|
||||
"commandLineArgs": "/rootSuffix Exp",
|
||||
"environmentVariables": {
|
||||
"ADL_SERVER_NODE_OPTIONS": "--nolazy --inspect=4242",
|
||||
"ADL_DEVELOPMENT_MODE": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -42,15 +44,29 @@ namespace Microsoft.Adl.VisualStudio {
|
|||
public async Task<Connection> ActivateAsync(CancellationToken token) {
|
||||
await Task.Yield();
|
||||
|
||||
var options = Environment.GetEnvironmentVariable("ADL_SERVER_NODE_OPTIONS");
|
||||
var info = new ProcessStartInfo {
|
||||
// Use adl-server on PATH in production
|
||||
FileName = "adl-server.cmd",
|
||||
Arguments = "--stdio",
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
Environment = { new("NODE_OPTIONS", options) },
|
||||
};
|
||||
|
||||
#if DEBUG
|
||||
// Use local build of adl-server in development (lauched from F5 in VS)
|
||||
if (InDevelopmentMode()) {
|
||||
var module = GetDevelopmentAdlServerPath();
|
||||
info.FileName = "node.exe";
|
||||
info.Arguments = $"{options} {module} {info.Arguments}";
|
||||
// --nolazy isn't supported by NODE_OPTIONS so we pass these via CLI instead
|
||||
info.Environment.Remove("NODE_OPTIONS");
|
||||
}
|
||||
#endif
|
||||
|
||||
var process = Process.Start(info);
|
||||
return new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
|
||||
}
|
||||
|
@ -66,5 +82,23 @@ namespace Microsoft.Adl.VisualStudio {
|
|||
public Task OnServerInitializedAsync() {
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
static bool InDevelopmentMode() {
|
||||
return string.Equals(
|
||||
Environment.GetEnvironmentVariable("ADL_DEVELOPMENT_MODE"),
|
||||
"true",
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
static string GetDevelopmentAdlServerPath() {
|
||||
// Even when debugging, we get deployed to an extension folder outside the source
|
||||
// tree, so we stash the source directory in a file in debug builds so we can use it
|
||||
// to run adl-server against the live developer build in the source tree.
|
||||
var thisDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
var srcDir = File.ReadAllText(Path.Combine(thisDir, "DebugSourceDirectory.txt")).Trim();
|
||||
return Path.GetFullPath(Path.Combine(srcDir, "../adl/cmd/adl-server.js"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@
|
|||
"compile": "tsc -p .",
|
||||
"watch": "tsc -p . --watch",
|
||||
"dogfood": "node scripts/dogfood.js",
|
||||
"generate-tmlanguage": "node dist-dev/adl.tmlanguage.js",
|
||||
"generate-tmlanguage": "node dist-dev/tmlanguage.js",
|
||||
"generate-third-party-notices": "node scripts/generate-third-party-notices.js",
|
||||
"rollup": "rollup --config --failAfterWarnings 2>&1",
|
||||
"package-vsix": "vsce package --yarn",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// TextMate-based syntax highlighting is implemented in this file.
|
||||
// adl.tmLanguage.json is generated by running this script.
|
||||
// adl.tmLanguage is generated by running this script.
|
||||
|
||||
import * as tm from "@azure-tools/tmlanguage-generator";
|
||||
import fs from "fs/promises";
|
|
@ -2,8 +2,7 @@
|
|||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist-dev",
|
||||
"rootDir": "."
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": ["./**/*.ts"],
|
||||
"exclude": ["dist", "test/scenarios/**", "resources", "node_modules", "**/*.d.ts", "**/*.adl.ts"]
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
"types": ["node", "mocha"]
|
||||
},
|
||||
"include": ["./**/*.ts"],
|
||||
"exclude": ["dist", "test/scenarios/**", "resources", "node_modules", "**/*.d.ts", "**/*.adl.ts"]
|
||||
"exclude": ["dist", "node_modules", "**/*.d.ts"]
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"bugs": {
|
||||
"url": "https://github.com/Azure/adl/issues"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"main": "dist/tmlanguage-generator.js",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"rootDir": "src",
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["./**/*.ts"],
|
||||
"exclude": ["dist", "node_modules", "**/*.d.ts"]
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче