Наследование: NAnt.Core.DataTypeBase
Пример #1
0
        protected override void ExecuteTask()
        {
            string dir = SolutionDir.FullName;
            string repositoryPath = GetRepositoryPathFromSolution(dir);

            _fileSystem = new PhysicalFileSystem(dir);
            RepositoryFactory = new PackageRepositoryFactory();
            SourceProvider = new PackageSourceProvider(new Settings(_fileSystem));
            var repo = RepositoryFactory.CreateRepository(repositoryPath);

            Log(Level.Debug, "Repo: {0}, Count: {1}", repo.Source, repo.GetPackages().Count());

            var fw = VersionUtility.ParseFrameworkName(Framework);
            List<string> files = new List<string>(), references = new List<string>();
            foreach (var deps in Dependencies)
            {
                foreach (var dep in deps.Dependencies)
                {
                    var package = repo.FindPackage(dep.Id, dep.VersionSpec, !String.IsNullOrWhiteSpace(dep.VersionSpec.MinVersion.SpecialVersion), false);
                    if (package == null)
                        package = repo.FindPackage(dep.Id, dep.VersionSpec, true, false);
                    if (package == null)
                        package = repo.FindPackage(dep.Id, dep.VersionSpec, true, true);
                    if (package == null)
                        throw new BuildException(String.Format("Can't find package {0} with min version {1}", dep.Id, dep.MinVersion), Location);

                    string pkgPath = Path.Combine(repositoryPath, package.Id + "." + package.Version);

                    var package_files = package.GetLibFiles().ToList();
                    IEnumerable<IPackageFile> compatible_files;
                    Log(Level.Debug, "Found package {0} with {1} file(s) - {2}", package.Id, package_files.Count, package.GetType());
                    if (!VersionUtility.TryGetCompatibleItems(fw, package_files, out compatible_files))
                        throw new BuildException("Couldn't get compatible files.");

                    foreach (var f in compatible_files)
                    {
                        var extension = Path.GetExtension(f.Path);
                        
                        var path = Path.Combine(pkgPath, f.Path);
                        Log(Level.Debug, "  - Found compatible file {1} ({0}) - {2}", f.Path, f.EffectivePath, path);
                        if (extension == ".dll" || extension == ".exe")
                            references.Add(path);
                        files.Add(path);
                    }
                }
            }

            if (FilesId != null)
            {
                PatternSet ps = new PatternSet();
                ps.Include.AddRange(files.Select(MakePattern).ToArray());
                Project.DataTypeReferences.Add(FilesId, ps);
            }
            if (ReferencesId != null)
            {
                PatternSet ps = new PatternSet();
                ps.Include.AddRange(references.Select(MakePattern).ToArray());
                Project.DataTypeReferences.Add(ReferencesId, ps);
            }

            Log(Level.Info, "Found {0} file(s) and {1} reference(s)", files.Count, references.Count);
        }
Пример #2
0
 public void Append(PatternSet patternSet)
 {
     string[] includePatterns = patternSet.GetIncludePatterns();
     foreach (string includePattern in includePatterns) {
         _include.Add(new Pattern(Project, includePattern));
     }
     string[] excludePatterns = patternSet.GetExcludePatterns();
     foreach (string excludePattern in excludePatterns) {
         _exclude.Add(new Pattern(Project, excludePattern));
     }
 }
Пример #3
0
 public void AddPatternSet(PatternSet patternSet)
 {
     Includes.AddRange(patternSet.GetIncludePatterns());
     Excludes.AddRange(patternSet.GetExcludePatterns());
 }
Пример #4
0
 public void AddPatternSet(PatternSet patternSet)
 {
     Includes.AddRange(patternSet.GetIncludePatterns());
     Excludes.AddRange(patternSet.GetExcludePatterns());
 }