/// <summary> /// Called by the vs shell to start debugging (managed or unmanaged). /// Override this method to support other debug engines. /// </summary> /// <param name="grfLaunch">A flag that determines the conditions under which to start the debugger. For valid grfLaunch values, see __VSDBGLAUNCHFLAGS</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code</returns> public override int DebugLaunch(uint grfLaunch) { CCITracing.TraceCall(); try { VsDebugTargetInfo info = new VsDebugTargetInfo(); info.cbSize = (uint)Marshal.SizeOf(info); info.dlo = Microsoft.VisualStudio.Shell.Interop.DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; // On first call, reset the cache, following calls will use the cached values string property = GetConfigurationProperty("StartProgram", true); if (string.IsNullOrEmpty(property)) { info.bstrExe = ProjectMgr.GetOutputAssembly(this.ConfigName); } else { info.bstrExe = property; } property = GetConfigurationProperty("WorkingDirectory", false); if (string.IsNullOrEmpty(property)) { info.bstrCurDir = Path.GetDirectoryName(info.bstrExe); } else { if (Path.IsPathRooted(property)) { info.bstrCurDir = property; } else { var path = Path.Combine(ProjectMgr.BaseURI.AbsoluteUrl, property); if (Directory.Exists(path)) { info.bstrCurDir = path; } else { info.bstrCurDir = property; } } } property = GetConfigurationProperty("CmdArgs", false); if (!string.IsNullOrEmpty(property)) { info.bstrArg = property; } property = GetConfigurationProperty("RemoteDebugMachine", false); if (property != null && property.Length > 0) { info.bstrRemoteMachine = property; } info.fSendStdoutToOutputWindow = 0; property = GetConfigurationProperty("EnableUnmanagedDebugging", false); if (property != null && string.Compare(property, "true", StringComparison.OrdinalIgnoreCase) == 0) { //Set the unmanged debugger //TODO change to vsconstant when it is available in VsConstants (guidNativeOnlyEng was the old name, maybe it has got a new name) info.clsidCustom = new Guid("{3B476D35-A401-11D2-AAD4-00C04F990171}"); } else { //Set the managed debugger info.clsidCustom = VSConstants.CLSID_ComPlusOnlyDebugEngine; } info.grfLaunch = grfLaunch; LaunchDebugger(this.ProjectMgr.Site, info); } catch (Exception e) { var proj = ((NemerleProjectNode)ProjectMgr).ProjectInfo; proj.ShowMessage(e.Message, Nemerle.Completion2.MessageType.Error); return(Marshal.GetHRForException(e)); } return(VSConstants.S_OK); }
public override int DebugLaunch(uint aLaunch) { LogUtility.LogString("Cosmos.VS.Package.VSProjectConfig debugger launching"); try { // Second param is ResetCache. Must be called one time. Dunno why. // Also dunno if this comment is still valid/needed: // On first call, reset the cache, following calls will use the cached values // Think we will change this to a dummy program when we get our debugger working // This is the program that gest launched after build var xDeployment = (DeploymentType)Enum.Parse(typeof(DeploymentType), GetConfigurationProperty(BuildPropertyNames.DeploymentString, true)); var xLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), GetConfigurationProperty(BuildPropertyNames.LaunchString, false)); var xVSDebugPort = GetConfigurationProperty(BuildPropertyNames.VisualStudioDebugPortString, false); string xOutputAsm = ProjectMgr.GetOutputAssembly(ConfigName); string xOutputPath = Path.GetDirectoryName(xOutputAsm); string xIsoFile = Path.ChangeExtension(xOutputAsm, ".iso"); string xBinFile = Path.ChangeExtension(xOutputAsm, ".bin"); if (xDeployment == DeploymentType.ISO) { IsoMaker.Generate(xBinFile, xIsoFile); } else if (xDeployment == DeploymentType.USB) { Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.USB.exe"), "\"" + xBinFile + "\""); } else if (xDeployment == DeploymentType.PXE) { string xPxePath = Path.Combine(CosmosPaths.Build, "PXE"); string xPxeIntf = GetConfigurationProperty(BuildPropertyNames.PxeInterfaceString, false); File.Copy(xBinFile, Path.Combine(xPxePath, "Cosmos.bin"), true); Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.exe"), xPxeIntf + " \"" + xPxePath + "\""); } else if (xDeployment == DeploymentType.BinaryImage) { // prepare? } else { throw new Exception("Unknown deployment type."); } if (xLaunch == LaunchType.None && xDeployment == DeploymentType.ISO) { Process.Start(xOutputPath); } else { // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.vsdebugtargetinfo_members.aspx var xInfo = new VsDebugTargetInfo(); xInfo.cbSize = (uint)Marshal.SizeOf(xInfo); xInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; xInfo.fSendStdoutToOutputWindow = 0; // App keeps its stdout xInfo.grfLaunch = aLaunch; // Just pass through for now. xInfo.bstrRemoteMachine = null; // debug locally var xValues = new NameValueCollection(); xValues.Add("ProjectFile", Path.Combine(ProjectMgr.ProjectFolder, ProjectMgr.ProjectFile)); xValues.Add("ISOFile", xIsoFile); xValues.Add("BinFormat", GetConfigurationProperty("BinFormat", false)); foreach (var xName in BuildProperties.PropNames) { xValues.Add(xName, GetConfigurationProperty(xName, false)); } xInfo.bstrExe = NameValueCollectionHelper.DumpToString(xValues); // Select the debugger xInfo.clsidCustom = new Guid("{FA1DA3A6-66FF-4c65-B077-E65F7164EF83}"); // Debug engine identifier. // ??? This identifier doesn't seems to appear anywhere else in souce code. xInfo.clsidPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); VsShellUtilities.LaunchDebugger(ProjectMgr.Site, xInfo); } } catch (Exception ex) { LogUtility.LogException(ex, true); return(Marshal.GetHRForException(ex)); } return(VSConstants.S_OK); }
public override int DebugLaunch(uint aLaunch) { Logger.TraceMethod(MethodBase.GetCurrentMethod()); try { var xDeployment = (DeploymentType)Enum.Parse(typeof(DeploymentType), GetConfigurationProperty(BuildPropertyNames.DeploymentString, true)); var xLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), GetConfigurationProperty(BuildPropertyNames.LaunchString, false)); var xVSDebugPort = GetConfigurationProperty(BuildPropertyNames.VisualStudioDebugPortString, false); string xOutputAsm = ProjectMgr.GetOutputAssembly(ConfigName); string xOutputPath = Path.GetDirectoryName(xOutputAsm); string xIsoFile = Path.ChangeExtension(xOutputAsm, ".iso"); string xBinFile = Path.ChangeExtension(xOutputAsm, ".bin"); if (xDeployment == DeploymentType.ISO) { IsoMaker.Generate(xBinFile, xIsoFile); } else if (xDeployment == DeploymentType.USB) { Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.USB.exe"), "\"" + xBinFile + "\""); } else if (xDeployment == DeploymentType.PXE) { string xPxePath = Path.Combine(CosmosPaths.Build, "PXE"); string xPxeIntf = GetConfigurationProperty(BuildPropertyNames.PxeInterfaceString, false); File.Copy(xBinFile, Path.Combine(xPxePath, "Cosmos.bin"), true); Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.exe"), xPxeIntf + " \"" + xPxePath + "\""); } else if (xDeployment == DeploymentType.BinaryImage) { // prepare? } else { throw new Exception("Unknown deployment type."); } if (xLaunch == LaunchType.None && xDeployment == DeploymentType.ISO) { Process.Start(xOutputPath); } else { // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.vsdebugtargetinfo_members.aspx var xInfo = new VsDebugTargetInfo(); xInfo.cbSize = (uint)Marshal.SizeOf(xInfo); xInfo.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; xInfo.fSendStdoutToOutputWindow = 0; // App keeps its stdout xInfo.grfLaunch = aLaunch; // Just pass through for now. xInfo.bstrRemoteMachine = null; // debug locally var xValues = new Dictionary <string, string>(); xValues.Add("ProjectFile", Path.Combine(ProjectMgr.ProjectFolder, ProjectMgr.ProjectFile)); xValues.Add("ISOFile", xIsoFile); //xValues.Add("BinFormat", GetConfigurationProperty("BinFormat", false)); foreach (var xName in BuildProperties.PropNames) { xValues.Add(xName, GetConfigurationProperty(xName, false)); } xInfo.bstrExe = DictionaryHelper.DumpToString(xValues); // Select the debugger xInfo.clsidCustom = Cosmos.VS.DebugEngine.AD7.Impl.AD7Engine.EngineID; // Debug engine identifier. // ??? This identifier doesn't seems to appear anywhere else in souce code. //xInfo.clsidPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}"); VsShellUtilities.LaunchDebugger(ProjectMgr.Site, xInfo); } } catch (Exception ex) { return(Marshal.GetHRForException(ex)); } return(VSConstants.S_OK); }