Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            try {
                Options opts = new Options(args);
                if (!opts.IsValid)
                {
                    Usage();
                                        #if DEBUG
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        Console.ReadLine();
                    }
                                        #endif
                    return;
                }

                ExecutablesCommon.ProcessWorkItemsInSeparateAppDomain(opts.ConfigFile, new[] { new WorkItem {
                                                                                                   InFile = opts.InputFile, OutFile = opts.OutputFile, Namespace = opts.Nmspace
                                                                                               } }, null);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                                #if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    Console.ReadLine();
                }
                                #endif
            }
        }
Ejemplo n.º 2
0
        public override bool Execute()
        {
            var inputsGroupedByConfigFile = new Dictionary <string, List <WorkItem> >();

            OutputFiles = new ITaskItem[InputFiles.Length];
            for (int i = 0; i < InputFiles.Length; i++)
            {
                string infileLocal = InputFiles[i].ItemSpec;
                OutputFiles[i] = new TaskItem(Path.ChangeExtension(infileLocal, ExecutablesCommon.GeneratedFileExtension));
                string          infile     = Path.GetFullPath(infileLocal);
                string          outfile    = Path.ChangeExtension(infile, ExecutablesCommon.GeneratedFileExtension);
                string          configFile = ExecutablesCommon.FindConfigFilePath(infile) ?? "";
                List <WorkItem> l;
                if (!inputsGroupedByConfigFile.TryGetValue(configFile, out l))
                {
                    inputsGroupedByConfigFile[configFile] = l = new List <WorkItem>();
                }
                l.Add(new WorkItem()
                {
                    InFile = infile, OutFile = outfile, Namespace = FindNamespace(InputFiles[i])
                });
            }

            bool success = true;

            foreach (var kvp in inputsGroupedByConfigFile)
            {
                ExecutablesCommon.ProcessWorkItemsInSeparateAppDomain(kvp.Key, kvp.Value, (item, ex) => {
                    if (ex is TemplateErrorException)
                    {
                        Log.LogError(null, null, null, item.InFile, 0, 0, 0, 0, ex.Message);
                        success = false;
                    }
                    else
                    {
                        Log.LogErrorFromException(ex, true, true, item.InFile);
                        success = false;
                    }
                    return(true);
                });
            }
            return(success);
        }