Пример #1
0
        public override void Execute()
        {
            DTE    dte = (DTE)GetService(typeof(DTE));
            string resourcesFileName = Resources.get_FileNames(1);

            SourceControlHelper.EnsureWritable(dte, resourcesFileName);
            ResourcesHelper.AddResource(resourcesFileName,
                                        string.Format("{0}{1}", NodeInfo.NodeName, Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.UICommandText),
                                        string.Format(Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.RecourceValueNeeded,
                                                      string.Format("{0}{1}", NodeInfo.NodeName, Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.UICommandText)));
            ResourcesHelper.AddResource(resourcesFileName,
                                        string.Format("{0}{1}", NodeInfo.NodeName, Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.UICommandLongText),
                                        string.Format(Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.RecourceValueNeeded,
                                                      string.Format("{0}{1}", NodeInfo.NodeName, Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.UICommandLongText)));

            foreach (DesignTimePropertyInfo designTimePropertyInfo in NodeInfo.DesignTimeProperties)
            {
                if (!designTimePropertyInfo.Action.Equals(IncludePropertyAction.Ignore))
                {
                    string propertyDescriptionResourceEntry = string.Format("{0}{1}", designTimePropertyInfo.PropertyInfo.Name, DescriptionSuffix);
                    ResourcesHelper.AddResource(resourcesFileName,
                                                propertyDescriptionResourceEntry,
                                                string.Format(Microsoft.Practices.EnterpriseLibrary.BlockFactory.Properties.Resources.RecourceValueNeeded, propertyDescriptionResourceEntry));
                }
            }

            VSProjectItem vsResources = Resources.Object as VSProjectItem;

            if (vsResources != null)
            {
                vsResources.RunCustomTool();
            }
        }
Пример #2
0
        protected override void Initialize()
        {
            base.Initialize();

            var context = ((ITeamFoundationContextManager)GetService(typeof(ITeamFoundationContextManager))).CurrentContext;

            _model       = new TimelineModel(new TimelineService(context, (message) => OutputWindowHelper.OutputString(this, message)));
            base.Content = new TimelineWrapper(_model,
                                               (message) => OutputWindowHelper.OutputString(this, message),
                                               (id) => {
                var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
                SourceControlHelper.ShowChangeset(dte, id);
            });
        }
Пример #3
0
        public override void Execute()
        {
            DTE    vs = GetService <DTE>();
            string resourcesFileName = Resources.get_FileNames(1);

            SourceControlHelper.EnsureWritable(vs, resourcesFileName);
            IDictionaryService dictionaryService = GetService <IDictionaryService>();

            ResourcesHelper.AddResource(resourcesFileName,
                                        ArgumentsHelper.ReplaceToken(ResourceName, dictionaryService),
                                        ArgumentsHelper.ReplaceToken(ResourceValue, dictionaryService));
            VSProjectItem vsResources = Resources.Object as VSProjectItem;

            if (vsResources != null && RunCustomTool)
            {
                vsResources.RunCustomTool();
            }
        }
Пример #4
0
        /// <summary>
        /// Program entry points
        /// </summary>
        /// <param name="args">Program arguments</param>
        public static void Main(string[] args)
        {
            var result = Parser.Default.ParseArguments <Options>(args)
                         .WithParsed(options =>
            {
                if (!string.IsNullOrWhiteSpace(options.LogLevel))
                {
                    if (options.LogLevel.ToUpper() == "TRACE")
                    {
                        var loggers = NLog.LogManager.Configuration.LoggingRules.ToList();
                        loggers.ForEach(x => x.EnableLoggingForLevels(LogLevel.Trace, LogLevel.Fatal));
                    }
                    else if (options.LogLevel.ToUpper() == "DEBUG")
                    {
                        var loggers = NLog.LogManager.Configuration.LoggingRules.ToList();
                        loggers.ForEach(x => x.EnableLoggingForLevels(LogLevel.Debug, LogLevel.Fatal));
                    }
                    else if (options.LogLevel.ToUpper() == "INFO")
                    {
                        var loggers = NLog.LogManager.Configuration.LoggingRules.ToList();
                        loggers.ForEach(x => x.EnableLoggingForLevels(LogLevel.Info, LogLevel.Fatal));
                    }
                    else if (options.LogLevel.ToUpper() == "WARN")
                    {
                        var loggers = NLog.LogManager.Configuration.LoggingRules.ToList();
                        loggers.ForEach(x => x.EnableLoggingForLevels(LogLevel.Warn, LogLevel.Fatal));
                    }
                    else if (options.LogLevel.ToUpper() == "ERROR")
                    {
                        var loggers = NLog.LogManager.Configuration.LoggingRules.ToList();
                        loggers.ForEach(x => x.EnableLoggingForLevels(LogLevel.Error, LogLevel.Fatal));
                    }
                    else if (options.LogLevel.ToUpper() == "FATAL")
                    {
                        var loggers = NLog.LogManager.Configuration.LoggingRules.ToList();
                        loggers.ForEach(x => x.EnableLoggingForLevel(LogLevel.Fatal));
                    }
                    else
                    {
                        Console.WriteLine($"Invalid log level {options.LogLevel}");
                        Environment.Exit(-1);
                    }
                }

                var configManager = new ConfigManager();

                if (!File.Exists(options.ConfigFile))
                {
                    logger.Fatal($"The supplied config file {options.ConfigFile} does not exist.");
                    Environment.Exit(-1);
                }

                var configContainer = configManager.LoadConfigFromFile(options.ConfigFile);
                var selectedConfig  = configContainer.ConfigActions.FirstOrDefault(x => x.Name.ToUpper() == options.ConfigActionName.ToUpper());

                if (selectedConfig == null)
                {
                    logger.Fatal($"The supplied project name {options.ConfigActionName} was not found in the config file {options.ConfigFile}.");
                    Environment.Exit(-1);
                }

                if (string.IsNullOrWhiteSpace(configContainer.RepositoryRootDirectory))
                {
                    logger.Debug($"RepositoryRootDirectory was not set. Attempting to determine if we're in a repository");

                    logger.Debug($"Config HgExecutablePath={configContainer.HgExecutablePath},Expanded={Environment.ExpandEnvironmentVariables(configContainer.HgExecutablePath)}");

                    logger.Debug($"Config GitExecutablePath={configContainer.GitExecutablePath},Expanded={Environment.ExpandEnvironmentVariables(configContainer.GitExecutablePath)}");

                    var hgRepositoryRoot  = SourceControlHelper.GetHGRepositoryRootPath(Environment.ExpandEnvironmentVariables(configContainer.HgExecutablePath));
                    var gitRepositoryRoot = SourceControlHelper.GetGitRepositoryRootPath(Environment.ExpandEnvironmentVariables(configContainer.GitExecutablePath));

                    if (!string.IsNullOrWhiteSpace(hgRepositoryRoot))
                    {
                        logger.Debug($"We are in a Mercurial repository. Root = {hgRepositoryRoot}.");
                        configContainer.RepositoryRootDirectory = hgRepositoryRoot;
                    }
                    else if (!string.IsNullOrWhiteSpace(gitRepositoryRoot))
                    {
                        logger.Debug($"We are in a Git repository. Root = {gitRepositoryRoot}.");
                        configContainer.RepositoryRootDirectory = gitRepositoryRoot;
                    }
                    else
                    {
                        logger.Debug($"We are not in a repository and the RepositoryRootDirectory isn't set. We cannot function like this. Exiting.");
                        Environment.Exit(-1);
                    }
                }
                else
                {
                    logger.Debug("$Repository is set in config file. {configContainer.RepositoryRootDirectory}");
                }

                logger.Debug($"Starting processing");
                foreach (var configItem in selectedConfig.ConfigItems)
                {
                    logger.Info($"Processing configItem Name={configItem.Name}, PackageName={configItem.PackageName}, RelativeDirectory={configItem.RelativeDirectory}, TargetFilename={configItem.TargetFilename}");
                    var package = configContainer.ConfigPackages.FirstOrDefault(x => x.Name.ToUpper() == configItem.PackageName.ToUpper());

                    if (package == null)
                    {
                        logger.Fatal($"The package {configItem.PackageName} is not a valid package name");
                        Environment.Exit(-1);
                    }

                    configManager.ProcessConfig(Path.Combine(configContainer.RepositoryRootDirectory, configItem.RelativeDirectory), configItem.TargetFilename, package, new FileSystem());
                }

                logger.Info($"Processing complete");
            })
                         .WithNotParsed(errors => { });
        }