Пример #1
0
        protected override ProjectNode CreateProject()
        {
            try {
                var project = new VSProjectNode(this.Package as VSProject);

                project.SetSite((IOleServiceProvider)((IServiceProvider)this.Package).GetService(typeof(IOleServiceProvider)));
                LogUtility.LogString("(Result == null) = {0}", project == null);
                return(project);
            } catch (Exception E) {
                LogUtility.LogException(E);
                throw;
            }
        }
Пример #2
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation

        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        protected override void Initialize()
        {
            LogUtility.LogString("Cosmos.VS.Package initializing");
            try {
                SetCosmosVar();
                base.Initialize();
                this.RegisterProjectFactory(new VSProjectFactory(this));
                LogUtility.LogString("Cosmos.VS.Package successfully initialized");
            }
            catch (Exception E) {
                LogUtility.LogException(E);
            }
        }
Пример #3
0
        public override void AddFileFromTemplate(
            string source, string target)
        {
            LogUtility.LogString("Entering Cosmos.VS.Package.VSProjectNode.AddFileFromTemplate('{0}', '{1}')", source, target);
            try {
                string nameSpace =
                    this.FileTemplateProcessor.GetFileNamespace(target, this);
                string className = Path.GetFileNameWithoutExtension(target);

                this.FileTemplateProcessor.AddReplace("$nameSpace$", nameSpace);
                this.FileTemplateProcessor.AddReplace("$className$", className);

                this.FileTemplateProcessor.UntokenFile(source, target);
                this.FileTemplateProcessor.Reset();
            } catch (Exception E) {
                LogUtility.LogException(E);
            } finally {
                LogUtility.LogString("Exiting Cosmos.VS.Package.VSProjectNode.AddFileFromTemplate");
            }
        }
Пример #4
0
        public VSProjectNode(VSProject package)
        {
            LogUtility.LogString("Entering Cosmos.VS.Package.VSProjectNode.ctor(VSProject)");
            try {
                this.Package = package;

                var dte = (EnvDTE.DTE)((IServiceProvider)this.Package).GetService(typeof(EnvDTE.DTE));
                buildEvents = dte.Events.BuildEvents;
                buildEvents.OnBuildProjConfigDone += buildEvents_OnBuildProjConfigDone;

                imageIndex = this.ImageHandler.ImageList.Images.Count;

                foreach (Image img in imageList.Images)
                {
                    this.ImageHandler.AddImage(img);
                }
            } catch (Exception E) {
                LogUtility.LogException(E);
            } finally {
                LogUtility.LogString("Exiting Cosmos.VS.Package.VSProjectNode.ctor(VSProject)");
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
 /// Default constructor of the package.
 /// Inside this method you can place any initialization code that does not require
 /// any Visual Studio service because at this point the package object is created but
 /// not sited yet inside Visual Studio environment. The place to do all the other
 /// initialization is the Initialize method.
 public VSProject()
 {
     LogUtility.LogString("Cosmos.VS.Package.VSProject instantiated");
 }