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); }
private ISet <TargetRelativePath> DeployDirectoryContents(IFileSystemDirectory depDir) { var result = new HashSet <TargetRelativePath>(); foreach (var file in repository.ListFiles(Path.GetDirectoryName(resolvedPath))) { var fileName = Path.GetFileName(file); repository.Copy(file, depDir, fileName); result.Add(new TargetRelativePath(targetRoot.GetRelativePath(depDir), fileName)); } return(result); }
/// <summary> /// Runs this builder /// </summary> /// <param name="context">Current build context</param> /// <returns>Returns a set of generated files, in target relative paths</returns> public ISet <TargetRelativePath> Run(IBuildContext context) { var files = context.GetResults(sourceBuilder); var result = new HashSet <TargetRelativePath>(); foreach (var sourcePath in files) { log.DebugFormat("Copying result {0}...", sourcePath); var relativePath = sourcePath.RelativePath; Copy(sourcePath, relativePath); result.Add(new TargetRelativePath(targetRoot.GetRelativePath(targetDirectory), relativePath)); } return(result); }
public void Compile(SuiteRelativePath scriptPath, TargetRelativePath targetPath, string version, Goal targetGoal) { var platform = targetGoal.Has("x64") ? "x64" : "x86"; Run(suiteRoot, "/dVERSION=" + version, "/dPLATFORM=" + platform, "/dGOAL=" + targetGoal.Name, "/o" + Path.GetDirectoryName(Path.Combine(suiteRoot.GetRelativePath(targetRoot), targetPath)), scriptPath); }
private void CollectOutput(IFileSystemDirectory productRoot, string productName, IFileSystemDirectory dir, HashSet <TargetRelativePath> result) { foreach (var file in dir.Files) { result.Add(new TargetRelativePath(productName, Path.Combine(productRoot.GetRelativePath(dir), file))); } foreach (var childDir in dir.ChildDirectories) { CollectOutput(productRoot, productName, dir.GetChildDirectory(childDir), result); } }
/// <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)); } }
/// <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> /// <param name="ignoreList">Ignore list for the target source set</param> private void AddAllFiles(SourceSet target, IFileSystemDirectory dir, SourceSetIgnoreList ignoreList) { foreach (var fileName in dir.Files) { var suiteRelativePath = new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName)); if (!ignoreList.IsIgnored(suiteRelativePath)) { target.Add(suiteRelativePath); } } foreach (var childDirectory in dir.ChildDirectories) { AddAllFiles(target, dir.GetChildDirectory(childDirectory), ignoreList); } }
/// <summary> /// Runs this builder /// </summary> /// <param name="context"> </param> /// <returns>Returns a set of generated files, in target relative paths</returns> public override ISet<TargetRelativePath> Run(IBuildContext context) { if (output != null) output.Message(String.Format("Resolving reference {0}", reference.Uri)); string pkgName = reference.Uri.Host; string pkgVersion = reference.Uri.AbsolutePath.TrimStart('/'); var depsRoot = targetRoot.CreateDirectory("deps"); var depDir = depsRoot.CreateDirectory(pkgName); var files = nuget.InstallPackage(pkgName, pkgVersion, depDir, "", dllsOnly: reference.Type == ReferenceType.Build, maxProfile: GetMaxProfile()); var relativeRoot = Path.Combine(targetRoot.GetRelativePath(depDir), files.Item1); return new HashSet<TargetRelativePath>( from path in files.Item2 let relativePath = path.Substring(files.Item1.Length).TrimStart(Path.DirectorySeparatorChar) select new TargetRelativePath(relativeRoot, relativePath)); }
/// <summary> /// Gets the relative path from a given directory to given file in a larger common directory subtree. /// /// r.Object.GetRelativePathFrom(a.Object, @"a\c.txt").Should().Be(@"c.txt"); /// r.Object.GetRelativePathFrom(a.Object, @"a.test\e.txt").Should().Be(@"..\a.test\e.txt"); /// r.Object.GetRelativePathFrom(a.Object, @"b\d.txt").Should().Be(@"..\b\d.txt"); /// </summary> /// <example> /// Consider the following hierarchy: /// r /// -> a /// -> c.txt /// -> a.test /// -> e.txt /// -> b /// -> d.txt /// /// In this case: /// <c>r.GetRelativePathFrom(a, "a\c.txt")</c> is <c>c.txt</c> /// <c>r.GetRelativePathFrom(a, "a.test\e.txt")</c> is <c>..\a.test\e.txt</c> /// <c>r.GetRelativePathFrom(a, "b\d.txt")</c> is <c>..\b\d.txt</c> /// </example> /// <param name="root">The directory subtree which contains both <c>innerRoot</c> and <c>outerRelativePath</c></param> /// <param name="innerRoot">The directory to get the path relative to</param> /// <param name="outerRelativePath">The target path, relative to the <c>root</c> directory</param> /// <returns>Returns the relative path from <c>innerRoot</c> to <c>outerRelativePath</c> (which is specified as a relative path /// to <c>root</c>)</returns> public static string GetRelativePathFrom(this IFileSystemDirectory root, IFileSystemDirectory innerRoot, string outerRelativePath) { if (root == innerRoot) { return(outerRelativePath); } else { string innerFromOuter = root.GetRelativePath(innerRoot); if (outerRelativePath.StartsWith(innerFromOuter + '\\', StringComparison.InvariantCultureIgnoreCase)) { return(outerRelativePath.Substring(innerFromOuter.Length).TrimStart('\\')); } else { string prefix = String.Join("\\", innerFromOuter.Split('\\').Select(_ => "..")); return(Path.Combine(prefix, outerRelativePath)); } } }
/// <summary> /// Runs this builder /// </summary> /// <param name="context">Current build context</param> /// <returns>Returns a set of generated files, in target relative paths</returns> public override ISet <TargetRelativePath> Run(IBuildContext context) { if (output != null) { output.Message(String.Format("Resolving reference {0}", reference.Uri)); } var depsRoot = targetRoot.CreateDirectory("deps"); var sourcePath = reference.Uri.OriginalString.Substring(7).Replace('/', Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar); var fileName = Path.GetFileName(sourcePath); using (var source = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var target = depsRoot.CreateBinaryFile(sourcePath)) { StreamOperations.Copy(source, target); } return(new HashSet <TargetRelativePath>(new[] { new TargetRelativePath(targetRoot.GetRelativePath(depsRoot), fileName) })); }
public virtual string GetSuiteRelativeProjectFilePath(Project project) { string projectFileName = project.Name + ProjectFileExtension; return(Path.Combine(suiteRoot.GetRelativePath(project.RootDirectory.GetChildDirectory(SourceSetName)), projectFileName)); }
private void CollectOutput(IFileSystemDirectory productRoot, string productName, IFileSystemDirectory dir, HashSet<TargetRelativePath> result) { foreach (var file in dir.Files) { result.Add(new TargetRelativePath(productName, Path.Combine(productRoot.GetRelativePath(dir), file))); } foreach (var childDir in dir.ChildDirectories) CollectOutput(productRoot, productName, dir.GetChildDirectory(childDir), result); }