Пример #1
0
        public ISet <TargetRelativePath> Run(IBuildContext context)
        {
            var targetDir = targetRoot.CreateDirectory(project.RelativeTargetPath);

            if (targetDir == null)
            {
                targetDir = targetRoot.CreateDirectory(project.RelativeTargetPath);
            }

            var sourceSet = project.GetSourceSet("scr");
            var result    = new HashSet <TargetRelativePath>();

            foreach (var file in sourceSet.Files)
            {
                log.DebugFormat("Processing {0}", file);

                using (var reader = suiteRoot.ReadTextFile(file))
                {
                    var contents = reader.ReadToEnd();
                    var msg      = String.Format("Hello {0}!!!", contents);
                    var fileName = Path.GetFileName(file);

                    using (var writer = targetDir.CreateTextFile(fileName + ".txt"))
                        writer.WriteLine(msg);

                    result.Add(new TargetRelativePath(project.RelativeTargetPath, fileName + ".txt"));
                }
            }

            return(result);
        }
Пример #2
0
        /// <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 (reference == null)
            {
                throw new InvalidOperationException("FS repository reference was not set on the builder");
            }

            if (reference != null && resolutionContext == null)
            {
                ResolveReference();
            }

            if (output != null)
            {
                output.Message(String.Format("Resolving reference {0}", reference.Uri));
            }

            log.DebugFormat("Resolving reference {0} using {1}", reference.Uri, resolvedPath);

            var depsRoot = targetRoot.CreateDirectory("deps");
            var depDir   = depsRoot.CreateDirectory(resolutionContext.DependencyName);

            string fileName = resolutionContext.FileName + "." + resolutionContext.Extension;

            if (fileName == "*.*")
            {
                return(DeployDirectoryContents(depDir, Path.GetDirectoryName(resolvedPath), ""));
            }
            else
            {
                return(DeploySingleFile(depDir, fileName));
            }
        }
Пример #3
0
        /// <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));
        }
Пример #4
0
        /// <summary>
        /// Gets a child directory and optionally creates it if missing
        /// </summary>
        /// <param name="root">The root directory</param>
        /// <param name="childName">The name of the direct child directory</param>
        /// <param name="createIfMissing">If <c>true</c>, the child directory will be created if does not exist</param>
        /// <exception cref="ArgumentException">Thrown if the child directory does not exist and <c>createIfMissing</c> parameter is false</exception>
        /// <returns>Returns the file system abstraction of the child directory</returns>
        public static IFileSystemDirectory GetChildDirectory(this IFileSystemDirectory root, string childName, bool createIfMissing)
        {
            Contract.Requires(root != null);
            Contract.Requires(!String.IsNullOrWhiteSpace(childName));
            Contract.Ensures(Contract.Result <IFileSystemDirectory>() != null);

            if (root.ChildDirectories.Any(name => name.Equals(childName, StringComparison.InvariantCultureIgnoreCase)))
            {
                return(root.GetChildDirectory(childName));
            }
            else
            {
                if (createIfMissing)
                {
                    return(root.CreateDirectory(childName));
                }
                else
                {
                    throw new ArgumentException("The argument is not a child directory of this directory", "childName");
                }
            }
        }
Пример #5
0
        /// <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)
            }));
        }
Пример #6
0
        /// <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)
        {
            if (output != null)
            {
                output.Message(String.Format("Resolving reference {0}", reference.Uri));
            }

            log.DebugFormat("Resolving reference {0} using {1}", reference.Uri, resolvedPath);

            var depsRoot = targetRoot.CreateDirectory("deps");
            var depDir   = depsRoot.CreateDirectory(resolutionContext.DependencyName);

            string fileName = resolutionContext.FileName + "." + resolutionContext.Extension;

            if (fileName == "*.*")
            {
                return(DeployDirectoryContents(depDir));
            }
            else
            {
                return(DeploySingleFile(depDir, fileName));
            }
        }