Exemple #1
0
        static bool CheckAnyFileExists(IEnumerable <ProjectFile> files)
        {
            foreach (ProjectFile file in files)
            {
                if (!file.IsLink && File.Exists(file.Name))
                {
                    return(true);
                }

                if (file.HasChildren)
                {
                    foreach (var child in file.DependentChildren.ToArray())
                    {
                        if (File.Exists(child.Name))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        static bool CheckAnyFileExists(IEnumerable <ProjectFile> files)
        {
            foreach (ProjectFile file in files)
            {
                if (!file.IsLink && File.Exists(file.Name))
                {
                    return(true);
                }

                var children = FileNestingService.GetDependentOrNestedChildren(file);
                if (children != null)
                {
                    foreach (var child in children.ToArray())
                    {
                        if (File.Exists(child.Name))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Get the project file
            HashSet <FileReference> ProjectFiles = ResolveFilespec(CommandUtils.RootDirectory, Parameters.Project, TagNameToFileSet);

            foreach (FileReference ProjectFile in ProjectFiles)
            {
                if (!ProjectFile.Exists())
                {
                    CommandUtils.LogError("Couldn't find project file '{0}'", ProjectFile.FullName);
                    return(false);
                }
            }

            // Get the default properties
            Dictionary <string, string> Properties = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);

            if (!String.IsNullOrEmpty(Parameters.Platform))
            {
                Properties["Platform"] = Parameters.Platform;
            }
            if (!String.IsNullOrEmpty(Parameters.Configuration))
            {
                Properties["Configuration"] = Parameters.Configuration;
            }

            // Build the arguments and run the build
            if (!Parameters.EnumerateOnly)
            {
                List <string> Arguments = new List <string>();
                foreach (KeyValuePair <string, string> PropertyPair in Properties)
                {
                    Arguments.Add(String.Format("/property:{0}={1}", CommandUtils.MakePathSafeToUseWithCommandLine(PropertyPair.Key), CommandUtils.MakePathSafeToUseWithCommandLine(PropertyPair.Value)));
                }
                if (!String.IsNullOrEmpty(Parameters.Arguments))
                {
                    Arguments.Add(Parameters.Arguments);
                }
                foreach (FileReference ProjectFile in ProjectFiles)
                {
                    CommandUtils.MsBuild(CommandUtils.CmdEnv, ProjectFile.FullName, String.Join(" ", Arguments), null);
                }
            }

            // Try to figure out the output files
            HashSet <FileReference> ProjectBuildProducts;

            if (!FindBuildProducts(ProjectFiles, Properties, out ProjectBuildProducts))
            {
                return(false);
            }

            // Apply the optional tag to the produced archive
            if (!String.IsNullOrEmpty(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, Parameters.Tag).UnionWith(ProjectBuildProducts);
            }

            // Merge them into the standard set of build products
            BuildProducts.UnionWith(ProjectBuildProducts);
            return(true);
        }