public VsProjectFlavorCfg(VsProject project, IVsCfg baseCfg)
        {
            m_vsCfg   = baseCfg;
            m_project = project;

            m_innerIVsDebuggableProjectCfg = m_vsCfg as IVsDebuggableProjectCfg;
            m_IVsBuildPropertyStorage      = m_project as IVsBuildPropertyStorage;

            Debug.Assert(m_innerIVsDebuggableProjectCfg != null);

            m_connectionsDeployStatusCallback = new ConnectionPoint.Connections();

            DeployPropertyPort   = new ProjectBuildProperty("DeployTransport", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, DebugPort.NameFromPortFilter(PortFilter.Emulator));
            DeployPropertyDevice = new ProjectBuildProperty("DeployDevice", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE);

            GenerateStubsFlag      = new ProjectBuildPropertyBool("MF_GenerateStubs", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE);
            GenerateStubsRootName  = new ProjectBuildProperty("MF_GenerateStubsRootName", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, "TARGET");
            GenerateStubsDirectory = new ProjectBuildProperty("MF_GenerateStubsDirectory", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, "DIRECTORY");

            try
            {
                ActivateDebugEngine();
            }
            catch (Exception e)
            {
                VsPackage.MessageCentre.InternalErrorMsg(false, String.Format("Unable to register debug engine: {0}", e.Message));
            }
        }
        public VsProjectFlavorCfg(VsProject project, IVsCfg baseCfg)
        {
            m_vsCfg = baseCfg;
            m_project = project;

            m_innerIVsDebuggableProjectCfg = m_vsCfg as IVsDebuggableProjectCfg;
            m_IVsBuildPropertyStorage = m_project as IVsBuildPropertyStorage;

            Debug.Assert(m_innerIVsDebuggableProjectCfg != null);

            m_connectionsDeployStatusCallback = new ConnectionPoint.Connections();

            DeployPropertyPort = new ProjectBuildProperty("DeployTransport", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, DebugPort.NameFromPortFilter(PortFilter.Emulator));
            DeployPropertyDevice = new ProjectBuildProperty("DeployDevice", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE);

            GenerateStubsFlag = new ProjectBuildPropertyBool("MF_GenerateStubs", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE);
            GenerateStubsRootName = new ProjectBuildProperty("MF_GenerateStubsRootName", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, "TARGET");
            GenerateStubsDirectory = new ProjectBuildProperty("MF_GenerateStubsDirectory", m_IVsBuildPropertyStorage, this, _PersistStorageType.PST_USER_FILE, _PersistStorageType.PST_PROJECT_FILE, "DIRECTORY");

            try
            {
                ActivateDebugEngine();
            }
            catch (Exception e)
            {
                VsPackage.MessageCentre.InternalErrorMsg(false, String.Format("Unable to register debug engine: {0}", e.Message));
            }
        }
Example #3
0
        public int DebugLaunch(uint grfLaunch)
        {
            IVsDebuggableProjectCfg cfg = _pythonCfg as IVsDebuggableProjectCfg;

            if (cfg != null)
            {
                return(cfg.DebugLaunch(grfLaunch));
            }
            return(VSConstants.E_NOTIMPL);
        }
Example #4
0
        public int QueryDebugLaunch(uint grfLaunch, out int pfCanLaunch)
        {
            IVsDebuggableProjectCfg cfg = _pythonCfg as IVsDebuggableProjectCfg;

            if (cfg != null)
            {
                return(cfg.QueryDebugLaunch(grfLaunch, out pfCanLaunch));
            }
            pfCanLaunch = 0;
            return(VSConstants.E_NOTIMPL);
        }
Example #5
0
        public MonoProgramFlavorCfg(MonoProgramProjectFlavor project, IVsCfg baseProjectCfg, IVsProjectFlavorCfg innerProjectFlavorCfg)
        {
            this.project               = project;
            this.baseProjectCfg        = baseProjectCfg;
            this.innerProjectFlavorCfg = innerProjectFlavorCfg;

            projectConfig = (IVsProjectCfg2)baseProjectCfg;
            string configurationName;

            projectConfig.get_CanonicalName(out configurationName);

            cfgs.Add(baseProjectCfg, this);
            cfgsByDteProject[Tuple.Create(GetDTEProject(project), configurationName)] = this;

            var    debugGuid = typeof(IVsDebuggableProjectCfg).GUID;
            IntPtr baseDebugConfigurationPtr;

            innerProjectFlavorCfg.get_CfgType(ref debugGuid, out baseDebugConfigurationPtr);
            baseDebugConfiguration = (IVsDebuggableProjectCfg)Marshal.GetObjectForIUnknown(baseDebugConfigurationPtr);
        }
        public SampSharpFlavorConfig(SampSharpProjectFlavor project, IVsCfg baseProjectConfig,
            IVsProjectFlavorCfg innerProjectFlavorConfig)
        {
            _project = project;
            _baseProjectConfig = baseProjectConfig;
            _innerProjectFlavorConfig = innerProjectFlavorConfig;

            _projectConfig = (IVsProjectCfg2) baseProjectConfig;
            string configurationName;
            _projectConfig.get_CanonicalName(out configurationName);

            Configs.Add(baseProjectConfig, this);

            var debugGuid = typeof(IVsDebuggableProjectCfg).GUID;
            IntPtr baseDebugConfigurationPtr;
            innerProjectFlavorConfig.get_CfgType(ref debugGuid, out baseDebugConfigurationPtr);
            _baseDebugConfiguration = (IVsDebuggableProjectCfg) Marshal.GetObjectForIUnknown(baseDebugConfigurationPtr);

            Instance = this;
        }
Example #7
0
        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;

#if DEV14_OR_LATER
                // 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;
                }
#endif

                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;

                // 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(), "--redirect-output" });

                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);
            }
        }