public int DebugLaunch(uint flags) { VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) { return(hr); } flags |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1]; int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); this.CopyDebugTargetInfo(ref targets[0], ref appPackageDebugTarget[0], flags); IVsAppContainerBootstrapperResult result = this.BootstrapForDebuggingSync(targets[0].bstrRemoteMachine); appPackageDebugTarget[0].bstrRemoteMachine = result.Address; // Pass the debug launch targets to the debugger IVsDebugger4 debugger4 = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger)); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1]; debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results); return(VSConstants.S_OK); }
private void OnBootstrapEnd(string remoteMachine, string projectUniqueName, IVsAppContainerBootstrapperResult result) { if (result == null || !result.Succeeded) { this.NotifyEndDeploy(0); return; } IVsDebuggerDeploy deploy = (IVsDebuggerDeploy)this.serviceProvider.GetService(typeof(SVsShellDebugger)); int hr = deploy.ConnectToTargetComputer(result.Address, VsDebugRemoteAuthenticationMode.VSAUTHMODE_None, out this.debuggerDeployConnection); if (ErrorHandler.Failed(hr)) { this.NotifyEndDeploy(0); return; } IVsAppContainerProjectDeploy2 deployHelper = (IVsAppContainerProjectDeploy2)this.serviceProvider.GetService(typeof(SVsAppContainerProjectDeploy)); uint deployFlags = (uint)(_AppContainerDeployOptions.ACDO_NetworkLoopbackEnable | _AppContainerDeployOptions.ACDO_SetNetworkLoopback); if (!PrepareNodeStartupInfo(GetProjectUniqueName())) { this.NotifyEndDeploy(0); return; } IVsAppContainerProjectDeployOperation localAppContainerDeployOperation = deployHelper.StartRemoteDeployAsync(deployFlags, this.debuggerDeployConnection, remoteMachine, this.GetRecipeFile(), this.GetProjectUniqueName(), this); lock (syncObject) { this.appContainerDeployOperation = localAppContainerDeployOperation; } }
private void OnBootstrapEnd(string projectUniqueName, IVsAppContainerBootstrapperResult result) { if (result == null || !result.Succeeded) { this.NotifyEndDeploy(0); return; } IVsDebuggerDeploy deploy = (IVsDebuggerDeploy)Package.GetGlobalService(typeof(SVsShellDebugger)); IVsDebuggerDeployConnection deployConnection; int hr = deploy.ConnectToTargetComputer(result.Address, VsDebugRemoteAuthenticationMode.VSAUTHMODE_None, out deployConnection); lock (syncObject) { connection = deployConnection; } if (ErrorHandler.Failed(hr)) { NotifyEndDeploy(0); return; } string recipeFile = GetRecipeFile(); IVsAppContainerProjectDeploy deployHelper = (IVsAppContainerProjectDeploy)Package.GetGlobalService(typeof(SVsAppContainerProjectDeploy)); uint deployFlags = (uint)(_AppContainerDeployOptions.ACDO_NetworkLoopbackEnable | _AppContainerDeployOptions.ACDO_SetNetworkLoopback); IVsAppContainerProjectDeployOperation localAppContainerDeployOperation = deployHelper.StartRemoteDeployAsync(deployFlags, connection, recipeFile, projectUniqueName, this); lock (syncObject) { this.deployOp = localAppContainerDeployOperation; } }
private void OnBootstrapEnd(string remoteMachine, IVsAppContainerBootstrapperResult result) { if (result == null || !result.Succeeded) { this.NotifyEndDeploy(0); return; } IVsDebuggerDeploy deploy = (IVsDebuggerDeploy)this.serviceProvider.GetService(typeof(SVsShellDebugger)); int hr = deploy.ConnectToTargetComputer(result.Address, VsDebugRemoteAuthenticationMode.VSAUTHMODE_None, out this.debuggerDeployConnection); if (ErrorHandler.Failed(hr)) { this.NotifyEndDeploy(0); return; } IVsAppContainerProjectDeploy2 deployHelper = (IVsAppContainerProjectDeploy2)this.serviceProvider.GetService(typeof(SVsAppContainerProjectDeploy)); uint deployFlags = (uint)(_AppContainerDeployOptions.ACDO_NetworkLoopbackEnable | _AppContainerDeployOptions.ACDO_SetNetworkLoopback); if (!PrepareNodeStartupInfo(GetProjectUniqueName())) { this.NotifyEndDeploy(0); return; } IVsAppContainerProjectDeployOperation localAppContainerDeployOperation = deployHelper.StartRemoteDeployAsync(deployFlags, this.debuggerDeployConnection, remoteMachine, this.GetRecipeFile(), this.GetProjectUniqueName(), this); lock (syncObject) { this.appContainerDeployOperation = localAppContainerDeployOperation; } }
int IVsDeployableProjectCfg.StartDeploy(IVsOutputWindowPane pIVsOutputWindowPane, uint dwOptions) { outputWindow = pIVsOutputWindowPane; if (!NotifyBeginDeploy()) { return(VSConstants.E_ABORT); } IVsAppContainerBootstrapper4 bootstrapper = (IVsAppContainerBootstrapper4)ServiceProvider.GlobalProvider.GetService(typeof(SVsAppContainerProjectDeploy)); VsBootstrapperPackageInfo[] packagesToDeployList = new VsBootstrapperPackageInfo[] { new VsBootstrapperPackageInfo { PackageName = "D8B19935-BDBF-4D5B-9619-A6693AFD4554" }, // ScriptMsVsMon new VsBootstrapperPackageInfo { PackageName = "EB22551A-7F66-465F-B53F-E5ABA0C0574E" }, // NativeMsVsMon new VsBootstrapperPackageInfo { PackageName = "62B807E2-6539-46FB-8D67-A73DC9499940" } // ManagedMsVsMon }; VsBootstrapperPackageInfo[] optionalPackagesToDeploy = new VsBootstrapperPackageInfo[] { new VsBootstrapperPackageInfo { PackageName = "FEC73B34-86DE-4EA8-BFF4-3600A0443E9C" }, // NativeMsVsMonDependency new VsBootstrapperPackageInfo { PackageName = "B968CC6A-D2C8-4197-88E3-11662042C291" }, // XamlUIDebugging new VsBootstrapperPackageInfo { PackageName = "8CDEABEF-33E1-4A23-A13F-94A49FF36E84" } // XamlUIDebuggingDependency }; BootstrapMode bootStrapMode = BootstrapMode.UniversalBootstrapMode; VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) { NotifyEndDeploy(0); return(hr); } string projectUniqueName = GetProjectUniqueName(); IVsTask localAppContainerBootstrapperOperation = bootstrapper.BootstrapAsync(projectUniqueName, targets[0].bstrRemoteMachine, bootStrapMode, packagesToDeployList.Length, packagesToDeployList, optionalPackagesToDeploy.Length, optionalPackagesToDeploy, this); lock (syncObject) { this.appContainerBootstrapperOperation = localAppContainerBootstrapperOperation; } ThreadHelper.JoinableTaskFactory.RunAsync(async() => { IVsAppContainerBootstrapperResult result = null; try { object taskResult = await localAppContainerBootstrapperOperation; result = (IVsAppContainerBootstrapperResult)taskResult; } finally { this.OnBootstrapEnd(targets[0].bstrRemoteMachine, projectUniqueName, result); } }); return(VSConstants.S_OK); }
public int DebugLaunch(uint grfLaunch) { if (PythonConfig.IsAppxPackageableProject()) { VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) { return(hr); } VsDebugTargetInfo4[] appPackageDebugTarget = new VsDebugTargetInfo4[1]; int targetLength = (int)Marshal.SizeOf(typeof(VsDebugTargetInfo4)); // Setup the app-specific parameters appPackageDebugTarget[0].AppPackageLaunchInfo.AppUserModelID = DeployAppUserModelID; appPackageDebugTarget[0].AppPackageLaunchInfo.PackageMoniker = DeployPackageMoniker; appPackageDebugTarget[0].AppPackageLaunchInfo.AppPlatform = VsAppPackagePlatform.APPPLAT_WindowsAppx; // Check if this project contains a startup task and set launch flag appropriately IVsBuildPropertyStorage bps = (IVsBuildPropertyStorage)this.PythonConfig; string canonicalName; string containsStartupTaskValue = null; bool containsStartupTask = false; get_CanonicalName(out canonicalName); bps.GetPropertyValue("ContainsStartupTask", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out containsStartupTaskValue); if (containsStartupTaskValue != null && bool.TryParse(containsStartupTaskValue, out containsStartupTask) && containsStartupTask) { grfLaunch |= (uint)__VSDBGLAUNCHFLAGS140.DBGLAUNCH_ContainsStartupTask; } appPackageDebugTarget[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AppPackageDebug; appPackageDebugTarget[0].LaunchFlags = grfLaunch; appPackageDebugTarget[0].bstrRemoteMachine = targets[0].bstrRemoteMachine; appPackageDebugTarget[0].bstrExe = targets[0].bstrExe; appPackageDebugTarget[0].bstrArg = targets[0].bstrArg; appPackageDebugTarget[0].bstrCurDir = targets[0].bstrCurDir; appPackageDebugTarget[0].bstrEnv = targets[0].bstrEnv; appPackageDebugTarget[0].dwProcessId = targets[0].dwProcessId; appPackageDebugTarget[0].pStartupInfo = IntPtr.Zero; appPackageDebugTarget[0].guidLaunchDebugEngine = targets[0].guidLaunchDebugEngine; appPackageDebugTarget[0].dwDebugEngineCount = targets[0].dwDebugEngineCount; appPackageDebugTarget[0].pDebugEngines = targets[0].pDebugEngines; appPackageDebugTarget[0].guidPortSupplier = targets[0].guidPortSupplier; appPackageDebugTarget[0].bstrPortName = targets[0].bstrPortName; appPackageDebugTarget[0].bstrOptions = targets[0].bstrOptions; appPackageDebugTarget[0].fSendToOutputWindow = targets[0].fSendToOutputWindow; appPackageDebugTarget[0].pUnknown = targets[0].pUnknown; appPackageDebugTarget[0].guidProcessLanguage = targets[0].guidProcessLanguage; appPackageDebugTarget[0].project = PythonConfig; // Get remote machine name and port from bootstrapper IVsAppContainerBootstrapperResult bootstrapResult = this.BootstrapForDebuggingSync(targets[0].bstrRemoteMachine); if (bootstrapResult == null || !bootstrapResult.Succeeded) { return(VSConstants.E_FAIL); } appPackageDebugTarget[0].bstrRemoteMachine = bootstrapResult.Address; // Pass the debug launch targets to the debugger IVsDebugger4 debugger4 = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger)); VsDebugTargetProcessInfo[] results = new VsDebugTargetProcessInfo[1]; IVsDebugger debugger = (IVsDebugger)debugger4; // Launch task to monitor to attach to Python remote process var sourceDir = Path.GetFullPath(PythonConfig.GetProjectProperty("ProjectDir")).Trim('\\'); var targetDir = Path.GetFullPath(this.LayoutDir).Trim('\\'); var debugPort = PythonConfig.GetProjectProperty("RemoteDebugPort") ?? DefaultRemoteDebugPort; var debugId = Guid.NewGuid(); var serializer = new JavaScriptSerializer(); var debugCmdJson = serializer.Serialize(new string[] { "visualstudio_py_remote_launcher.py", debugPort.ToString(), debugId.ToString() }); Debugger.PythonRemoteDebugEvents.Instance.RemoteDebugCommandInfo = Encoding.Unicode.GetBytes(debugCmdJson); Debugger.PythonRemoteDebugEvents.Instance.AttachRemoteProcessFunction = () => { return(RemoteProcessAttachAsync( appPackageDebugTarget[0].bstrRemoteMachine, debugId.ToString(), debugPort, sourceDir, targetDir)); }; int result = debugger.AdviseDebugEventCallback(Debugger.PythonRemoteDebugEvents.Instance); if (result == VSConstants.S_OK) { debugger4.LaunchDebugTargets4(1, appPackageDebugTarget, results); } else { Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Failure {0}", result)); } return(result); } else { IVsDebuggableProjectCfg cfg = _pythonCfg as IVsDebuggableProjectCfg; if (cfg != null) { return(cfg.DebugLaunch(grfLaunch)); } return(VSConstants.E_NOTIMPL); } }
public int StartDeploy(IVsOutputWindowPane pIVsOutputWindowPane, uint dwOptions) { outputWindow = pIVsOutputWindowPane; if (!NotifyBeginDeploy()) { return(VSConstants.E_ABORT); } VsDebugTargetInfo2[] targets; int hr = QueryDebugTargets(out targets); if (ErrorHandler.Failed(hr)) { NotifyEndDeploy(0); return(hr); } string projectUniqueName = this.GetProjectUniqueName(); IVsAppContainerBootstrapper4 bootstrapper = (IVsAppContainerBootstrapper4)ServiceProvider.GlobalProvider.GetService(typeof(SVsAppContainerProjectDeploy)); VsBootstrapperPackageInfo[] packagesToDeployList = new VsBootstrapperPackageInfo[] { #if DEV15 new VsBootstrapperPackageInfo { PackageName = "8B426345-3B98-4111-819A-46533C393CE5" }, // NativeMsVsMon new VsBootstrapperPackageInfo { PackageName = "973CA972-0C5F-4F19-B436-814CF773A102" } // ManagedMsVsMon #elif DEV14 new VsBootstrapperPackageInfo { PackageName = "EB22551A-7F66-465F-B53F-E5ABA0C0574E" }, // NativeMsVsMon new VsBootstrapperPackageInfo { PackageName = "62B807E2-6539-46FB-8D67-A73DC9499940" } // ManagedMsVsMon #else #error Unsupported version of Visual Studio #endif }; VsBootstrapperPackageInfo[] optionalPackagesToDeploy = new VsBootstrapperPackageInfo[] { #if DEV15 new VsBootstrapperPackageInfo { PackageName = "92063DB3-36E3-434E-840C-DEE8DA2AD4B7" }, // NativeMsVsMonDependency #elif DEV14 new VsBootstrapperPackageInfo { PackageName = "FEC73B34-86DE-4EA8-BFF4-3600A0443E9C" }, // NativeMsVsMonDependency #else #error Unsupported version of Visual Studio #endif new VsBootstrapperPackageInfo { PackageName = "B968CC6A-D2C8-4197-88E3-11662042C291" }, // XamlUIDebugging new VsBootstrapperPackageInfo { PackageName = "8CDEABEF-33E1-4A23-A13F-94A49FF36E84" } // XamlUIDebuggingDependency }; BootstrapMode bootStrapMode = BootstrapMode.UniversalBootstrapMode; IVsTask localAppContainerBootstrapperOperation = bootstrapper.BootstrapAsync(projectUniqueName, targets[0].bstrRemoteMachine, bootStrapMode, packagesToDeployList.Length, packagesToDeployList, optionalPackagesToDeploy.Length, optionalPackagesToDeploy, this); lock (syncObject) { this.appContainerBootstrapperOperation = localAppContainerBootstrapperOperation; } ThreadHelper.JoinableTaskFactory.RunAsync(async() => { IVsAppContainerBootstrapperResult result = null; try { object taskResult = await localAppContainerBootstrapperOperation; result = (IVsAppContainerBootstrapperResult)taskResult; } finally { this.OnBootstrapEnd(projectUniqueName, result); } }); return(VSConstants.S_OK); }