예제 #1
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;
        }
예제 #2
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;
        }
예제 #3
0
        /// <summary>
        /// Copies output files to the cache directory, and also saves a '.names' file referring to he original target relative
        /// paths of these files.
        /// </summary>
        /// <param name="outputs">Build outputs to be copied</param>
        /// <param name="targetRoot">Root directory for the build outputs</param>
        /// <param name="cacheDir">Target directory for the copy operation</param>
        private void SaveOutputs(IEnumerable <TargetRelativePath> outputs, IFileSystemDirectory targetRoot, IFileSystemDirectory cacheDir)
        {
            using (var names = cacheDir.CreateTextFile(NamesFileName))
            {
                int idx = 0;
                foreach (var outputPath in outputs)
                {
                    try
                    {
                        // It is possible that the returned path is a special path and does not refer to an existing file
                        // In this case we only have to save the filename, without its contents
                        if (targetRoot.Exists(outputPath))
                        {
                            targetRoot.CopyFile(outputPath, cacheDir, idx.ToString(CultureInfo.InvariantCulture));
                        }

                        names.WriteLine("{0};{1}", outputPath.RelativeRoot, outputPath.RelativePath);
                        idx++;
                    }
                    catch (IOException ex)
                    {
                        log.WarnFormat("IOException while reading {0}: {1}", outputPath, ex.Message);

                        if (!outputPath.RelativePath.ToLowerInvariant().EndsWith(".vshost.exe"))
                        {
                            throw;
                        }
                    }
                }
            }
        }
예제 #4
0
 private void SaveToCache()
 {
     using (var writer = cacheRoot.CreateTextFile("guids"))
     {
         foreach (var pair in map)
         {
             string key   = pair.Key.Module.Name + "." + pair.Key.Name;
             string value = pair.Value.ToString("B");
             writer.WriteLine("{0}={1}", key, value);
         }
     }
 }
예제 #5
0
        public void AddingFileChangesFingerprint()
        {
            var dep = new SourceSetDependencies(fingerprintFactory, sourceSet);
            var fp1 = dep.CreateFingerprint();

            using (var writer = rootDir.CreateTextFile("file3"))
                writer.WriteLine("Contents of file 3");
            sourceSet.Add(new SuiteRelativePath("file3"));

            var fp2 = dep.CreateFingerprint();

            fp1.Should().NotBe(fp2);
        }
예제 #6
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)
        {
            string slnPath = Uid + ".sln";

            using (var sln = targetDir.CreateTextFile(slnPath))
            {
                var generator = new SlnGenerator(projectGuidManagement, projectPlatformManagement, supportedSlnProjects, projects, msBuildVersion, sln, suiteRoot, targetDir, GetInSolutionReferences, solutionItemProviders, Uid);
                generator.Generate();
            }

            return(new HashSet <TargetRelativePath> {
                new TargetRelativePath(String.Empty, slnPath)
            });
        }
예제 #7
0
        private TargetRelativePath GenerateAddonSupportFile(string solutionName)
        {
            string contents  = AddonSupportData();
            var    path      = new TargetRelativePath("", solutionName + ".yaml");
            bool   writeFile = true;

            if (targetRoot.Exists(path.RelativePath))
            {
                using (var reader = targetRoot.ReadTextFile(path.RelativePath))
                {
                    string existingContents = reader.ReadToEnd();
                    writeFile = existingContents != contents;
                }
            }

            if (writeFile)
            {
                using (var writer = targetRoot.CreateTextFile(path.RelativePath))
                    writer.WriteLine(contents);
            }

            return(path);
        }
예제 #8
0
        /// <summary>
        /// Copies output files to the cache directory, and also saves a '.names' file referring to he original target relative
        /// paths of these files.
        /// </summary>
        /// <param name="outputs">Build outputs to be copied</param>
        /// <param name="targetRoot">Root directory for the build outputs</param>
        /// <param name="cacheDir">Target directory for the copy operation</param>
        private void SaveOutputs(IEnumerable<TargetRelativePath> outputs, IFileSystemDirectory targetRoot, IFileSystemDirectory cacheDir)
        {
            using (var names = cacheDir.CreateTextFile(NamesFileName))
            {
                int idx = 0;
                foreach (var outputPath in outputs)
                {
                    try
                    {
                        // It is possible that the returned path is a special path and does not refer to an existing file
                        // In this case we only have to save the filename, without its contents
                        if (targetRoot.Exists(outputPath))
                        {
                            targetRoot.CopyFile(outputPath, cacheDir, idx.ToString(CultureInfo.InvariantCulture));
                        }

                        names.WriteLine("{0};{1}", outputPath.RelativeRoot, outputPath.RelativePath);
                        idx++;
                    }
                    catch (IOException ex)
                    {
                        log.WarnFormat("IOException while reading {0}: {1}", outputPath, ex.Message);

                        if (!outputPath.RelativePath.ToLowerInvariant().EndsWith(".vshost.exe"))
                            throw;
                    }
                }
            }
        }