コード例 #1
0
        public virtual bool Applies()
        {
            if (MinVersion != VSInstance.None)
            {
                // Calculate enum value. VS2005 = VS 8.0
                VSInstance actualVersion = (VSInstance)(VSVersion.FullVersion.Major - 8 + (int)VSInstance.VS2005);

                if (MinVersion > actualVersion)
                {
                    return(false);
                }
            }

            if (MaxVersion != VSInstance.None)
            {
                // Calculate enum value. VS2005 = VS 8.0
                VSInstance actualVersion = (VSInstance)(VSVersion.FullVersion.Major - 8 + (int)VSInstance.VS2005);

                if (MaxVersion < actualVersion)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        public static bool BuildVsix(Logger l, string logDir, string projectFile)
        {
            var query       = new SetupConfiguration();
            var setupHelper = (ISetupHelper)query;

            var instances = new List <VSInstance>();

            ForEachVsInstance(inst =>
            {
                var version  = inst.GetInstallationVersion();
                var instance = new VSInstance
                {
                    Name        = inst.GetDisplayName(),
                    Version     = version,
                    IntVersion  = setupHelper.ParseVersion(version),
                    Path        = inst.GetInstallationPath(),
                    MSBuildPath = inst.ResolvePath("MSBuild\\Current\\Bin\\MSBuild.exe")
                };

                instances.Add(instance);
            });

            instances.Sort((left, right) => Math.Sign((long)left.IntVersion - (long)right.IntVersion));
            var newestInstance = instances.Last();

            if (!newestInstance.IsVs2017OrNewer())
            {
                l.LogError("Did not find a VS2017+ installation.");
                return(false);
            }

            l.Log("Building VSIX");

            var buildLogPath  = Path.Combine(logDir, "build.log");
            var vsixDir       = Path.GetDirectoryName(projectFile);
            var buildExitCode = MSBuildBuild(buildLogPath, newestInstance.MSBuildPath, vsixDir);

            if (buildExitCode != 0)
            {
                l.LogError($"VSIX build failed, check the MSBuild output at {Path.GetFullPath(buildLogPath)}.");
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            TraceService.WriteLine("NinjaCoder_MvvmCross_VSPackagePackage::Initialize START");

            base.Initialize();

            DTE2 dte2 = this.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SDTE)) as DTE2;

            if (dte2 == null)
            {
                TraceService.WriteError("DTE2 is null from this.GetService(typeof(DTE2))");
            }

            this.VsInstance = new VSInstance(dte2);

            string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            TraceService.WriteLine("assembly path=" + assemblyPath);

            NinjaController.SetWorkingDirectory(Path.GetDirectoryName(assemblyPath));

            OleMenuCommandService mcs = this.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs == null)
            {
                TraceService.WriteError("NinjaCoder_MvvmCross_VSPackagePackage::menuCommandService is null");
                return;
            }

            CommandID   menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddProjects);
            MenuCommand menuItem      = new MenuCommand(this.OnAddProjects, menuCommandId);

            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddViewModelsAndViews);
            menuItem      = new MenuCommand(this.OnAddViewModelAndViews, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddMvvmCrossPlugins);
            menuItem      = new MenuCommand(this.OnAddMvvmCrossPlugins, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddNugetPackages);
            menuItem      = new MenuCommand(this.OnAddNugetPackages, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddDependencyService);
            menuItem      = new MenuCommand(this.OnAddDependencyService, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddCustomRenderer);
            menuItem      = new MenuCommand(this.OnAddCustomerRenderer, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddEffect);
            menuItem      = new MenuCommand(this.OnAddEffect, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.Options);
            menuItem      = new MenuCommand(this.OnOptions, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ViewLogFile);
            menuItem      = new MenuCommand(this.OnViewLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ClearLogFile);
            menuItem      = new MenuCommand(this.OnClearLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ViewErrorLog);
            menuItem      = new MenuCommand(this.OnViewErrorLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ClearErrorLog);
            menuItem      = new MenuCommand(this.OnClearErrorLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.XamarinFormsHomePage);
            menuItem      = new MenuCommand(this.OnXamarinFormsHomePage, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.MvvmCrossHomePage);
            menuItem      = new MenuCommand(this.OnMvvmCrossHomePage, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.About);
            menuItem      = new MenuCommand(this.OnAbout, menuCommandId);
            mcs.AddCommand(menuItem);

            TraceService.WriteLine("NinjaCoder_MvvmCross_VSPackagePackage::Initialize END");
        }
コード例 #4
0
        /// <summary>
        /// Called when [connection].
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="connectMode">The connect mode.</param>
        /// <param name="addInInst">The add in instance.</param>
        /// <param name="custom">The custom.</param>
        public void OnConnection(
            object application, 
            ext_ConnectMode connectMode, 
            object addInInst, 
            ref Array custom)
        {
            this.VsInstance = new VSInstance((DTE2)application);
            this.AddInInstance = (AddIn)addInInst;

            TraceService.WriteLine("--------------------------------------------------------");
            TraceService.WriteLine("CommandManager::OnConnection ConnectMode=" + connectMode);
            TraceService.WriteLine("--------------------------------------------------------");

            switch (connectMode)
            {
                case ext_ConnectMode.ext_cm_UISetup:
                    //// Do nothing for this add-in with temporary user interface

                    //// Initialize for permanent user interface

                    this.UISetup();
                    this.Initialize();
                    break;

                case ext_ConnectMode.ext_cm_Startup:
                    //// The add-in was marked to load on startup
                    //// Do nothing at this point because the IDE may not be fully initialized
                    //// Visual Studio will call OnStartupComplete when fully initialized

                    this.StartUp();
                    this.Initialize();
                    break;

                case ext_ConnectMode.ext_cm_AfterStartup:
                    //// The add-in was loaded by hand after startup using the Add-In Manager
                    //// Initialize it in the same way that when is loaded on startup

                    this.AfterStartUp();
                    this.Initialize();
                    break;
            }
        }