diff --git a/src/BaGet.Core/Configuration/BaGetOptions.cs b/src/BaGet.Core/Configuration/BaGetOptions.cs index 932c2681..c55c0183 100644 --- a/src/BaGet.Core/Configuration/BaGetOptions.cs +++ b/src/BaGet.Core/Configuration/BaGetOptions.cs @@ -1,11 +1,10 @@ -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace BaGet.Core { public class BaGetOptions { - /// + /// /// The API Key required to authenticate package /// operations. If empty, package operations do not require authentication. /// @@ -34,10 +33,16 @@ public class BaGetOptions public bool AllowPackageOverwrites { get; set; } = false; /// - /// If true, disables package pushing, deleting, and relisting. + /// If true, disables package pushing, deleting, and re-listing. /// public bool IsReadOnlyMode { get; set; } = false; + /// + /// The URLs the BaGet server will use. + /// As per documentation here (Server URLs). + /// + public string Urls { get; set; } + [Required] public DatabaseOptions Database { get; set; } diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 1d2f16a8..32c88394 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -1,8 +1,10 @@ +using System.IO; using System.Threading.Tasks; using BaGet.Core; using BaGet.Hosting; using McMaster.Extensions.CommandLineUtils; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -28,7 +30,6 @@ public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); var importer = host.Services.GetRequiredService(); - await importer.ImportAsync(cancellationToken); }); }); @@ -37,7 +38,6 @@ public static async Task Main(string[] args) app.OnExecuteAsync(async cancellationToken => { var host = CreateWebHostBuilder(args).Build(); - await host.RunMigrationsAsync(cancellationToken); await host.RunAsync(cancellationToken); }); @@ -56,6 +56,19 @@ public static IHostBuilder CreateWebHostBuilder(string[] args) => options.Limits.MaxRequestBodySize = null; }); + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: true) + .AddCommandLine(args) + .Build(); + + var urls = config["Urls"]; + + if (!string.IsNullOrWhiteSpace(urls)) + { + web.UseUrls(urls); + } + web.UseStartup(); }); diff --git a/src/BaGet/appsettings.json b/src/BaGet/appsettings.json index 09f1283f..cd2b5778 100644 --- a/src/BaGet/appsettings.json +++ b/src/BaGet/appsettings.json @@ -1,5 +1,6 @@ { "ApiKey": "", + "Urls": "http://*:5000", "PackageDeletionBehavior": "Unlist", "AllowPackageOverwrites": false,