From b3fba48529ea068b0ecd753c1283d33a0098b87d Mon Sep 17 00:00:00 2001 From: "Yi Zhang (CLR)" Date: Thu, 19 Jan 2017 23:25:58 -0800 Subject: =?UTF-8?q?Update=20CoreRT=20doc=20to=20include=20how=20to=20debug?= =?UTF-8?q?=20ILC=20using=20VSCode=20in=20non-win=E2=80=A6=20(#2514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update CoreRT doc to include how to debug ILC using VSCode in non-windows * Automate some of the tasks and check in vscode .json files * Simplify instructions * Explains the magic and added a bit more coding annotations to make it looks better * Change ILCompiler.csproj to output ILC.dll directly to be VS-code friendly --- .vscode/launch.json | 27 +++++++++++ .vscode/tasks.json | 18 ++++++++ Documentation/README.md | 1 + .../how-to-build-and-run-ilcompiler-in-vscode.md | 54 ++++++++++++++++++++++ .../Microsoft.NETCore.Native.targets | 2 +- src/ILCompiler/src/ILCompiler.csproj | 8 ++++ src/ILCompiler/src/ilc.runtimeconfig.json | 8 ++++ src/Test.CoreLib/readme.md | 2 +- src/packaging/packages.targets | 8 +++- 9 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 Documentation/how-to-build-and-run-ilcompiler-in-vscode.md create mode 100755 src/ILCompiler/src/ilc.runtimeconfig.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..46d40ef7b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "", + "osx": { + "program": "${workspaceRoot}/bin/Product/OSX.x64.Debug/packaging/publish1/ilc.dll" + }, + "linux": { + "program": "${workspaceRoot}/bin/Product/Linux.x64.Debug/packaging/publish1/ilc.dll" + }, + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "externalConsole": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command.pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..3420cc476 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "${workspaceRoot}/build.sh", + "isShellCommand": false, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ ], + "isBuildCommand": true, + "showOutput": "silent", + "suppressTaskName" : true, + "problemMatcher": "$msCompile" + } + ] +} diff --git a/Documentation/README.md b/Documentation/README.md index bcca1faeb..1f099ff2c 100644 --- a/Documentation/README.md +++ b/Documentation/README.md @@ -12,5 +12,6 @@ This is the repo for CoreRT, the .NET Core runtime optimized for AOT (Ahead of T - [Prerequisites for building](prerequisites-for-building.md) - [How to build and run from the Command Line](how-to-build-and-run-ilcompiler-in-console-shell-prompt.md) - [How to build and run from Visual Studio](how-to-build-and-run-ilcompiler-in-visual-studio-2015.md) +- [How to build and run from VSCode](how-to-build-and-run-ilcompiler-in-vscode.md) - [How to run tests](how-to-run-tests.md) - [Cross Compilation for ARM on Linux](cross-building.md) diff --git a/Documentation/how-to-build-and-run-ilcompiler-in-vscode.md b/Documentation/how-to-build-and-run-ilcompiler-in-vscode.md new file mode 100644 index 000000000..df1f3fe9b --- /dev/null +++ b/Documentation/how-to-build-and-run-ilcompiler-in-vscode.md @@ -0,0 +1,54 @@ +_Please ensure that [pre-requisites](prerequisites-for-building.md) are installed for a successful build of the repo._ + +_Note_: + +* Instructions below assume ```~/corert``` is the repo root. + +# Setting up # + +Please make sure you have latest VS Code, C# extension, and .NET Core available. This guide is tested under C# 1.6.2 + VS Code 1.8.1 + CLI 1.0.0-preview4-004233. + +This guide assumes that your VS code workspace is set to the root of the repo. + +# Running VS Code + +We've checked-in reasonable default ```launch.json``` and ```tasks.json``` under ```corert/.vscode``` directory. You only need to run vscode form corert root: + +``` +code ~/corert +``` + +And then press SHIFT+COMMAND+B to start the build. + +# Debugging ILC.exe using .NET Core Debugger # + +Go to the debug pane and click Debug, choose .NET Core as the environment. If needed, you can change program property in launch.json (the gear button) to point to a different flavor of ilc: + +```json + "osx": { + "program": "${workspaceRoot}/bin/Product/OSX.x64.Debug/packaging/publish1/ilc.dll" + }, + "linux": { + "program": "${workspaceRoot}/bin/Product/Linux.x64.Debug/packaging/publish1/ilc.dll" + }, +``` + +By default we've disabled automatic build before debug. If you want to change that, you can change the ```preLaunchTask``` property to ```"build"```. But this is not currently recommended. + +# Getting ILC response files + +A ```.ilc.rsp``` file path can be easily obtained from a .NET core project that you want to debug by following command: + +``` +dotnet build /t:LinkNative /t:Rebuild /v:Detailed | grep ".ilc.rsp" +``` + +Once you have the ilc path, you can change ```launch.json``` accordingly: + +```json + "args": ["@obj/Debug/netcoreapp1.0/native/.ilc.rsp"], + "cwd": "", +``` + +* ```args``` - the argument to ILC +* ```cwd``` - the current directory where ILC is running. You can set it to the .NET Core project root. diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.targets b/src/BuildIntegration/Microsoft.NETCore.Native.targets index 9d1325eff..c45f6636f 100644 --- a/src/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/BuildIntegration/Microsoft.NETCore.Native.targets @@ -91,7 +91,7 @@ See the LICENSE file in the project root for more information. corerun - + diff --git a/src/ILCompiler/src/ILCompiler.csproj b/src/ILCompiler/src/ILCompiler.csproj index 1121a50ee..3ffc7651a 100644 --- a/src/ILCompiler/src/ILCompiler.csproj +++ b/src/ILCompiler/src/ILCompiler.csproj @@ -7,6 +7,10 @@ {DD5B6BAA-D41A-4A6E-9E7D-83060F394B10} Exe ILCompiler + + + + .dll ilc en-US 512 @@ -44,6 +48,10 @@ + + + PreserveNewest + diff --git a/src/ILCompiler/src/ilc.runtimeconfig.json b/src/ILCompiler/src/ilc.runtimeconfig.json new file mode 100755 index 000000000..d0437745b --- /dev/null +++ b/src/ILCompiler/src/ilc.runtimeconfig.json @@ -0,0 +1,8 @@ +{ + "runtimeOptions": { + "framework": { + "name": "Microsoft.NETCore.App", + "version": "1.0.1" + } + } +} \ No newline at end of file diff --git a/src/Test.CoreLib/readme.md b/src/Test.CoreLib/readme.md index d05eca4ff..878302f80 100644 --- a/src/Test.CoreLib/readme.md +++ b/src/Test.CoreLib/readme.md @@ -14,7 +14,7 @@ csc /noconfig /nostdlib Program.cs /r:\bin\Product\Windows_NT.x64.Deb 2. Compile the IL with ILC -Use ilc.exe that was built with the repo to compile the program. +Use ilc.dll that was built with the repo to compile the program. ``` ilc repro.exe -o:repro.obj -r:\bin\Product\Windows_NT.x64.Debug\Test.CoreLib\Test.CoreLib.dll --systemmodule Test.CoreLib diff --git a/src/packaging/packages.targets b/src/packaging/packages.targets index f362e52cd..00b505047 100644 --- a/src/packaging/packages.targets +++ b/src/packaging/packages.targets @@ -33,7 +33,7 @@ - + @@ -74,6 +74,12 @@ ]]> + + + + + ]]> + -- cgit v1.2.3