private ManifestItem UpdateItem(ManifestItem item, string sourceRelativePath)
        {
            var result = item.Clone();

            result.IsIncremental      = true;
            result.SourceRelativePath = sourceRelativePath;
            Parallel.ForEach(
                from ofi in result.OutputFiles.Values
                where ofi.LinkToPath != null
                where ofi.LinkToPath.Length > IncrementalContext.LastBaseDir.Length
                where ofi.LinkToPath.StartsWith(IncrementalContext.LastBaseDir)
                where (ofi.LinkToPath[IncrementalContext.LastBaseDir.Length] == '\\' || ofi.LinkToPath[IncrementalContext.LastBaseDir.Length] == '/')
                select ofi,
                new ParallelOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            },
                ofi =>
            {
                IncrementalUtility.RetryIO(() =>
                {
                    var path = Path.Combine(IncrementalContext.BaseDir, IncrementalUtility.GetRandomEntry(IncrementalContext.BaseDir));
                    File.Copy(Environment.ExpandEnvironmentVariables(ofi.LinkToPath), Environment.ExpandEnvironmentVariables(path));
                    ofi.LinkToPath = path;
                });
            });

            return(result);
        }
        private ManifestItem UpdateItem(ManifestItem item, string sourceRelativePath)
        {
            var result = item.Clone();

            result.IsIncremental      = true;
            result.SourceRelativePath = sourceRelativePath;

            // Copy when current base dir is not last base dir
            if (!FilePathComparerWithEnvironmentVariable.OSPlatformSensitiveRelativePathComparer.Equals(
                    IncrementalContext.BaseDir,
                    IncrementalContext.LastBaseDir))
            {
                foreach (var ofi in result.OutputFiles.Values)
                {
                    if (ofi.LinkToPath != null &&
                        ofi.LinkToPath.Length > IncrementalContext.LastBaseDir.Length &&
                        ofi.LinkToPath.StartsWith(IncrementalContext.LastBaseDir, StringComparison.Ordinal) &&
                        (ofi.LinkToPath[IncrementalContext.LastBaseDir.Length] == '\\' || ofi.LinkToPath[IncrementalContext.LastBaseDir.Length] == '/'))
                    {
                        IncrementalUtility.RetryIO(() =>
                        {
                            var path = Path.Combine(IncrementalContext.BaseDir, IncrementalUtility.GetRandomEntry(IncrementalContext.BaseDir));
                            File.Copy(Environment.ExpandEnvironmentVariables(ofi.LinkToPath), Environment.ExpandEnvironmentVariables(path));
                            ofi.LinkToPath = path;
                        });
                    }
                }
            }

            return(result);
        }
        private ManifestItem UpdateItem(ManifestItem item, string sourceRelativePath)
        {
            var result = item.Clone();

            result.IsIncremental      = true;
            result.SourceRelativePath = sourceRelativePath;
            foreach (var ofi in result.OutputFiles.Values)
            {
                if (ofi.LinkToPath != null &&
                    ofi.LinkToPath.Length > IncrementalContext.LastBaseDir.Length &&
                    ofi.LinkToPath.StartsWith(IncrementalContext.LastBaseDir) &&
                    (ofi.LinkToPath[IncrementalContext.LastBaseDir.Length] == '\\' || ofi.LinkToPath[IncrementalContext.LastBaseDir.Length] == '/'))
                {
                    IncrementalUtility.RetryIO(() =>
                    {
                        var path = Path.Combine(IncrementalContext.BaseDir, IncrementalUtility.GetRandomEntry(IncrementalContext.BaseDir));
                        File.Copy(Environment.ExpandEnvironmentVariables(ofi.LinkToPath), Environment.ExpandEnvironmentVariables(path));
                        ofi.LinkToPath = path;
                    });
                }
            }
            return(result);
        }