internal AssembliesDirectoryWatcher(ILifetimeScope lifetimeScope, CommandLineOptions options)
        {
            _options = options;
            watcher.IncludeSubdirectories = true;
            watcher.Filter = "*.dll";
            watcher.Path = options.Source;
            watcher.NotifyFilter = 
                NotifyFilters.CreationTime
                | NotifyFilters.DirectoryName
                | NotifyFilters.FileName
                | NotifyFilters.LastWrite
                | NotifyFilters.Size;
            watcher.Changed += watcher_Changed;
            watcher.Created += Watcher_Created;
            watcher.Deleted += Watcher_Deleted;
            watcher.Renamed += Watcher_Renamed;
            watcher.EnableRaisingEvents = true;
            Trace.TraceInformation("Start watching changes on {0}", options.Source);

            using (var scope = Program.Container.BeginLifetimeScope())
            {
                _cacheService = scope.Resolve<AssemblyCacheService>();
                _packageGroupService = scope.Resolve<NuGetPackageCreationService>();
            }
        }
 public DependenciesResolverService(AssemblyCacheService assemblyCacheService, MappingService mappingService, bool useCache, ResolutionLevelEnum resolutionLevel)
 {
     _assemblyCacheService = assemblyCacheService;
     _mappingService = mappingService;
     _useCache = useCache;
     _resolutionLevel = resolutionLevel;
 }
 public NuGetPackageCreationService(AssemblyCacheService assemblyCacheService, MappingService mappingService, ConfigurationService configurationService, DependenciesResolverService dependenciesResolverService, bool useCache,
                                   string repository, string credential, string owner,string author, string slackUrl, string slackChannel, string slackUsername)
 {
     _assemblyCacheService = assemblyCacheService;
     _mappingService = mappingService;
     _configurationService = configurationService;
     _dependenciesResolverService = dependenciesResolverService;
     _useCache = useCache;
     _repository = repository;
     _credential = credential;
     _owner = owner;
     _author = author;
     _slackUrl = slackUrl;
     _slackChannel = slackChannel;
     _slackUsername = slackUsername;
 }
Esempio n. 4
0
        public Tuple<SemanticVersion, string> GetNuGetPackage(AssemblyCacheService _service, Tuple<Version, string> name)
        {
            Configuration configuration = null;
            ConfigurationGetter configurationGetter = new ConfigurationGetter(new ConfigurationFileReader());
            
            //Try to see if some manual mapping is set on the dll directory
            var result = _service.Assemblies.Union(_service.IgnoredAssemblies);
            var groups = result.GroupBy(_ => _.Key.Item2);
            var assemblyVersions = groups.FirstOrDefault(_ => _.Key == name.Item2);

            if (assemblyVersions != null)
            {
                var sortedAssemblyVersions = assemblyVersions.Where(_ => _.Key.Item1.Version.Equals(name.Item1)).ToList();
                //No exact matching, let's find in a larger way
                if (!sortedAssemblyVersions.Any())
                    sortedAssemblyVersions = assemblyVersions.Where(_ => _.Key.Item1.Version >= name.Item1).ToList();
                //No exact matching, let's find in an even larger way
                if (!sortedAssemblyVersions.Any())
                    sortedAssemblyVersions = assemblyVersions.Where(_ => _.Key.Item1.Version.Major >= name.Item1.Major).ToList();
                sortedAssemblyVersions.Sort((pair, valuePair) => pair.Key.Item1.CompareTo(valuePair.Key.Item1));

                configuration = sortedAssemblyVersions.Aggregate(new Configuration(), (tmpConfiguration, pairs) =>
                            configurationGetter.Merge(tmpConfiguration, configurationGetter.Get(pairs.Value.Path)));
            }
            //Unable to find a dll name close to the package name, let's try to find in root .ini
            else
            {
                configuration = configurationGetter.Get(_rootPath);
                
            }

            var nugetPackage = configuration.NugetPackagesMapping.FirstOrDefault(_ => _.Item2.Regex.Match(name.Item2 + NuGetPackageCreationService.NugetSeparator + name.Item1).Success);
            if (nugetPackage!=null)
            {
                Trace.TraceInformation($"Manual configuration ask to used {nugetPackage.Item1} instead of {name.Item2}");
                return new Tuple<SemanticVersion, string>(nugetPackage.Item2.SemanticVersion??new SemanticVersion(name.Item1), nugetPackage.Item1);
            }

            //Try to see if it exist on nuget official repository
            var nuGetPackage = GetOfficialNuGetPackage(name);
            if (nuGetPackage != null)
                return nuGetPackage;

            Trace.TraceInformation($"No mapping information for {name.Item2}");
            return null;
        }