示例#1
0
        bool IsDirty(LibraryProject lib)
        {
            try
            {
                // Marked by command-line & EnumerateDirty()
                if (_dirty.Contains(lib.ToUpperInvariant()))
                {
                    return(true);
                }

                if (!File.Exists(lib.PackageFile))
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "package not found");
                    return(true);
                }

                if (Directory.EnumerateDirectories(lib.PackageDirectory).Count() > 1)
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "old version(s) found");
                    return(true);
                }

                if (Configuration != null && (
                        !File.Exists(lib.ConfigFile) ||
                        File.ReadAllText(lib.ConfigFile).Trim() != Configuration.ToString()
                        ))
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "dirty config");
                    return(true);
                }

                if (File.GetLastWriteTime(lib.Project.FullPath) > lib.LastBuildTime)
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "dirty project");
                    return(true);
                }

                foreach (var e in lib.Project.GetFlattenedItems())
                {
                    var file = Path.Combine(lib.Project.RootDirectory, e.Value);
                    if (File.Exists(file) && File.GetLastWriteTime(file) > lib.LastBuildTime)
                    {
                        Log.Event(IOEvent.Build, lib.Project.Name, "dirty file: " + e.Value);
                        return(true);
                    }
                }

                // Don't waste time on dependencies in express mode
                if (Express)
                {
                    return(false);
                }

                foreach (var e in lib.References)
                {
                    foreach (var dependency in _libMap.GetList(e))
                    {
                        if (dependency.LastBuildTime > lib.LastBuildTime)
                        {
                            Log.Event(IOEvent.Build, lib.Project.Name, "dirty dependency: " + dependency.Project.Name);
                            Log.UltraVerbose("dependency: " + dependency.LastBuildTime + ", lib: " + lib.LastBuildTime);
                            return(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Event(IOEvent.Build, lib.Project.Name, "exception: " + e.Message);
                return(true);
            }

            return(false);
        }
示例#2
0
        bool IsDirty(LibraryProject lib)
        {
            try
            {
                // Marked by command-line & EnumerateDirty()
                if (_dirty.Contains(lib.ToUpperInvariant()))
                {
                    return(true);
                }

                // Check if a build with a different version number exists, possibly
                // the project is already built using 'uno doctor --version=X.Y.Z'.
                LibraryProject existing;
                if (string.IsNullOrEmpty(Version) && lib.TryGetExistingBuild(out existing))
                {
                    // Test the existing build and maybe we don't need to built it again.
                    lib = existing;
                }

                if (!File.Exists(lib.PackageFile))
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "package not found");
                    return(true);
                }

                if (Directory.EnumerateDirectories(lib.PackageDirectory).Count() > 1)
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "old version(s) found");
                    return(true);
                }

                if (Configuration != null && (
                        !File.Exists(lib.ConfigFile) ||
                        File.ReadAllText(lib.ConfigFile).Trim() != Configuration.ToString()
                        ))
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "dirty config");
                    return(true);
                }

                if (File.GetLastWriteTime(lib.Project.FullPath) > lib.LastBuildTime)
                {
                    Log.Event(IOEvent.Build, lib.Project.Name, "dirty project");
                    return(true);
                }

                foreach (var e in lib.Project.GetFlattenedItems())
                {
                    var file = Path.Combine(lib.Project.RootDirectory, e.Value);
                    if (File.Exists(file) && File.GetLastWriteTime(file) > lib.LastBuildTime)
                    {
                        Log.Event(IOEvent.Build, lib.Project.Name, "dirty file: " + e.Value);
                        return(true);
                    }
                }

                // Don't waste time on dependencies in express mode
                if (Express)
                {
                    return(false);
                }

                foreach (var e in lib.References)
                {
                    foreach (var dependency in _libMap.GetList(e))
                    {
                        if (dependency.LastBuildTime > lib.LastBuildTime)
                        {
                            Log.Event(IOEvent.Build, lib.Project.Name, "dirty dependency: " + dependency.Project.Name);
                            Log.UltraVerbose("dependency: " + dependency.LastBuildTime + ", lib: " + lib.LastBuildTime);
                            return(true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Event(IOEvent.Build, lib.Project.Name, "exception: " + e.Message);
                return(true);
            }

            return(false);
        }