void IVsAppContainerProjectDeployCallback.OnEndDeploy(bool successful, string deployedPackageMoniker, string deployedAppUserModelID)
        {
            try
            {
                if (successful)
                {
                    deployPackageMoniker = deployedPackageMoniker;
                    deployAppUserModelID = deployedAppUserModelID;
                    NotifyEndDeploy(1);
                }
                else
                {
                    deployPackageMoniker = null;
                    deployAppUserModelID = null;
                    NotifyEndDeploy(0);
                }
            }
            finally
            {
                IVsDebuggerDeployConnection localConnection = null;

                lock (syncObject)
                {
                    this.appContainerBootstrapperOperation = null;
                    this.appContainerDeployOperation       = null;
                    localConnection = this.debuggerDeployConnection;
                    this.debuggerDeployConnection = null;
                }

                if (localConnection != null)
                {
                    localConnection.Dispose();
                }
            }
        }
Example #2
0
        public int StartDeploy(IVsOutputWindowPane pIVsOutputWindowPane, uint dwOptions)
        {
            int continueOn = 1;

            outputWindow = pIVsOutputWindowPane;

            if (connection != null)
            {
                lock (syncObject) {
                    if (connection != null)
                    {
                        connection.Dispose();
                        connection = null;
                    }
                }
            }

            // Loop through deploy status callbacks
            foreach (IVsDeployStatusCallback callback in deployCallbackCollection)
            {
                if (ErrorHandler.Failed(callback.OnStartDeploy(ref continueOn)))
                {
                    continueOn = 0;
                }

                if (continueOn == 0)
                {
                    outputWindow = null;
                    return(VSConstants.E_ABORT);
                }
            }

            try {
                VsDebugTargetInfo2[] targets;
                uint   deployFlags          = (uint)(_AppContainerDeployOptions.ACDO_NetworkLoopbackEnable | _AppContainerDeployOptions.ACDO_SetNetworkLoopback);
                string recipeFile           = null;
                string layoutDir            = null;
                var    pythonProject        = PythonConfig;
                IVsBuildPropertyStorage bps = (IVsBuildPropertyStorage)pythonProject;
                int hr = QueryDebugTargets(out targets);
                if (ErrorHandler.Failed(hr))
                {
                    NotifyEndDeploy(0);
                    return(hr);
                }

                string canonicalName;

                get_CanonicalName(out canonicalName);

                bps.GetPropertyValue("AppxPackageRecipe", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out recipeFile);

                string      projectUniqueName = null;
                IVsSolution vsSolution        = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
                if (vsSolution != null)
                {
                    hr = vsSolution.GetUniqueNameOfProject(pythonProject, out projectUniqueName);
                }

                IVsAppContainerProjectDeploy deployHelper = (IVsAppContainerProjectDeploy)Package.GetGlobalService(typeof(SVsAppContainerProjectDeploy));
                if (String.IsNullOrEmpty(targets[0].bstrRemoteMachine))
                {
                    bps.GetPropertyValue("LayoutDir", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out layoutDir);

                    deployOp = deployHelper.StartDeployAsync(deployFlags, recipeFile, layoutDir, projectUniqueName, this);
                }
                else
                {
                    IVsDebuggerDeploy           deploy = (IVsDebuggerDeploy)Package.GetGlobalService(typeof(SVsShellDebugger));
                    IVsDebuggerDeployConnection deployConnection;

                    hr = deploy.ConnectToTargetComputer(targets[0].bstrRemoteMachine, VsDebugRemoteAuthenticationMode.VSAUTHMODE_None, out deployConnection);
                    if (ErrorHandler.Failed(hr))
                    {
                        NotifyEndDeploy(0);
                        return(hr);
                    }

                    connection = deployConnection;

                    deployOp = deployHelper.StartRemoteDeployAsync(deployFlags, connection, recipeFile, projectUniqueName, this);
                }
            } catch (Exception) {
                if (connection != null)
                {
                    lock (syncObject) {
                        if (connection != null)
                        {
                            connection.Dispose();
                            connection = null;
                        }
                    }
                }
                connection = null;

                NotifyEndDeploy(0);

                // Rethrow exception
                throw;
            }

            return(VSConstants.S_OK);
        }
Example #3
0
        int IVsDeployableProjectCfg.StartDeploy(IVsOutputWindowPane pIVsOutputWindowPane, uint dwOptions)
        {
            int continueOn = 1;

            outputWindow = pIVsOutputWindowPane;

            if (connection != null)
            {
                lock (syncObject)
                {
                    if (connection != null)
                    {
                        connection.Dispose();
                        connection = null;
                    }
                }
            }

            // Loop through deploy status callbacks
            foreach (IVsDeployStatusCallback callback in deployCallbackCollection)
            {
                if (ErrorHandler.Failed(callback.OnStartDeploy(ref continueOn)))
                {
                    continueOn = 0;
                }

                if (continueOn == 0)
                {
                    outputWindow = null;
                    return(VSConstants.E_ABORT);
                }
            }

            try
            {
                VsDebugTargetInfo2[] targets;
                uint                 deployFlags = (uint)(_AppContainerDeployOptions.ACDO_NetworkLoopbackEnable | _AppContainerDeployOptions.ACDO_SetNetworkLoopback);
                string               recipeFile  = null;
                string               layoutDir   = null;
                EnvDTE.DTE           dte         = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));
                EnvDTE.SolutionBuild sb          = dte.Solution.SolutionBuild;
                string               uniqueName  = string.Empty;
                foreach (String s in (Array)sb.StartupProjects)
                {
                    // There should only be one startup project so get the first one we find.
                    uniqueName = s;
                    break;
                }
                if (uniqueName.Equals(string.Empty))
                {
                    throw new Exception("Could not find a startup project to deploy.");
                }
                IVsSolution  solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
                IVsHierarchy hierarchy;
                solution.GetProjectOfUniqueName(uniqueName, out hierarchy);
                string canonicalName;
                IVsBuildPropertyStorage bps = hierarchy as IVsBuildPropertyStorage;

                int hr = QueryDebugTargets(out targets);
                if (ErrorHandler.Failed(hr))
                {
                    NotifyEndDeploy(0);
                    return(hr);
                }

                get_CanonicalName(out canonicalName);
                bps.GetPropertyValue("AppxPackageRecipe", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out recipeFile);
                bps.GetPropertyValue("LayoutDir", canonicalName, (uint)_PersistStorageType.PST_PROJECT_FILE, out layoutDir);

                string      projectUniqueName = null;
                IVsSolution vsSolution        = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
                if (vsSolution != null)
                {
                    hr = vsSolution.GetUniqueNameOfProject((IVsHierarchy)this.project, out projectUniqueName);
                }

                PrepareNodeStartupInfo(uniqueName);

                System.IServiceProvider      sp           = this.project as System.IServiceProvider;
                IVsAppContainerProjectDeploy deployHelper = (IVsAppContainerProjectDeploy)sp.GetService(typeof(SVsAppContainerProjectDeploy));
                if (String.IsNullOrEmpty(targets[0].bstrRemoteMachine))
                {
                    deployOp = deployHelper.StartDeployAsync(deployFlags, recipeFile, layoutDir, projectUniqueName, this);
                }
                else
                {
                    IVsDebuggerDeploy           deploy = (IVsDebuggerDeploy)sp.GetService(typeof(SVsShellDebugger));
                    IVsDebuggerDeployConnection deployConnection;
                    bool useAuthentication             = false;
                    VsDebugRemoteAuthenticationMode am = useAuthentication ? VsDebugRemoteAuthenticationMode.VSAUTHMODE_WindowsAuthentication : VsDebugRemoteAuthenticationMode.VSAUTHMODE_None;
                    hr = deploy.ConnectToTargetComputer(targets[0].bstrRemoteMachine, am, out deployConnection);
                    if (ErrorHandler.Failed(hr))
                    {
                        NotifyEndDeploy(0);
                        return(hr);
                    }

                    connection = deployConnection;

                    deployOp = deployHelper.StartRemoteDeployAsync(deployFlags, connection, recipeFile, projectUniqueName, this);
                }
            }
            catch (Exception)
            {
                if (connection != null)
                {
                    lock (syncObject)
                    {
                        if (connection != null)
                        {
                            connection.Dispose();
                            connection = null;
                        }
                    }
                }
                connection = null;

                NotifyEndDeploy(0);
                throw;
            }

            return(VSConstants.S_OK);
        }