-
Notifications
You must be signed in to change notification settings - Fork 749
Issues using coreclr on Linux #613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Other API calls do work though:
|
That works for me too - curious - I'm trying to get debuggers working in Linux to get a handle on what's going on ... |
I am using docker, VS 2017 +docker tools + custom C# script for DTE and debugging works perfectly. This an example of my script script for C# Interactive window. #r "EnvDTE100"
using EnvDTE;
using EnvDTE80;
using System;
using System.IO;
using System.Diagnostics;
using System.Linq;
var dte = (DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.15.0");
var startupProject = Path.Combine(
Path.GetDirectoryName(dte.Solution.FullName),
(string)(((object[])dte.Solution.SolutionBuild.StartupProjects).First()));
Project FindProjectByNameInFolder(Project solutionFolder, string name)
{
for (int i = 1; i <= solutionFolder.ProjectItems.Count; i++)
{
var subProject = solutionFolder.ProjectItems.Item(i).SubProject;
if (subProject == null)
{
continue;
}
if (subProject.FullName == name)
{
return subProject;
}
if (subProject.Kind == ProjectKinds.vsProjectKindSolutionFolder)
{
var p = FindProjectByNameInFolder(subProject, name);
if (p != null)
{
return p;
}
}
}
return null;
}
Project FindProjectByName(string name)
{
foreach (var obj in dte.Solution.Projects)
{
var project = obj as Project;
if (project == null)
{
continue;
}
if (project.FullName == name)
{
return project;
}
if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder)
{
var p = FindProjectByNameInFolder(project, name);
if (p != null)
{
return p;
}
}
}
return null;
}
int SimpleExecute(string fileName, string arguments, out string stdOut, out string stdErr)
{
// Start the child process.
System.Diagnostics.Process p = new System.Diagnostics.Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = fileName;
p.StartInfo.Arguments = arguments;
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
stdOut = p.StandardOutput.ReadToEnd();
stdErr = p.StandardError.ReadToEnd();
p.WaitForExit();
return p.ExitCode;
}
var project = FindProjectByName(startupProject);
var projectDir = Path.GetDirectoryName(project.FullName);
var solutionDir = Path.GetDirectoryName(dte.Solution.FullName);
var projectRelativeDir = projectDir.Replace(solutionDir + "\\", string.Empty).Replace("\\", "/");
var outputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString().Replace("\\", "/").TrimEnd('/');
var outputFileName = project.Properties.Item("OutputFileName").Value.ToString();
if (string.IsNullOrWhiteSpace(outputFileName))
{
outputFileName = project.Name + ".dll";
}
////Console.WriteLine(outputFileName);
////Console.WriteLine(outputPath);
////Console.WriteLine(projectRelativeDir);
var psArgs = $"ps --no-trunc --filter ancestor=my-name:{Environment.GetEnvironmentVariable("USERNAME")}-dev -n 1 --format \"{{{{.ID}}}}\"";
////Console.WriteLine(psArgs);
var exitCode = SimpleExecute("docker", psArgs, out var stdOut, out var stdErr);
Console.WriteLine(stdOut);
if (exitCode != 0)
{
Console.WriteLine(stdOut);
Console.WriteLine(stdErr);
return;
}
var containerId = stdOut.Substring(0, 12);
var launchOptionsContent =
$@"
{{
""version"": ""0.2.0"",
""adapter"": ""C:\\Program Files\\Docker\\Docker\\Resources\\bin\\docker.exe"",
""adapterArgs"": ""exec -i {containerId} /remote_debugger/vsdbg --interpreter=vscode"",
""languageMappings"": {{
""C#"": {{
""languageId"": ""3F5162F8-07C6-11D3-9053-00C04FA302A1"",
""extensions"": [ ""*"" ]
}}
}},
""exceptionCategoryMappings"": {{
""CLR"": ""449EC4CC-30D2-4032-9256-EE18EB41B62B"",
""MDA"": ""6ECE07A9-0EDE-45C4-8296-818D8FC401D4""
}},
""configurations"": [
{{
""name"": "".NET Core Launch"",
""type"": ""coreclr"",
""request"": ""launch"",
""preLaunchTask"": ""build"",
""cwd"": ""/project/{projectRelativeDir}"",
""program"": ""/usr/bin/dotnet"",
""args"": [
""--additionalprobingpath"",
""/nuget/packages"",
""{outputPath}/{outputFileName}"",
""-t=monitorAndAnalyze""]
}}
]
}}";
var tempFileName = Path.GetTempFileName();
File.WriteAllText(tempFileName, launchOptionsContent);
Console.WriteLine("Starging debug with options:");
Console.WriteLine(launchOptionsContent);
dte.ExecuteCommand("DebugAdapterHost.Launch", $"/LaunchJson:{tempFileName}");
//File.Delete(tempFileName); You can try this approach. |
Probably (when I will have enough time) I will inject this toolset into he pythonnet project. |
This helps for managed C# code debugging. |
@dmitriyse That's great, thanks 👍 |
FYI I've also had success debugging remotely by just attaching from Visual Studio: https://blogs.msdn.microsoft.com/devops/2017/01/26/debugging-net-core-on-unix-over-ssh/ |
@djoyce82 @dmitriyse I got debugging using VSCode working in Linux - now trying to establish what is going wrong with the basic functionality. What is the code that usually prevents |
Closed in favour of #984. |
Environment
Using the code in PR #612, I get the following errors trying some basic tests:
The text was updated successfully, but these errors were encountered: