示例#1
0
 public RebuildCommand([Named("clean")] ICommand cleanCommand, [Named("build")] ICommand buildCommand, [TargetRoot] IFileSystemDirectory targetRoot, [CacheRoot] IFileSystemDirectory cacheRoot)
 {
     this.cleanCommand = cleanCommand;
     this.buildCommand = buildCommand;
     this.targetRoot   = targetRoot;
     this.cacheRoot    = cacheRoot;
 }
示例#2
0
        /// <summary>
        /// Gets the relative path from this directory to another directory (in any depth)
        ///
        /// <para>If the given argument is not a child of this directory, an <see cref="ArgumentException"/>will
        /// be thrown.</para>
        /// </summary>
        /// <param name="childDirectory">The child directory to get path to</param>
        /// <returns>Returns the path</returns>
        public string GetRelativePath(IFileSystemDirectory childDirectory)
        {
            Contract.Requires(childDirectory != null);
            Contract.Ensures(Contract.Result <string>() != null);

            return(null); // dummy value
        }
示例#3
0
        private static List <IFileSystemInfo> GetFiles(string path, IDepth depth, IFileSystemDirectory parent)
        {
            var result = new List <IFileSystemInfo>();

            try
            {
                var files = Directory.GetFiles(path)
                            .Select(p => new FileInfo(p))
                            .Where(p => !p.Attributes.HasFlag(FileAttributes.Directory) &&
                                   !p.Attributes.HasFlag(FileAttributes.Hidden) &&
                                   !p.Attributes.HasFlag(FileAttributes.System) &&
                                   !p.Attributes.HasFlag(FileAttributes.Offline) &&
                                   !p.Attributes.HasFlag(FileAttributes.Encrypted))
                            .Select(p => new MapleFile(p, depth, parent))
                            .ToList();

                result.AddRange(files);
            }
            catch (UnauthorizedAccessException ex)
            {
                Debug.WriteLine($"{nameof(UnauthorizedAccessException)} occured during reading off {path}");
                Debug.WriteLine(ex.Message);
            }
            return(result);
        }
示例#4
0
        public DefaultSuiteFactory(IParameters parameters, [SuiteRoot] IFileSystemDirectory suiteRoot, ICommandEnumerator commandEnumerator)
        {
            targetGoal = parameters.Goal;
            this.suiteRoot = suiteRoot;

            ignoreTargetGoal = !commandEnumerator.NeedsExplicitTargetGoal(parameters.Command);
        }
示例#5
0
 public DefaultPluginLoader(IReferenceBuilderFactory referenceBuilderFactory, IBuildContextFactory buildContextFactory, [SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot)
 {
     this.referenceBuilderFactory = referenceBuilderFactory;
     this.buildContextFactory = buildContextFactory;
     this.suiteRoot = suiteRoot;
     this.targetRoot = targetRoot;
 }
示例#6
0
        /// <summary>
        /// Copy a file to a target directory
        /// </summary>
        /// <param name="name">Name of the file</param>
        /// <param name="target">Target file system directory</param>
        /// <param name="targetName">Name (relative path) in the target directory</param>
        public void CopyFile(string name, IFileSystemDirectory target, string targetName)
        {
            var localTarget = target as LocalFileSystemDirectory;

            if (localTarget != null)
            {
                var targetSubdir = Path.GetDirectoryName(targetName);

                if (!String.IsNullOrWhiteSpace(targetSubdir))
                {
                    var absoluteTargetDir = Path.Combine(localTarget.AbsolutePath, targetSubdir);
                    if (!Directory.Exists(absoluteTargetDir))
                    {
                        Directory.CreateDirectory(absoluteTargetDir);
                    }
                }

                File.Copy(Path.Combine(path, name), Path.Combine(localTarget.AbsolutePath, targetName), overwrite: true);
            }
            else
            {
                using (var sourceStream = ReadBinaryFile(name))
                    using (var targetStream = target.CreateBinaryFileWithDirectories(targetName))
                        StreamOperations.Copy(sourceStream, targetStream);
            }
        }
示例#7
0
 public PropertiesSection(Suite suite, IProjectGuidManagement projectGuidManagement, [TargetRoot] IFileSystemDirectory targetDir, IProjectPlatformManagement platformManagement)
     : base(suite)
 {
     this.projectGuidManagement = projectGuidManagement;
     this.targetDir             = targetDir;
     this.platformManagement    = platformManagement;
 }
示例#8
0
 public ContentBuilder(Project project, ISourceSetFingerprintFactory fingerprintFactory, [SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot)
 {
     this.project = project;
     this.fingerprintFactory = fingerprintFactory;
     this.suiteRoot = suiteRoot;
     this.targetRoot = targetRoot;
 }
示例#9
0
        /// <summary>
        /// Store build outputs in the cache by reading them from the file system
        /// </summary>
        /// <param name="builder">Builder key (first part of the key)</param>
        /// <param name="fingerprint">Dependency fingerprint created when the builder was executed (second part of the key)</param>
        /// <param name="outputs">Target-relative path of the build outputs to be cached</param>
        /// <param name="targetRoot">File system abstraction of the root target directory</param>
        public void Store(BuildKey builder, IDependencyFingerprint fingerprint, IEnumerable<TargetRelativePath> outputs, IFileSystemDirectory targetRoot)
        {
            MemoryCacheItem item = GetOrCreate(builder);            

            var map = new ConcurrentDictionary<TargetRelativePath, byte[]>();

            Parallel.ForEach(outputs, outputPath =>
                {
                    if (targetRoot.Exists(outputPath))
                    {
                        using (var stream = targetRoot.ReadBinaryFile(outputPath))
                        {
                            var buf = new byte[stream.Length];
                            stream.Read(buf, 0, buf.Length);

                            map.TryAdd(outputPath, buf);
                        }
                    }
                    else
                    {
                        map.TryAdd(outputPath, null);
                    }
                });
            
            item.Update(fingerprint, map);
        }
示例#10
0
        protected MapleFileSystemBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent, IMessenger messenger)
            : this(messenger)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name), $"{nameof(name)} {Resources.IsRequired}");
            }

            if (string.IsNullOrEmpty(fullName))
            {
                throw new ArgumentNullException(nameof(fullName), $"{nameof(fullName)} {Resources.IsRequired}");
            }

            if (depth == null)
            {
                throw new ArgumentNullException(nameof(depth), $"{nameof(depth)} {Resources.IsRequired}");
            }

            if (!(this is IFileSystemDrive) && parent == null)
            {
                throw new ArgumentNullException(nameof(parent), $"{nameof(parent)} {Resources.IsRequired}");
            }

            using (BusyStack.GetToken())
            {
                Depth = depth;
                Depth.Current++;

                Name     = name;
                FullName = fullName;
                Parent   = parent;
            }
        }
示例#11
0
 /// <summary>
 /// Constructs the builder
 /// </summary>
 /// <param name="nuget">Interface to the NuGet package manager</param>
 /// <param name="targetRoot">Target root directory</param>
 /// <param name="output">User output interface</param>
 /// <param name="project">The project his reference belong sto</param>
 public NugetReferenceBuilder(INuGet nuget, [TargetRoot] IFileSystemDirectory targetRoot, IUserOutput output, Project project)
 {
     this.nuget = nuget;
     this.targetRoot = targetRoot;
     this.output = output;
     this.project = project;
 }
示例#12
0
 /// <summary>
 /// Constructs the command
 /// </summary>
 /// <param name="targetRoot">Target root directory</param>
 /// <param name="extensions">Additional cleaning steps to be performed </param>
 /// <param name="output">User interface output interface</param>
 /// <param name="predicates">Soft clean predicate registry</param>
 public CleanCommand([TargetRoot] IFileSystemDirectory targetRoot, IEnumerable <ICleanExtension> extensions, IUserOutput output, ISoftCleanPredicates predicates)
 {
     this.targetRoot = targetRoot;
     this.extensions = extensions;
     this.output     = output;
     this.predicates = predicates;
 }
示例#13
0
 public AddonSupportSolutionItemProvider([TargetRoot] IFileSystemDirectory targetRoot, Suite suite, [Current] ICommand currentCommand, ICommandTargetParser targetParser)
 {
     this.targetRoot     = targetRoot;
     this.suite          = suite;
     this.currentCommand = currentCommand;
     this.targetParser   = targetParser;
 }
 public AddonSupportSolutionItemProvider([TargetRoot] IFileSystemDirectory targetRoot, Suite suite, [Current] ICommand currentCommand, ICommandTargetParser targetParser)
 {
     this.targetRoot = targetRoot;
     this.suite = suite;
     this.currentCommand = currentCommand;
     this.targetParser = targetParser;
 }
示例#15
0
 /// <summary>
 /// Constructs the command
 /// </summary>
 /// <param name="suiteRoot">Suite root directory</param>
 /// <param name="targetRoot">Target root directory</param>
 /// <param name="extensions">Additional cleaning steps to be performed </param>
 /// <param name="output">User interface output interface</param>
 public CleanCommand([SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot, IEnumerable<ICleanExtension> extensions, IUserOutput output)
 {
     this.suiteRoot = suiteRoot;
     this.targetRoot = targetRoot;
     this.extensions = extensions;
     this.output = output;
 }
示例#16
0
        /// <summary>
        /// Runs the external tool with the given parameters
        /// </summary>
        /// <param name="root">Working directory</param>
        /// <param name="args">Process parameters</param>
        /// <returns>Returns <c>true</c> if the process' exit code was 0</returns>
        public bool Run(IFileSystemDirectory root, params string[] args)
        {
            EnsureToolAvailable();

            var localRoot = root as LocalFileSystemDirectory;
            if (localRoot != null)
            {
                string path = ToolPath;

                var psi = new ProcessStartInfo
                {
                    FileName = path,
                    WorkingDirectory = localRoot.AbsolutePath,
                    Arguments = String.Join(" ", args),
                    UseShellExecute = false
                };

                log.DebugFormat("Executing {0} with arguments {1}", path, psi.Arguments);

                using (var process = System.Diagnostics.Process.Start(psi))
                {
                    process.WaitForExit();
                    
                    log.DebugFormat("Exit code: {0}", process.ExitCode);
                    return process.ExitCode == 0;
                }
            }
            else
            {
                throw new NotSupportedException("Only local file system is supported for " + name + "!");
            }
        }
示例#17
0
        /// <summary>
        /// Gets the relative path from this directory to another directory (in any depth)
        /// 
        /// <para>If the given argument is not a child of this directory, an <see cref="ArgumentException"/>will
        /// be thrown.</para>
        /// </summary>
        /// <param name="childDirectory">The child directory to get path to</param>
        /// <returns>Returns the path</returns>
        public string GetRelativePath(IFileSystemDirectory childDirectory)
        {
            var testChild = childDirectory as TestFileSystemDirectory;
            if (testChild != null)
            {
                var dirs = new List<TestFileSystemDirectory>();
                TestFileSystemDirectory current = testChild;
                while (current != this)
                {
                    dirs.Add(current);
                    current = current.parent;
                }

                dirs.Reverse();

                var result = new StringBuilder();
                for (int i = 0; i < dirs.Count; i++)
                {
                    if (i > 0)
                        result.Append("\\");

                    result.Append(dirs[i].Name);
                }

                return result.ToString();
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#18
0
        protected MapleFileSystemBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent) : this()
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException($"{nameof(Name)} can't be empty.", nameof(Name));
            }

            if (string.IsNullOrEmpty(fullName))
            {
                throw new ArgumentException($"{nameof(FullName)} can't be empty.", nameof(FullName));
            }

            if (depth == null)
            {
                throw new ArgumentException($"{nameof(Depth)} can't be empty.", nameof(Depth));
            }

            if (!(this is IFileSystemDrive) && parent == null)
            {
                throw new ArgumentException($"{nameof(Parent)} can't be empty.", nameof(Parent));
            }

            using (_busyStack.GetToken())
            {
                Depth = depth;
                Depth.Current++;

                Name     = name;
                FullName = fullName;
                Parent   = parent;
            }
        }
示例#19
0
 /// <summary>
 /// Initializes the class
 /// </summary>
 /// <param name="suite">Active suite</param>
 /// <param name="projectGuidManagement">Project GUID management service</param>
 /// <param name="sourceSetName">Source set name</param>
 /// <param name="targetDir">Target directory where the compiled files will be placed</param>
 public ReferencesSection(Suite suite, IProjectGuidManagement projectGuidManagement, string sourceSetName, [TargetRoot] IFileSystemDirectory targetDir)
     : base(suite)
 {
     this.projectGuidManagement = projectGuidManagement;
     this.sourceSetName         = sourceSetName;
     this.targetDir             = targetDir;
 }
示例#20
0
 public RebuildCommand([Named("clean")] ICommand cleanCommand, [Named("build")] ICommand buildCommand, [TargetRoot] IFileSystemDirectory targetRoot, [CacheRoot] IFileSystemDirectory cacheRoot)
 {
     this.cleanCommand = cleanCommand;
     this.buildCommand = buildCommand;
     this.targetRoot = targetRoot;
     this.cacheRoot = cacheRoot;
 }
示例#21
0
 /// <summary>
 /// Constructs the command
 /// </summary>
 /// <param name="targetRoot">Target root directory</param>
 /// <param name="extensions">Additional cleaning steps to be performed </param>
 /// <param name="output">User interface output interface</param>
 /// <param name="predicates">Soft clean predicate registry</param>
 public CleanCommand([TargetRoot] IFileSystemDirectory targetRoot, IEnumerable<ICleanExtension> extensions, IUserOutput output, ISoftCleanPredicates predicates)
 {
     this.targetRoot = targetRoot;
     this.extensions = extensions;
     this.output = output;
     this.predicates = predicates;
 }
示例#22
0
        public DefaultSuiteFactory(IParameters parameters, [SuiteRoot] IFileSystemDirectory suiteRoot, ICommandEnumerator commandEnumerator)
        {
            targetGoal     = parameters.Goal;
            this.suiteRoot = suiteRoot;

            ignoreTargetGoal = !commandEnumerator.NeedsExplicitTargetGoal(parameters.Command);
        }
示例#23
0
 public PropertiesSection(Suite suite, IProjectGuidManagement projectGuidManagement, [TargetRoot] IFileSystemDirectory targetDir, IProjectPlatformManagement platformManagement)
     : base(suite)
 {
     this.projectGuidManagement = projectGuidManagement;
     this.targetDir = targetDir;
     this.platformManagement = platformManagement;
 }
示例#24
0
        private ISet <TargetRelativePath> DeployDirectoryContents(IFileSystemDirectory depDir, string directoryPath, string subDir)
        {
            var result = new HashSet <TargetRelativePath>();

            //Files
            foreach (var file in repository.ListFiles(directoryPath))
            {
                var fileName = Path.GetFileName(file);
                repository.Copy(file, depDir, Path.Combine(subDir, fileName));
                result.Add(new TargetRelativePath(targetRoot.GetRelativePath(depDir), Path.Combine(subDir, fileName)));
            }

            //Child directories
            var directory = new LocalFileSystemDirectory(directoryPath);

            foreach (var childDirectory in directory.ChildDirectories)
            {
                var dir         = directory.GetChildDirectory(childDirectory);
                var dirContents = DeployDirectoryContents(depDir, dir.ToString(), Path.Combine(subDir, childDirectory));
                foreach (var path in dirContents)
                {
                    result.Add(path);
                }
            }

            return(result);
        }
示例#25
0
        /// <summary>
        /// Copies a source file to a target location, but only if it does not exist yet, with the same MD5 checksum
        /// as the source
        /// </summary>
        /// <param name="sourceDirectory">Source root directory</param>
        /// <param name="sourceFileName">Source file's relative path</param>
        /// <param name="targetRoot">Target root directory</param>
        /// <param name="targetRelativePath">Target file's relative path</param>
        private void CopyIfDifferent(IFileSystemDirectory sourceDirectory, string sourceFileName, IFileSystemDirectory targetRoot, string targetRelativePath)
        {
            bool copy       = true;
            long sourceSize = sourceDirectory.GetFileSize(sourceFileName);

            if (targetRoot.Exists(targetRelativePath))
            {
                long targetSize = targetRoot.GetFileSize(targetRelativePath);
                if (sourceSize == targetSize)
                {
                    var sourceChecksum = Task.Factory.StartNew(() => ComputeChecksum(md5a, sourceDirectory, sourceFileName));
                    var targetChecksum = Task.Factory.StartNew(() => ComputeChecksum(md5b, targetRoot, targetRelativePath));

                    copy = !sourceChecksum.Result.SequenceEqual(targetChecksum.Result);
                }
            }

            if (copy)
            {
                sourceDirectory.CopyFile(sourceFileName, targetRoot, targetRelativePath);
            }
            else
            {
                log.DebugFormat("File {0} is the same as the cached one", targetRelativePath);
            }
        }
示例#26
0
        /// <summary>
        /// Copies a source file to a target location, but only if it does not exist yet, with the same MD5 checksum
        /// as the source
        /// </summary>
        /// <param name="sourceDirectory">Source root directory</param>
        /// <param name="sourceFileName">Source file's relative path</param>
        /// <param name="targetRoot">Target root directory</param>
        /// <param name="targetRelativePath">Target file's relative path</param>
        private void CopyIfDifferent(IFileSystemDirectory sourceDirectory, string sourceFileName, IFileSystemDirectory targetRoot, string targetRelativePath)
        {
            bool copy       = true;
            long sourceSize = sourceDirectory.GetFileSize(sourceFileName);

            if (targetRoot.Exists(targetRelativePath))
            {
                long targetSize = targetRoot.GetFileSize(targetRelativePath);
                if (sourceSize == targetSize)
                {
                    byte[] sourceChecksum = ComputeChecksum(sourceDirectory, sourceFileName);
                    byte[] targetChecksum = ComputeChecksum(targetRoot, targetRelativePath);

                    copy = !sourceChecksum.SequenceEqual(targetChecksum);
                }
            }

            if (copy)
            {
                using (var source = sourceDirectory.ReadBinaryFile(sourceFileName))
                    using (var target = targetRoot.CreateBinaryFileWithDirectories(targetRelativePath))
                        StreamOperations.Copy(source, target);
            }
            else
            {
                log.DebugFormat("File {0} is the same as the cached one", targetRelativePath);
            }
        }
示例#27
0
        public void SetUp()
        {
            kernel = new StandardKernel();

            tmp = new TempDirectory();
            rootDir = new LocalFileSystemDirectory(tmp);
            using (var writer = rootDir.CreateTextFile("file1"))
                writer.WriteLine("Contents of file 1");
            using (var writer = rootDir.CreateTextFile("file2"))
                writer.WriteLine("Contents of file 2");

            sourceSet = new SourceSet("test");
            sourceSet.Add(new SuiteRelativePath("file1"));
            sourceSet.Add(new SuiteRelativePath("file2"));

            kernel.Bind<IFileSystemDirectory>().ToConstant(rootDir).WhenTargetHas<SuiteRootAttribute>();

            var factoryMock = new Mock<ISourceSetFingerprintFactory>();
            factoryMock.Setup(
                f =>
                f.CreateSourceSetFingerprint(It.IsAny<IEnumerable<SuiteRelativePath>>(), It.IsAny<Func<string, bool>>(), It.IsAny<bool>()))
                       .Returns<IEnumerable<SuiteRelativePath>, Func<string, bool>, bool>(
                            (files, exclusions, fullDependency) => new SourceSetFingerprint(rootDir, files, exclusions, fullDependency));
            fingerprintFactory = factoryMock.Object;
        }
示例#28
0
 /// <summary>
 /// Initializes the command
 /// </summary>
 /// <param name="buildContextFactory">Interface to create new build contexts</param>
 /// <param name="slnBuilderFactory">Interface to create new SLN builders</param>
 /// <param name="targetDir">Target root directory</param>
 /// <param name="targetParser">Parser used for parsing the target parameter</param>
 public VisualStudioCommand(IBuildContextFactory buildContextFactory, ISlnBuilderFactory slnBuilderFactory, [TargetRoot] IFileSystemDirectory targetDir, ICommandTargetParser targetParser)
 {
     this.buildContextFactory = buildContextFactory;
     this.slnBuilderFactory   = slnBuilderFactory;
     this.targetDir           = targetDir;
     this.targetParser        = targetParser;
 }
示例#29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppConfigBuilder"/> class.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="fingerprintFactory">The fingerprint factory</param>
 /// <param name="suiteRoot">Suite's root directory</param>
 /// <param name="targetRoot">Target root directory</param>
 public AppConfigBuilder(Project project, ISourceSetFingerprintFactory fingerprintFactory, [SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot)
 {
     this.project    = project;
     this.suiteRoot  = suiteRoot;
     this.targetRoot = targetRoot;
     dependencies    = new SourceSetDependencies(fingerprintFactory, project.GetSourceSet(appConfigSourceSetName));
 }
示例#30
0
        public void SetUp()
        {
            kernel = new StandardKernel();

            tmp     = new TempDirectory();
            rootDir = new LocalFileSystemDirectory(tmp);
            using (var writer = rootDir.CreateTextFile("file1"))
                writer.WriteLine("Contents of file 1");
            using (var writer = rootDir.CreateTextFile("file2"))
                writer.WriteLine("Contents of file 2");

            sourceSet = new SourceSet("test");
            sourceSet.Add(new SuiteRelativePath("file1"));
            sourceSet.Add(new SuiteRelativePath("file2"));

            RebindRootDir();

            var factoryMock = new Mock <ISourceSetFingerprintFactory>();

            factoryMock.Setup(
                f =>
                f.CreateSourceSetFingerprint(It.IsAny <IEnumerable <SuiteRelativePath> >(), It.IsAny <Func <string, bool> >(), It.IsAny <bool>()))
            .Returns <IEnumerable <SuiteRelativePath>, Func <string, bool>, bool>(
                (files, exclusions, fullDependency) => new SourceSetFingerprint(rootDir, files, exclusions, fullDependency));
            fingerprintFactory = factoryMock.Object;
        }
示例#31
0
        /// <summary>
        /// Restores the stored files for a given builder to a file system directory
        ///
        /// <para>The cache only stores the latest stored results and this is what will be restored
        /// to the target directory. To verify if it was generated with the correct dependency fingerprint,
        /// use <see cref="IBuildCache.Contains"/>.</para>
        /// <para>To ensure thread safety, use <see cref="IBuildCache.LockForBuilder"/>.</para>
        /// </summary>
        /// <param name="builder">Builder key</param>
        /// <param name="targetRoot">Target file system directory</param>
        /// <returns>Returns the target root relative paths of all the restored files</returns>
        public ISet <TargetRelativePath> Restore(BuildKey builder, IFileSystemDirectory targetRoot)
        {
            MemoryCacheItem item;

            lock (cache)
                cache.TryGetValue(builder, out item);

            if (item != null)
            {
                var outputs = item.Outputs;
                var paths   = new HashSet <TargetRelativePath>();
                foreach (var pair in outputs)
                {
                    if (pair.Value != null)
                    {
                        using (var stream = targetRoot.CreateBinaryFile(pair.Key))
                            stream.Write(pair.Value, 0, pair.Value.Length);
                    }

                    paths.Add(pair.Key);
                }

                return(paths);
            }
            else
            {
                return(new HashSet <TargetRelativePath>());
            }
        }
示例#32
0
 /// <summary>
 /// Constructs the test command
 /// </summary>
 /// <param name="buildContextFactory">Factory interface to create build contexts</param>
 /// <param name="targetRoot">Target file system directory</param>
 /// <param name="projectBuilders">Available project builders</param>
 /// <param name="testRunners">Available test runners</param>
 public TestCommand(IBuildContextFactory buildContextFactory, [TargetRoot] IFileSystemDirectory targetRoot, IEnumerable <IProjectBuilderFactory> projectBuilders, IEnumerable <ITestRunner> testRunners)
 {
     this.buildContextFactory = buildContextFactory;
     this.targetRoot          = targetRoot;
     this.projectBuilders     = projectBuilders;
     this.testRunners         = testRunners;
 }
示例#33
0
 /// <summary>
 /// Initializes the class
 /// </summary>
 /// <param name="suite">Active suite</param>
 /// <param name="projectGuidManagement">Project GUID management service</param>
 /// <param name="sourceSetName">Source set name</param>
 /// <param name="targetDir">Target directory where the compiled files will be placed</param>
 public ReferencesSection(Suite suite, IProjectGuidManagement projectGuidManagement, string sourceSetName, [TargetRoot] IFileSystemDirectory targetDir)
     : base(suite)
 {
     this.projectGuidManagement = projectGuidManagement;
     this.sourceSetName = sourceSetName;
     this.targetDir = targetDir;
 }
示例#34
0
 public DefaultPluginLoader(IReferenceBuilderFactory referenceBuilderFactory, IBuildContextFactory buildContextFactory, [SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot)
 {
     this.referenceBuilderFactory = referenceBuilderFactory;
     this.buildContextFactory     = buildContextFactory;
     this.suiteRoot  = suiteRoot;
     this.targetRoot = targetRoot;
 }
示例#35
0
        /// <summary>
        /// Runs the external tool with the given parameters
        /// </summary>
        /// <param name="root">Working directory</param>
        /// <param name="args">Process parameters</param>
        /// <returns>Returns <c>true</c> if the process' exit code was 0</returns>
        public bool Run(IFileSystemDirectory root, params string[] args)
        {
            EnsureToolAvailable();

            var localRoot = root as LocalFileSystemDirectory;

            if (localRoot != null)
            {
                string path = ToolPath;

                var psi = new ProcessStartInfo
                {
                    FileName         = path,
                    WorkingDirectory = localRoot.AbsolutePath,
                    Arguments        = String.Join(" ", args),
                    UseShellExecute  = false
                };

                log.DebugFormat("Executing {0} with arguments {1}", path, psi.Arguments);

                using (var process = System.Diagnostics.Process.Start(psi))
                {
                    process.WaitForExit();

                    log.DebugFormat("Exit code: {0}", process.ExitCode);
                    return(process.ExitCode == 0);
                }
            }
            else
            {
                throw new NotSupportedException("Only local file system is supported for " + name + "!");
            }
        }
示例#36
0
 /// <summary>
 /// Constructs the test command
 /// </summary>
 /// <param name="buildContextFactory">Factory interface to create build contexts</param>
 /// <param name="targetRoot">Target file system directory</param>
 /// <param name="projectBuilders">Available project builders</param>
 /// <param name="testRunners">Available test runners</param>
 public TestCommand(IBuildContextFactory buildContextFactory, [TargetRoot] IFileSystemDirectory targetRoot, IEnumerable<IProjectBuilderFactory> projectBuilders, IEnumerable<ITestRunner> testRunners)
 {
     this.buildContextFactory = buildContextFactory;
     this.targetRoot = targetRoot;
     this.projectBuilders = projectBuilders;
     this.testRunners = testRunners;
 }
示例#37
0
 /// <summary>
 /// Initializes the command
 /// </summary>
 /// <param name="buildContextFactory">Interface to create new build contexts</param>
 /// <param name="targetDir">Target root directory</param>
 /// <param name="targetParser">Parser used for parsing the target parameter</param>
 public VisualStudioCommand(IBuildContextFactory buildContextFactory, [TargetRoot] IFileSystemDirectory targetDir, ICommandTargetParser targetParser, ICoreBuilderFactory coreBuilderFactory, IEnumerable<IProjectBuilderFactory> projectBuilders)
 {
     this.buildContextFactory = buildContextFactory;
     this.targetDir = targetDir;
     this.targetParser = targetParser;
     this.coreBuilderFactory = coreBuilderFactory;
     this.projectBuilders = projectBuilders;
 }
示例#38
0
 /// <summary>
 /// Goes through all the subdirectories of a project and interprets them as source sets
 /// </summary>
 /// <param name="project">The project to be extended with source sets</param>
 /// <param name="projectDir">The project's directory</param>
 private void DiscoverProjectSources(Project project, IFileSystemDirectory projectDir)
 {
     foreach (var sourceSetName in projectDir.ChildDirectories)
     {
         var sourceSet = project.GetSourceSet(sourceSetName);
         AddAllFiles(sourceSet, projectDir.GetChildDirectory(sourceSetName));
     }
 }
 /// <summary>
 /// Copies a file from the FS repository to a given target directory
 /// </summary>
 /// <param name="path">Path to the file in the FS repository</param>
 /// <param name="targetDir">Target directory</param>
 /// <param name="targetFileName">Target file name</param>
 public void Copy(string path, IFileSystemDirectory targetDir, string targetFileName)
 {
     using (var source = GetDirectory(path).ReadBinaryFile(Path.GetFileName(path)))
     using (var target = targetDir.CreateBinaryFile(targetFileName))
     {
         StreamOperations.Copy(source, target);
     }
 }
示例#40
0
        private void DeleteDirectory(IFileSystemDirectory directory, ICleanParameters parameters)
        {
            var predicates = predicatesFactory();

            if (parameters.SoftClean)
                directory.Delete(predicates.ShouldDelete);
            else
                directory.Delete();
        }
示例#41
0
        /// <summary>
        /// Initializes the GUID management service
        /// </summary>
        /// <param name="cacheRoot">Cache root directory</param>
        /// <param name="suite">Active suite</param>
        public DefaultProjectGuidManagement([CacheRoot] IFileSystemDirectory cacheRoot, Suite suite)
        {
            Contract.Requires(cacheRoot != null);
            Contract.Requires(suite != null);

            this.cacheRoot = cacheRoot;
            this.suite = suite;

            InitializeFromCache();
        }        
示例#42
0
文件: TestCommand.cs 项目: vigoo/bari
 /// <summary>
 /// Constructs the test command
 /// </summary>
 /// <param name="buildContextFactory">Factory interface to create build contexts</param>
 /// <param name="targetRoot">Target file system directory</param>
 /// <param name="projectBuilders">Available project builders</param>
 /// <param name="testRunners">Available test runners</param>
 /// <param name="output">Output interface for the dependency dump functionality</param>
 /// <param name="targetParser">User-given target string parser</param>
 /// <param name="coreBuilderFactory">Factory for core builder types</param>
 public TestCommand(IBuildContextFactory buildContextFactory, [TargetRoot] IFileSystemDirectory targetRoot, IEnumerable<IProjectBuilderFactory> projectBuilders, IEnumerable<ITestRunner> testRunners, IUserOutput output, ICommandTargetParser targetParser, ICoreBuilderFactory coreBuilderFactory)
 {
     this.buildContextFactory = buildContextFactory;
     this.targetRoot = targetRoot;
     this.projectBuilders = projectBuilders;
     this.testRunners = testRunners;
     this.output = output;
     this.targetParser = targetParser;
     this.coreBuilderFactory = coreBuilderFactory;
 }
示例#43
0
 /// <summary>
 /// Constructs the build command
 /// </summary>
 /// <param name="buildContextFactory">Interface for creating new build contexts</param>
 /// <param name="projectBuilders">The set of registered project builder factories</param>
 /// <param name="targetRoot">Build target root directory </param>
 /// <param name="targetParser">Command target parser implementation to be used</param>
 /// <param name="output">Output interface</param>
 /// <param name="postProcessorFactories">Factory for post processors</param>
 /// <param name="coreBuilderFactory">Factory for core builders</param>
 public BuildCommand(IBuildContextFactory buildContextFactory, IEnumerable<IProjectBuilderFactory> projectBuilders, [TargetRoot] IFileSystemDirectory targetRoot, ICommandTargetParser targetParser, IUserOutput output, IEnumerable<IPostProcessorFactory> postProcessorFactories, ICoreBuilderFactory coreBuilderFactory)
 {
     this.buildContextFactory = buildContextFactory;
     this.projectBuilders = projectBuilders;
     this.targetRoot = targetRoot;
     this.targetParser = targetParser;
     this.output = output;
     this.postProcessorFactories = postProcessorFactories;
     this.coreBuilderFactory = coreBuilderFactory;
 }
示例#44
0
 public InnoSetupCompiler([SuiteRoot] IFileSystemDirectory suiteRoot, [TargetRoot] IFileSystemDirectory targetRoot, IParameters parameters)
     : base("InnoSetup",
         Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Inno Setup 5"),
         "iscc.exe",
         new Uri("http://www.jrsoftware.org/download.php/ispack-unicode.exe"),
         false, parameters)
 {
     this.suiteRoot = suiteRoot;
     this.targetRoot = targetRoot;
 }
示例#45
0
        /// <summary>
        /// Creates a cached builder
        /// </summary>
        /// <param name="wrappedBuilder">The builder instance to be wrapped</param>
        /// <param name="cache">The cache implementation to be used</param>
        /// <param name="targetDir">The target directory's file system abstraction</param>
        public CachedBuilder(IBuilder wrappedBuilder, IBuildCache cache, [TargetRoot] IFileSystemDirectory targetDir)
        {
            Contract.Requires(wrappedBuilder != null);
            Contract.Requires(cache != null);
            Contract.Requires(targetDir != null);

            this.wrappedBuilder = wrappedBuilder;
            this.cache = cache;
            this.targetDir = targetDir;
        }
示例#46
0
 /// <summary>
 /// Constructs the project builder factory
 /// </summary>
 /// <param name="slnBuilderFactory">Interface for creating new SLN builders</param>
 /// <param name="msBuildRunnerFactory">Interface to create new MSBuild runners</param>
 /// <param name="referenceBuilderFactory">Interface to create new reference builders</param>
 /// <param name="targetRoot">Target root directory</param>
 /// <param name="analyzer">Suite content analyzer implementation</param>
 /// <param name="suite">The active suite</param>
 /// <param name="postProcessorFactories">List of registered post processor factories</param>
 public VsProjectBuilderFactory(ISlnBuilderFactory slnBuilderFactory, IMSBuildRunnerFactory msBuildRunnerFactory, IReferenceBuilderFactory referenceBuilderFactory, 
     [TargetRoot] IFileSystemDirectory targetRoot, ISuiteContentsAnalyzer analyzer, Suite suite, IEnumerable<IPostProcessorFactory> postProcessorFactories)
 {
     this.slnBuilderFactory = slnBuilderFactory;
     this.msBuildRunnerFactory = msBuildRunnerFactory;
     this.referenceBuilderFactory = referenceBuilderFactory;
     this.targetRoot = targetRoot;
     this.analyzer = analyzer;
     this.suite = suite;
     this.postProcessorFactories = postProcessorFactories;
 }
示例#47
0
 /// <summary>
 /// Constructs the project builder factory
 /// </summary>
 /// <param name="suite">The active suite</param>
 /// <param name="slnBuilderFactory">Interface for creating new SLN builders</param>
 /// <param name="msBuildRunnerFactory">Interface to create new MSBuild runners</param>
 /// <param name="referenceBuilderFactory">Interface to create new reference builders</param>
 /// <param name="targetRoot">Target root directory</param>
 /// <param name="postProcessorFactories">List of registered post processor factories</param>
 /// <param name="coreBuilderFactory">Factory to create core builder instances</param>
 public VsProjectBuilderFactory(Suite suite, ISlnBuilderFactory slnBuilderFactory, IMSBuildRunnerFactory msBuildRunnerFactory, IReferenceBuilderFactory referenceBuilderFactory, 
     [TargetRoot] IFileSystemDirectory targetRoot, IEnumerable<IPostProcessorFactory> postProcessorFactories, ICoreBuilderFactory coreBuilderFactory)
 {
     this.suite = suite;
     this.slnBuilderFactory = slnBuilderFactory;
     this.msBuildRunnerFactory = msBuildRunnerFactory;
     this.referenceBuilderFactory = referenceBuilderFactory;
     this.targetRoot = targetRoot;
     this.postProcessorFactories = postProcessorFactories;
     this.coreBuilderFactory = coreBuilderFactory;
 }
示例#48
0
        /// <summary>
        /// Recursively adds every file in a given directory to a source set (<see cref="SourceSet"/>)
        /// </summary>
        /// <param name="target">The target source set to be extended</param>
        /// <param name="dir">The root directory for the operation</param>
        private void AddAllFiles(SourceSet target, IFileSystemDirectory dir)
        {
            foreach (var fileName in dir.Files)
            {
                target.Add(new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName)));
            }

            foreach (var childDirectory in dir.ChildDirectories)
            {
                AddAllFiles(target, dir.GetChildDirectory(childDirectory));
            }
        }
示例#49
0
文件: NuGet.cs 项目: vigoo/bari
        public void CreatePackage(IFileSystemDirectory targetRoot, string packageName, string nuspec)
        {
            var localRoot = targetRoot as LocalFileSystemDirectory;
            if (localRoot != null)
            {
                var nuSpecName = packageName + ".nuspec";
                using (var writer = localRoot.CreateTextFile(nuSpecName))
                    writer.WriteLine(nuspec);

                Run(targetRoot, "pack", nuSpecName, "-Verbosity", Verbosity);
            }
        }
示例#50
0
文件: XBuild.cs 项目: zvrana/bari
 /// <summary>
 /// Runs MSBuild
 /// </summary>
 /// <param name="root">The root directory which will became MSBuild's root directory</param>
 /// <param name="relativePath">Relative path of the solution file (or MSBuild file) to be processed</param>
 public void Run(IFileSystemDirectory root, string relativePath)
 {
     var localRoot = root as LocalFileSystemDirectory;
     if (localRoot != null)
     {
         var absPath = Path.Combine(localRoot.AbsolutePath, relativePath);
         if (!Run(root, (Path.GetFileName(absPath) ?? String.Empty), "/nologo", "/verbosity:" + Verbosity, "/consoleloggerparameters:" + ConsoleLoggerParameters))
             throw new MSBuildFailedException();
     }
     else
     {
         throw new NotSupportedException("Only local file system is supported for MSBuild!");
     }
 }
示例#51
0
        public void SetUp()
        {
            cache = new MemoryBuildCache();
            T = new BuildKey(typeof(IBuilder), "test");
            root = new TestFileSystemDirectory("root");           

            fingerprint = new Mock<IDependencyFingerprint>();
            otherFingerprint = new Mock<IDependencyFingerprint>();

            fingerprint.Setup(f => f.Equals(fingerprint.Object)).Returns(true);
            fingerprint.Setup(f => f.Equals(otherFingerprint.Object)).Returns(false);

            otherFingerprint.Setup(f => f.Equals(fingerprint.Object)).Returns(false);
            otherFingerprint.Setup(f => f.Equals(otherFingerprint.Object)).Returns(true);
        }
示例#52
0
        /// <summary>
        /// Store build outputs in the cache by reading them from the file system
        /// </summary>
        /// <param name="builder">Builder key (first part of the key)</param>
        /// <param name="fingerprint">Dependency fingerprint created when the builder was executed (second part of the key)</param>
        /// <param name="outputs">Target-relative path of the build outputs to be cached</param>
        /// <param name="targetRoot">File system abstraction of the root target directory</param>
        public void Store(BuildKey builder, IDependencyFingerprint fingerprint, IEnumerable<TargetRelativePath> outputs, IFileSystemDirectory targetRoot)
        {
            var lck = GetOrCreateLock(builder);
            lck.EnterWriteLock();
            try
            {
                var cacheDir = cacheRoot.GetChildDirectory(GetCacheDirectoryName(builder), createIfMissing: true);

                SaveDependencyFingerprint(fingerprint, cacheDir);
                SaveOutputs(outputs, targetRoot, cacheDir);
            }
            finally
            {
                lck.ExitWriteLock();
            }
        }