private void RefreshCommandLine() { CommandLineBuilder commandLine = new CommandLineBuilder(); switch (StartAction) { case StartAction.Class: var projectConfigs = ParentPropertyPage.Configurations; JavaProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (JavaProjectConfig)projectConfigs[0] : null; string javaPath = projectConfig != null?projectConfig.FindJavaBinary("java.exe", true) : null; commandLine.AppendFileNameIfNotNull(javaPath); string agentSwitch; if (DebugAgent == DebugAgent.Jdwp) { agentSwitch = "-Xrunjdwp:transport=dt_socket,server=y,address=6777"; } else { agentSwitch = "-agentpath:{AgentPath}"; } commandLine.AppendSwitch(agentSwitch); if (!string.IsNullOrEmpty(AgentArguments)) { commandLine.AppendTextUnquoted("=" + AgentArguments); } if (!string.IsNullOrEmpty(VirtualMachineArguments)) { commandLine.AppendTextUnquoted(" " + VirtualMachineArguments); } if (!string.IsNullOrEmpty(StartClass)) { commandLine.AppendFileNameIfNotNull(StartClass); } break; case StartAction.Program: case StartAction.Browser: throw new NotSupportedException(); case StartAction.Unknown: default: break; } if (!string.IsNullOrEmpty(ExtraArguments)) { commandLine.AppendTextUnquoted(" " + ExtraArguments); } txtCommandLine.Text = commandLine.ToString(); }
private void RefreshCommandLine() { CommandLineBuilder commandLine = new CommandLineBuilder(); switch (StartAction) { case StartAction.Class: var projectConfigs = ParentPropertyPage.Configurations; DartProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (DartProjectConfig)projectConfigs[0] : null; string javaPath = "javac.exe"; commandLine.AppendFileNameIfNotNull(javaPath); commandLine.AppendSwitch("-agentpath:{AgentPath}"); if (!string.IsNullOrEmpty(AgentArguments)) { commandLine.AppendTextUnquoted("=" + AgentArguments); } if (!string.IsNullOrEmpty(VirtualMachineArguments)) { commandLine.AppendTextUnquoted(" " + VirtualMachineArguments); } if (!string.IsNullOrEmpty(StartClass)) { commandLine.AppendFileNameIfNotNull(StartClass); } break; case StartAction.Program: case StartAction.Browser: throw new NotSupportedException(); case StartAction.Unknown: default: break; } if (!string.IsNullOrEmpty(ExtraArguments)) { commandLine.AppendTextUnquoted(" " + ExtraArguments); } txtCommandLine.Text = commandLine.ToString(); }
internal void RefreshCommandLine() { CommandLineBuilder commandLine = new CommandLineBuilder(); string javacPath = null; if (ParentPropertyPage.ProjectManager != null && ParentPropertyPage.ProjectManager.SharedBuildOptions.General != null) javacPath = ParentPropertyPage.ProjectManager.SharedBuildOptions.General.JavacPath; if (javacPath == null) javacPath = ParentPropertyPage.GetConfigProperty(JavaConfigConstants.JavacPath, _PersistStorageType.PST_PROJECT_FILE); string fullucc = javacPath; try { if (!string.IsNullOrEmpty(fullucc) && !Path.IsPathRooted(fullucc) && ParentPropertyPage.ProjectManager != null) { fullucc = Path.Combine(ParentPropertyPage.ProjectManager.ProjectFolder, javacPath); } } catch (ArgumentException) { fullucc = javacPath; } if (string.IsNullOrEmpty(fullucc)) { var projectConfigs = ParentPropertyPage.Configurations; JavaProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (JavaProjectConfig)projectConfigs[0] : null; fullucc = projectConfig != null ? projectConfig.FindJavaBinary("javac.exe", true) : null; } commandLine.AppendFileNameIfNotNull(fullucc); commandLine.AppendSwitchIfNotNullOrEmpty("-encoding ", Encoding); switch (DebuggingInformation) { case DebuggingInformation.All: commandLine.AppendSwitch("-g"); break; case DebuggingInformation.Specific: if (!string.IsNullOrEmpty(SpecificDebuggingInformation)) commandLine.AppendSwitchIfNotNull("-g:", SpecificDebuggingInformation); else commandLine.AppendSwitch("-g:none"); break; case DebuggingInformation.None: commandLine.AppendSwitch("-g:none"); break; case DebuggingInformation.Default: default: break; } if (!string.IsNullOrEmpty(SourceRelease) && !string.Equals(SourceRelease, "Default", StringComparison.OrdinalIgnoreCase)) commandLine.AppendSwitchIfNotNull("-source ", SourceRelease); if (!string.IsNullOrEmpty(TargetRelease) && !string.Equals(TargetRelease, "Default", StringComparison.OrdinalIgnoreCase)) commandLine.AppendSwitchIfNotNull("-target ", TargetRelease); commandLine.AppendSwitchIfNotNullOrEmpty("-d ", OutputPath); if (!ShowWarnings) { commandLine.AppendSwitch("-nowarn"); } else if (ShowAllWarnings) { commandLine.AppendSwitch("-Xlint"); commandLine.AppendSwitch("-deprecation"); } if (!string.IsNullOrEmpty(ExtraArguments)) commandLine.AppendTextUnquoted(" " + ExtraArguments); txtBuildCommandLine.Text = commandLine.ToString(); }
internal void RefreshCommandLine() { CommandLineBuilder commandLine = new CommandLineBuilder(); string javacPath = null; if (ParentPropertyPage.ProjectManager != null && ParentPropertyPage.ProjectManager.SharedBuildOptions.General != null) { javacPath = ParentPropertyPage.ProjectManager.SharedBuildOptions.General.JavacPath; } if (javacPath == null) { javacPath = ParentPropertyPage.GetConfigProperty(DartConfigConstants.JavacPath, _PersistStorageType.PST_PROJECT_FILE); } string fullucc = javacPath; try { if (!string.IsNullOrEmpty(fullucc) && !Path.IsPathRooted(fullucc) && ParentPropertyPage.ProjectManager != null) { fullucc = Path.Combine(ParentPropertyPage.ProjectManager.ProjectFolder, javacPath); } } catch (ArgumentException) { fullucc = javacPath; } if (string.IsNullOrEmpty(fullucc)) { var projectConfigs = ParentPropertyPage.Configurations; DartProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (DartProjectConfig)projectConfigs[0] : null; fullucc = "javac.exe"; } commandLine.AppendFileNameIfNotNull(fullucc); commandLine.AppendSwitchIfNotNullOrEmpty("-encoding ", Encoding); switch (DebuggingInformation) { case DebuggingInformation.All: commandLine.AppendSwitch("-g"); break; case DebuggingInformation.Specific: if (!string.IsNullOrEmpty(SpecificDebuggingInformation)) { commandLine.AppendSwitchIfNotNull("-g:", SpecificDebuggingInformation); } else { commandLine.AppendSwitch("-g:none"); } break; case DebuggingInformation.None: commandLine.AppendSwitch("-g:none"); break; case DebuggingInformation.Default: default: break; } if (!string.IsNullOrEmpty(SourceRelease) && !string.Equals(SourceRelease, "Default", StringComparison.OrdinalIgnoreCase)) { commandLine.AppendSwitchIfNotNull("-source ", SourceRelease); } if (!string.IsNullOrEmpty(TargetRelease) && !string.Equals(TargetRelease, "Default", StringComparison.OrdinalIgnoreCase)) { commandLine.AppendSwitchIfNotNull("-target ", TargetRelease); } commandLine.AppendSwitchIfNotNullOrEmpty("-d ", OutputPath); if (!ShowWarnings) { commandLine.AppendSwitch("-nowarn"); } else if (ShowAllWarnings) { commandLine.AppendSwitch("-Xlint"); commandLine.AppendSwitch("-deprecation"); } if (!string.IsNullOrEmpty(ExtraArguments)) { commandLine.AppendTextUnquoted(" " + ExtraArguments); } txtBuildCommandLine.Text = commandLine.ToString(); }
public override int DebugLaunch(uint grfLaunch) { DebugTargetInfo info = new DebugTargetInfo(); CommandLineBuilder commandLine = new CommandLineBuilder(); bool x64 = Platform.EndsWith("X64", StringComparison.OrdinalIgnoreCase) || (Platform.EndsWith("Any CPU", StringComparison.OrdinalIgnoreCase) && Environment.Is64BitOperatingSystem); string agentBaseFileName = "Tvl.Java.DebugHostWrapper"; if (x64) { agentBaseFileName += "X64"; } bool useDevelopmentEnvironment = (grfLaunch & (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_NoDebug) == 0; string debugAgentName = GetConfigurationProperty(JavaConfigConstants.DebugAgent, _PersistStorageType.PST_USER_FILE, false); bool useJdwp = string.Equals(DebugAgent.Jdwp.ToString(), debugAgentName, StringComparison.OrdinalIgnoreCase); if (useJdwp) { commandLine.AppendSwitch("-Xdebug"); string serverValue = useDevelopmentEnvironment ? "y" : "n"; commandLine.AppendSwitch("-Xrunjdwp:transport=dt_socket,server=" + serverValue + ",address=6777"); } else { string agentFolder = Path.GetDirectoryName(typeof(JavaProjectConfig).Assembly.Location); string agentFileName = agentBaseFileName + ".dll"; string agentPath = Path.GetFullPath(Path.Combine(agentFolder, agentFileName)); commandLine.AppendSwitchIfNotNull("-agentpath:", agentPath); string agentArguments = GetConfigurationProperty(JavaConfigConstants.DebugAgentArguments, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(agentArguments)) { commandLine.AppendTextUnquoted("=" + agentArguments); } } switch (GetConfigurationProperty(JavaConfigConstants.DebugStartAction, _PersistStorageType.PST_USER_FILE, false)) { case "Class": string jvmArguments = GetConfigurationProperty(JavaConfigConstants.DebugJvmArguments, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(jvmArguments)) { commandLine.AppendTextUnquoted(" " + jvmArguments); } commandLine.AppendSwitch("-cp"); commandLine.AppendFileNameIfNotNull(GetConfigurationProperty("TargetPath", _PersistStorageType.PST_PROJECT_FILE, false)); string startupObject = GetConfigurationProperty(JavaConfigConstants.DebugStartClass, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(startupObject)) { commandLine.AppendFileNameIfNotNull(startupObject); } break; default: throw new NotImplementedException("This preview version of the Java debugger only supports starting execution in a named class; the class name may be configured in the project properties on the Debug tab."); } string debugArgs = GetConfigurationProperty(JavaConfigConstants.DebugExtraArgs, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(debugArgs)) { commandLine.AppendTextUnquoted(" " + debugArgs); } string workingDirectory = GetConfigurationProperty(JavaConfigConstants.DebugWorkingDirectory, _PersistStorageType.PST_USER_FILE, false); if (string.IsNullOrEmpty(workingDirectory)) { workingDirectory = GetConfigurationProperty(JavaConfigConstants.OutputPath, _PersistStorageType.PST_PROJECT_FILE, false); } if (!Path.IsPathRooted(workingDirectory)) { workingDirectory = Path.GetFullPath(Path.Combine(this.ProjectManager.ProjectFolder, workingDirectory)); } // Pass the project references via the CLASSPATH environment variable List <string> classPathEntries = new List <string>(); IReferenceContainer referenceContainer = ProjectManager.GetReferenceContainer(); IList <ReferenceNode> references = referenceContainer.EnumReferences(); foreach (var referenceNode in references) { JarReferenceNode jarReferenceNode = referenceNode as JarReferenceNode; if (jarReferenceNode != null) { if (File.Exists(jarReferenceNode.InstalledFilePath) || Directory.Exists(jarReferenceNode.InstalledFilePath)) { classPathEntries.Add(jarReferenceNode.InstalledFilePath); } } } if (classPathEntries != null) { string classPath = string.Join(";", classPathEntries); info.Environment.Add("CLASSPATH", classPath); } //List<string> arguments = new List<string>(); //arguments.Add(@"-agentpath:C:\dev\SimpleC\Tvl.Java.DebugHost\bin\Debug\Tvl.Java.DebugHostWrapper.dll"); ////arguments.Add(@"-verbose:jni"); ////arguments.Add(@"-cp"); ////arguments.Add(@"C:\dev\JavaProjectTest\JavaProject\out\Debug"); //arguments.Add("tvl.school.ee382v.a3.problem1.program1"); ////arguments.Add(GetConfigurationProperty("OutputPath", true)); ////arguments.Add(GetConfigurationProperty(JavaConfigConstants.DebugStartClass, false, _PersistStorageType.PST_USER_FILE)); ////arguments.Add(GetConfigurationProperty(JavaConfigConstants.DebugExtraArgs, false, _PersistStorageType.PST_USER_FILE)); //info.Arguments = string.Join(" ", arguments); info.Arguments = commandLine.ToString(); info.Executable = FindJavaBinary("java.exe", useDevelopmentEnvironment); //info.CurrentDirectory = GetConfigurationProperty("WorkingDirectory", false, _PersistStorageType.PST_USER_FILE); info.CurrentDirectory = workingDirectory; info.SendToOutputWindow = false; info.DebugEngines = new Guid[] { typeof(JavaDebugEngine).GUID, //VSConstants.DebugEnginesGuids.ManagedOnly_guid, //VSConstants.DebugEnginesGuids.NativeOnly_guid, }; Guid localPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); info.PortSupplier = localPortSupplier; info.LaunchOperation = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; info.LaunchFlags = (__VSDBGLAUNCHFLAGS)grfLaunch | (__VSDBGLAUNCHFLAGS)__VSDBGLAUNCHFLAGS2.DBGLAUNCH_MergeEnv; var debugger = (IVsDebugger2)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)); int result = debugger.LaunchDebugTargets(info); if (result != VSConstants.S_OK) { IVsUIShell uishell = (IVsUIShell)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsUIShell)); string message = uishell.GetErrorInfo(); } return(result); }
private void RefreshCommandLine() { CommandLineBuilder commandLine = new CommandLineBuilder(); switch (StartAction) { case StartAction.Class: var projectConfigs = ParentPropertyPage.Configurations; JavaProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (JavaProjectConfig)projectConfigs[0] : null; string javaPath = projectConfig != null ? projectConfig.FindJavaBinary("java.exe", true) : null; commandLine.AppendFileNameIfNotNull(javaPath); string agentSwitch; if (DebugAgent == DebugAgent.Jdwp) { agentSwitch = "-Xrunjdwp:transport=dt_socket,server=y,address=6777"; } else { agentSwitch = "-agentpath:{AgentPath}"; } commandLine.AppendSwitch(agentSwitch); if (!string.IsNullOrEmpty(AgentArguments)) commandLine.AppendTextUnquoted("=" + AgentArguments); if (!string.IsNullOrEmpty(VirtualMachineArguments)) commandLine.AppendTextUnquoted(" " + VirtualMachineArguments); if (!string.IsNullOrEmpty(StartClass)) commandLine.AppendFileNameIfNotNull(StartClass); break; case StartAction.Program: case StartAction.Browser: throw new NotSupportedException(); case StartAction.Unknown: default: break; } if (!string.IsNullOrEmpty(ExtraArguments)) commandLine.AppendTextUnquoted(" " + ExtraArguments); txtCommandLine.Text = commandLine.ToString(); }
public override int DebugLaunch(uint grfLaunch) { DebugTargetInfo info = new DebugTargetInfo(); CommandLineBuilder commandLine = new CommandLineBuilder(); bool x64 = Platform.EndsWith("X64", StringComparison.OrdinalIgnoreCase) || (Platform.EndsWith("Any CPU", StringComparison.OrdinalIgnoreCase) && Environment.Is64BitOperatingSystem); string agentBaseFileName = "Tvl.Java.DebugHostWrapper"; if (x64) agentBaseFileName += "X64"; bool useDevelopmentEnvironment = (grfLaunch & (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_NoDebug) == 0; string debugAgentName = GetConfigurationProperty(JavaConfigConstants.DebugAgent, _PersistStorageType.PST_USER_FILE, false); bool useJdwp = string.Equals(DebugAgent.Jdwp.ToString(), debugAgentName, StringComparison.OrdinalIgnoreCase); if (useJdwp) { commandLine.AppendSwitch("-Xdebug"); string serverValue = useDevelopmentEnvironment ? "y" : "n"; commandLine.AppendSwitch("-Xrunjdwp:transport=dt_socket,server=" + serverValue + ",address=6777"); } else { string agentFolder = Path.GetDirectoryName(typeof(JavaProjectConfig).Assembly.Location); string agentFileName = agentBaseFileName + ".dll"; string agentPath = Path.GetFullPath(Path.Combine(agentFolder, agentFileName)); commandLine.AppendSwitchIfNotNull("-agentpath:", agentPath); string agentArguments = GetConfigurationProperty(JavaConfigConstants.DebugAgentArguments, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(agentArguments)) commandLine.AppendTextUnquoted("=" + agentArguments); } switch (GetConfigurationProperty(JavaConfigConstants.DebugStartAction, _PersistStorageType.PST_USER_FILE, false)) { case "Class": string jvmArguments = GetConfigurationProperty(JavaConfigConstants.DebugJvmArguments, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(jvmArguments)) commandLine.AppendTextUnquoted(" " + jvmArguments); commandLine.AppendSwitch("-cp"); commandLine.AppendFileNameIfNotNull(GetConfigurationProperty("TargetPath", _PersistStorageType.PST_PROJECT_FILE, false)); string startupObject = GetConfigurationProperty(JavaConfigConstants.DebugStartClass, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(startupObject)) commandLine.AppendFileNameIfNotNull(startupObject); break; default: throw new NotImplementedException("This preview version of the Java debugger only supports starting execution in a named class; the class name may be configured in the project properties on the Debug tab."); } string debugArgs = GetConfigurationProperty(JavaConfigConstants.DebugExtraArgs, _PersistStorageType.PST_USER_FILE, false); if (!string.IsNullOrEmpty(debugArgs)) commandLine.AppendTextUnquoted(" " + debugArgs); string workingDirectory = GetConfigurationProperty(JavaConfigConstants.DebugWorkingDirectory, _PersistStorageType.PST_USER_FILE, false); if (string.IsNullOrEmpty(workingDirectory)) workingDirectory = GetConfigurationProperty(JavaConfigConstants.OutputPath, _PersistStorageType.PST_PROJECT_FILE, false); if (!Path.IsPathRooted(workingDirectory)) { workingDirectory = Path.GetFullPath(Path.Combine(this.ProjectManager.ProjectFolder, workingDirectory)); } // Pass the project references via the CLASSPATH environment variable List<string> classPathEntries = new List<string>(); IReferenceContainer referenceContainer = ProjectManager.GetReferenceContainer(); IList<ReferenceNode> references = referenceContainer.EnumReferences(); foreach (var referenceNode in references) { JarReferenceNode jarReferenceNode = referenceNode as JarReferenceNode; if (jarReferenceNode != null) { if (File.Exists(jarReferenceNode.InstalledFilePath) || Directory.Exists(jarReferenceNode.InstalledFilePath)) classPathEntries.Add(jarReferenceNode.InstalledFilePath); } } if (classPathEntries != null) { string classPath = string.Join(";", classPathEntries); info.Environment.Add("CLASSPATH", classPath); } //List<string> arguments = new List<string>(); //arguments.Add(@"-agentpath:C:\dev\SimpleC\Tvl.Java.DebugHost\bin\Debug\Tvl.Java.DebugHostWrapper.dll"); ////arguments.Add(@"-verbose:jni"); ////arguments.Add(@"-cp"); ////arguments.Add(@"C:\dev\JavaProjectTest\JavaProject\out\Debug"); //arguments.Add("tvl.school.ee382v.a3.problem1.program1"); ////arguments.Add(GetConfigurationProperty("OutputPath", true)); ////arguments.Add(GetConfigurationProperty(JavaConfigConstants.DebugStartClass, false, _PersistStorageType.PST_USER_FILE)); ////arguments.Add(GetConfigurationProperty(JavaConfigConstants.DebugExtraArgs, false, _PersistStorageType.PST_USER_FILE)); //info.Arguments = string.Join(" ", arguments); info.Arguments = commandLine.ToString(); info.Executable = FindJavaBinary("java.exe", useDevelopmentEnvironment); //info.CurrentDirectory = GetConfigurationProperty("WorkingDirectory", false, _PersistStorageType.PST_USER_FILE); info.CurrentDirectory = workingDirectory; info.SendToOutputWindow = false; info.DebugEngines = new Guid[] { typeof(JavaDebugEngine).GUID, //VSConstants.DebugEnginesGuids.ManagedOnly_guid, //VSConstants.DebugEnginesGuids.NativeOnly_guid, }; Guid localPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); info.PortSupplier = localPortSupplier; info.LaunchOperation = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; info.LaunchFlags = (__VSDBGLAUNCHFLAGS)grfLaunch | (__VSDBGLAUNCHFLAGS)__VSDBGLAUNCHFLAGS2.DBGLAUNCH_MergeEnv; var debugger = (IVsDebugger2)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)); int result = debugger.LaunchDebugTargets(info); if (result != VSConstants.S_OK) { IVsUIShell uishell = (IVsUIShell)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsUIShell)); string message = uishell.GetErrorInfo(); } return result; }
private void RefreshCommandLine() { CommandLineBuilder commandLine = new CommandLineBuilder(); switch (StartAction) { case StartAction.Class: var projectConfigs = ParentPropertyPage.Configurations; DartProjectConfig projectConfig = projectConfigs != null && projectConfigs.Count == 1 ? (DartProjectConfig)projectConfigs[0] : null; string javaPath = "javac.exe"; commandLine.AppendFileNameIfNotNull(javaPath); commandLine.AppendSwitch("-agentpath:{AgentPath}"); if (!string.IsNullOrEmpty(AgentArguments)) commandLine.AppendTextUnquoted("=" + AgentArguments); if (!string.IsNullOrEmpty(VirtualMachineArguments)) commandLine.AppendTextUnquoted(" " + VirtualMachineArguments); if (!string.IsNullOrEmpty(StartClass)) commandLine.AppendFileNameIfNotNull(StartClass); break; case StartAction.Program: case StartAction.Browser: throw new NotSupportedException(); case StartAction.Unknown: default: break; } if (!string.IsNullOrEmpty(ExtraArguments)) commandLine.AppendTextUnquoted(" " + ExtraArguments); txtCommandLine.Text = commandLine.ToString(); }