public static IAppBuilder UseLightNuGetServer(
            this IAppBuilder app,
            HttpConfiguration config,
            LightNuGetServerSettings settings,
            Action <LightNuGetFeed[]> cfg = null)
        {
            Ensure.Any.IsNotNull(app, nameof(app));
            Ensure.Any.IsNotNull(config, nameof(config));
            Ensure.Any.IsNotNull(settings, nameof(settings));

            var logger = new SerilogProxyLogger(Log.Logger);

            foreach (var repo in settings.Repositories)
            {
                var feeds = repo.Feeds
                            .Select(fs => new LightNuGetFeed(fs, NuGetV2WebApiEnabler.CreatePackageRepository(Path.Combine(repo.PackagesDirPath, fs.Name), fs, logger)))
                            .ToArray();

                cfg?.Invoke(feeds);

                foreach (var feed in feeds)
                {
                    config.UseNuGetV2WebApiFeed(
                        routeName: feed.Name,
                        routeUrlRoot: feed.Slug,
                        oDatacontrollerName: "LightNuGetFeed");
                }
            }

            return(app);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var baseAddress = "http://*****:*****@"d:\omnishopcentraldata\Packages\Private", settingsProvider, logger);
            NuGetPublicRepository     = NuGetV2WebApiEnabler.CreatePackageRepository(@"d:\omnishopcentraldata\Packages\Public", settingsProvider, logger);
            NuGetVeryPublicRepository = NuGetV2WebApiEnabler.CreatePackageRepository(@"d:\omnishopcentraldata\Packages\VeryPublic", settingsProvider, logger);

            // Start OWIN host, which in turn will create a new instance of Startup class, and execute its Configuration method.
            using (WebApp.Start <Startup>(url: baseAddress))
            {
                Console.WriteLine("Server listening at baseaddress: " + baseAddress);
                Console.WriteLine("[ENTER] to close server");
                Console.ReadLine();
            }
        }
예제 #3
0
        private static IContainer CreateContainer()
        {
            string apiKey = ConfigurationManager.AppSettings["APIKEY"];
            string publishPackageRepository = ConfigurationManager.AppSettings["REPOSITORY"];
            string nuGetPublic = "NuGetPublic";

            // Set up a common settingsProvider to be used by all repositories.
            // If a setting is not present in dictionary default value will be used.
            var settings = new Dictionary <string, object>();

            settings.Add("enableDelisting", false);                         //default=false
            settings.Add("enableFrameworkFiltering", false);                //default=false
            settings.Add("ignoreSymbolsPackages", true);                    //default=false
            settings.Add("allowOverrideExistingPackageOnPush", true);       //default=true
            var settingsProvider = new DictionarySettingsProvider(settings);

            var logger = new ConsoleLogger();


            ContainerBuilder builder = new ContainerBuilder();

            Assembly assembly = Assembly.GetExecutingAssembly();

            // Enable Interceptor Logger you can use Class Attribute in  Controller such as [Intercept(typeof(InterceptLogger))]
            builder.RegisterApiControllers(assembly);

            //Sets up three repositories with seperate packages in each feed. These repositories are used by our controllers.
            //In a real world application the repositories will probably be inserted through DI framework, or created in the controllers constructor.
            //builder.Register(c => NuGetV2WebApiEnabler.CreatePackageRepository(PrivatePackageRepository, settingsProvider, logger))
            //    .Keyed<IServerPackageRepository>(NugetPrivate);
            builder.Register(c => NuGetV2WebApiEnabler.CreatePackageRepository(publishPackageRepository, settingsProvider, logger))
            .Keyed <IServerPackageRepository>(nuGetPublic);
            //builder.Register(c => NuGetV2WebApiEnabler.CreatePackageRepository(VeryPublishPackageRepository, settingsProvider, logger))
            //   .Keyed<IServerPackageRepository>(NuGetVeryPublic);

            builder.Register(c => new ApiKeyPackageAuthenticationService(true, apiKey)).As <IPackageAuthenticationService>()
            .InstancePerDependency();

            builder.RegisterType <NugetService>();


            // You can register controllers all at once using assembly scanning...
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

            var container = builder.Build();


            return(container);
        }
예제 #4
0
 public NuGetGatewayController() :
     base(NuGetV2WebApiEnabler.CreatePackageRepository("NuGetRepository"), new ApiKeyPackageAuthenticationService(false, null))
 {
 }