예제 #1
0
 public override bool Execute()
 {
     return(BuildEngine2.BuildProjectFilesInParallel(GetSolutionProject(), null, null, null, null, true, false));
 }
예제 #2
0
        public override bool Execute()
        {
            if (projects.Length == 0)
            {
                return(true);
            }

            string filename;
            bool   result     = true;
            bool   all_result = true;

            stopOnFirstFailure = false;
            List <ITaskItem> outputItems      = new List <ITaskItem> ();
            string           currentDirectory = Environment.CurrentDirectory;
            Hashtable        outputs;

            var global_properties = SplitPropertiesToDictionary();

            Log.LogMessage(MessageImportance.Low, "Global Properties:");
            if (global_properties != null)
            {
                foreach (KeyValuePair <string, string> pair in global_properties)
                {
                    Log.LogMessage(MessageImportance.Low, "\t{0} = {1}", pair.Key, pair.Value);
                }
            }

            foreach (ITaskItem project in projects)
            {
                filename = project.GetMetadata("FullPath");
                if (!File.Exists(filename))
                {
                    Log.LogError("Could not find the project file '{0}'", filename);
                    if (stopOnFirstFailure)
                    {
                        break;
                    }

                    continue;
                }

                Directory.SetCurrentDirectory(Path.GetDirectoryName(filename));
                outputs = new Hashtable();

                try {
                    // Order of precedence:
                    // ToolsVersion property, %(Project.ToolsVersion)
                    string tv = ToolsVersion;
                    if (String.IsNullOrEmpty(tv))
                    {
                        // metadata on the Project item
                        tv = project.GetMetadata("ToolsVersion");
                    }

                    if (!String.IsNullOrEmpty(tv) && Engine.GlobalEngine.Toolsets [tv] == null)
                    {
                        throw new UnknownToolsVersionException(tv);
                    }

                    result = BuildEngine2.BuildProjectFile(filename, targets, global_properties, outputs, tv);
                } catch (InvalidProjectFileException e) {
                    Log.LogError("Error building project {0}: {1}", filename, e.Message);
                    result = false;
                }

                if (!result)
                {
                    all_result = false;
                }

                if (result)
                {
                    foreach (DictionaryEntry de in outputs)
                    {
                        ITaskItem [] array = (ITaskItem [])de.Value;
                        foreach (ITaskItem item in array)
                        {
                            // DONT share items!
                            ITaskItem new_item = new TaskItem(item);

                            // copy the metadata from original @project to here
                            // CopyMetadataTo does _not_ overwrite
                            project.CopyMetadataTo(new_item);

                            outputItems.Add(new_item);

                            //FIXME: Correctly rebase output paths to be relative to the
                            //	 calling project
                            //if (rebaseOutputs)
                            //	File.Copy (item.ItemSpec, Path.Combine (currentDirectory, item.ItemSpec), true);
                        }
                    }
                }
                else
                {
                    if (stopOnFirstFailure)
                    {
                        break;
                    }
                }

                Directory.SetCurrentDirectory(currentDirectory);
            }

            if (all_result)
            {
                targetOutputs = outputItems.ToArray();
            }

            Directory.SetCurrentDirectory(currentDirectory);
            return(all_result);
        }
 public override bool Execute()
 {
     return(BuildEngine2.BuildProjectFilesInParallel(SolutionFile.Parse(Solution).ProjectsByGuid.Select(p => p.Value.AbsolutePath).ToArray(), null, null, null, null, true, false));
 }