Exemple #1
0
        public System.Collections.Generic.List <UPPCompiler> Compile(System.Collections.Generic.List <Project> projects)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var vtasks = new System.Collections.Generic.List <UPPCompiler>();

            if (UPPCompilerExtensions.IsUSDKSupported())
            {
                var tasks = new System.Collections.Generic.List <UPPCompiler>();

                bool   failure       = false;
                string failure_title = string.Empty;
                string failure_msg   = string.Empty;

                foreach (var project in projects)
                {
                    string ProjectConfig = project.ConfigurationManager.ActiveConfiguration.ConfigurationName;
                    string Platform      = project.ConfigurationManager.ActiveConfiguration.PlatformName;

                    string   configneedmessage = string.Empty;
                    SDKError uerr = project.DetectUSDK(ProjectConfig, Platform, out configneedmessage);
                    if (uerr == SDKError.ConfigNeed)
                    {
                        failure_title = "未设置指定配置";
                        failure_msg   = configneedmessage;
                        failure       = true;
                    }

                    if (uerr == SDKError.Success)
                    {
                        using (var serviceProvider = new ServiceProvider(dte2.DTE as Microsoft.VisualStudio.OLE.Interop.IServiceProvider))
                        {
                            Guid guid = project.GetProjectGuid(serviceProvider);

                            string      clmsg = string.Empty;
                            UPPCompiler uppcl = UPPCompiler.Create(0, dte2.GetVCProject(guid), ProjectConfig, Platform, out clmsg);

                            if (uppcl != null)
                            {
                                tasks.Add(uppcl);
                            }
                            else
                            {
                                failure_title = "无效项设置";
                                failure_msg   = clmsg;
                                failure       = true;
                                foreach (var task in tasks)
                                {
                                    task.Dispose();
                                }
                                tasks.Clear();
                            }
                        }
                    }
                }

                if (!failure)
                {
                    if (tasks.Count > 0)
                    {
                        foreach (var task in tasks)
                        {
                            if (task.Compile())
                            {
                                vtasks.Add(task);
                            }
                        }
                    }
                }
            }
            return(vtasks);
        }