From 509cb96329661ede60d516392c014eb8d521ac46 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sat, 18 Jan 2020 23:34:31 -0800 Subject: [PATCH 01/19] WIP - Upgrade dependencies. Controllers are broken currently --- BaGet.sln | 2 + nuget.config | 8 ++++ src/BaGet.Aws/BaGet.Aws.csproj | 2 +- src/BaGet.Azure/BaGet.Azure.csproj | 2 +- .../BaGet.Core.Server.csproj | 11 +++-- .../Extensions/IRouteBuilderExtensions.cs | 4 +- .../IServiceCollectionExtensions.cs | 11 +++-- src/BaGet.Core.Server/Routes.cs | 1 + src/BaGet.Core/BaGet.Core.csproj | 2 +- .../BaGet.Database.MySql.csproj | 2 +- .../BaGet.Database.PostgreSql.csproj | 4 +- .../BaGet.Database.SqlServer.csproj | 2 +- .../SqlServerContext.cs | 2 +- .../BaGet.Database.Sqlite.csproj | 2 +- src/BaGet.Gcp/BaGet.Gcp.csproj | 2 +- src/BaGet/BaGet.csproj | 21 +++------ .../IServiceCollectionExtensions.cs | 4 +- src/BaGet/Program.cs | 47 +++++++++++++++---- src/BaGet/Startup.cs | 19 ++------ src/Directory.Build.props | 6 +-- .../BaGet.Core.Tests/BaGet.Core.Tests.csproj | 12 ++--- .../BaGet.Protocol.Tests.csproj | 14 ++---- tests/BaGet.Tests/BaGet.Tests.csproj | 18 +++---- tests/Directory.Build.props | 22 +++++++++ 24 files changed, 130 insertions(+), 90 deletions(-) create mode 100644 nuget.config create mode 100644 tests/Directory.Build.props diff --git a/BaGet.sln b/BaGet.sln index 766d8fbbb..bf3fccce5 100644 --- a/BaGet.sln +++ b/BaGet.sln @@ -26,6 +26,8 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0B44364D-952B-497A-82E0-C9AAE94E0369}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + src\Directory.Build.props = src\Directory.Build.props + nuget.config = nuget.config EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaGet.Core.Server", "src\BaGet.Core.Server\BaGet.Core.Server.csproj", "{D68B56AC-98DD-4DA7-B4F8-1243538A8A5C}" diff --git a/nuget.config b/nuget.config new file mode 100644 index 000000000..6ce97590a --- /dev/null +++ b/nuget.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/BaGet.Aws/BaGet.Aws.csproj b/src/BaGet.Aws/BaGet.Aws.csproj index 0cc93fcfd..e394489fa 100644 --- a/src/BaGet.Aws/BaGet.Aws.csproj +++ b/src/BaGet.Aws/BaGet.Aws.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 NuGet;Amazon;Cloud The libraries to host BaGet on AWS. diff --git a/src/BaGet.Azure/BaGet.Azure.csproj b/src/BaGet.Azure/BaGet.Azure.csproj index 94bad3b91..30060afa5 100644 --- a/src/BaGet.Azure/BaGet.Azure.csproj +++ b/src/BaGet.Azure/BaGet.Azure.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 NuGet;Azure;Cloud The libraries to host BaGet on Azure. diff --git a/src/BaGet.Core.Server/BaGet.Core.Server.csproj b/src/BaGet.Core.Server/BaGet.Core.Server.csproj index 20dcb8cfd..c99a2bea5 100644 --- a/src/BaGet.Core.Server/BaGet.Core.Server.csproj +++ b/src/BaGet.Core.Server/BaGet.Core.Server.csproj @@ -1,14 +1,17 @@ - + - netstandard2.0;net461 + netcoreapp3.0 BaGet's NuGet server implementation - - + + + + + diff --git a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs b/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs index a83a0d6f4..2a172c9b3 100644 --- a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs @@ -49,9 +49,9 @@ public static IRouteBuilder MapSymbolRoutes(this IRouteBuilder routes) name: Routes.SymbolDownloadRouteName, template: "api/download/symbols/{file}/{key}/{file2}", defaults: new { controller = "Symbol", action = "Get" }); - + routes.MapRoute( - name: Routes.SymbolDownloadRouteName, + name: Routes.PrefixedSymbolDownloadRouteName, template: "api/download/symbols/{prefix}/{file}/{key}/{file2}", defaults: new { controller = "Symbol", action = "Get" }); diff --git a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs index 394059f05..610581ae3 100644 --- a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs @@ -13,16 +13,19 @@ public static class IServiceCollectionExtensions { public static IServiceCollection ConfigureHttpServices(this IServiceCollection services) { + // TODO: Consider replacing "AddMvc" with "AddControllers". + // See: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#mvc-service-registration + // TODO: Consider replacing "AddMvc" with Endpoint Routing + // See: options => options.EnableEndpointRouting = false services - .AddMvc() + .AddControllers(options => options.EnableEndpointRouting = false) .AddApplicationPart(typeof(BaGet.Controllers.PackageContentController).Assembly) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .AddJsonOptions(options => + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) + .AddNewtonsoftJson(options => { options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; }); - services.AddCors(); services.AddHttpContextAccessor(); services.AddSingleton, ConfigureCorsOptions>(); diff --git a/src/BaGet.Core.Server/Routes.cs b/src/BaGet.Core.Server/Routes.cs index ae5ac0b30..899a4423a 100644 --- a/src/BaGet.Core.Server/Routes.cs +++ b/src/BaGet.Core.Server/Routes.cs @@ -17,5 +17,6 @@ public class Routes public const string PackageDownloadManifestRouteName = "package-download-manifest"; public const string PackageDownloadReadmeRouteName = "package-download-readme"; public const string SymbolDownloadRouteName = "symbol-download"; + public const string PrefixedSymbolDownloadRouteName = "prefixed-symbol-download"; } } diff --git a/src/BaGet.Core/BaGet.Core.csproj b/src/BaGet.Core/BaGet.Core.csproj index 963a5f776..779a02ede 100644 --- a/src/BaGet.Core/BaGet.Core.csproj +++ b/src/BaGet.Core/BaGet.Core.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 The core libraries that power BaGet. diff --git a/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj b/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj index cb0d1891e..ac39bb3ab 100644 --- a/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj +++ b/src/BaGet.Database.MySql/BaGet.Database.MySql.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 diff --git a/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj b/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj index 262ac1eb1..856e40843 100644 --- a/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj +++ b/src/BaGet.Database.PostgreSql/BaGet.Database.PostgreSql.csproj @@ -1,11 +1,11 @@  - netstandard2.0;net461 + netcoreapp3.0 - + diff --git a/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj b/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj index b86a8ffe4..db2b3704b 100644 --- a/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj +++ b/src/BaGet.Database.SqlServer/BaGet.Database.SqlServer.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 diff --git a/src/BaGet.Database.SqlServer/SqlServerContext.cs b/src/BaGet.Database.SqlServer/SqlServerContext.cs index b7f34c1a0..3639b8cad 100644 --- a/src/BaGet.Database.SqlServer/SqlServerContext.cs +++ b/src/BaGet.Database.SqlServer/SqlServerContext.cs @@ -1,6 +1,6 @@ -using System.Data.SqlClient; using System.Linq; using BaGet.Core; +using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; namespace BaGet.Database.SqlServer diff --git a/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj b/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj index bb77aedd5..541d69c38 100644 --- a/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj +++ b/src/BaGet.Database.Sqlite/BaGet.Database.Sqlite.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 diff --git a/src/BaGet.Gcp/BaGet.Gcp.csproj b/src/BaGet.Gcp/BaGet.Gcp.csproj index 3e750aa92..24b7b2b85 100644 --- a/src/BaGet.Gcp/BaGet.Gcp.csproj +++ b/src/BaGet.Gcp/BaGet.Gcp.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net461 + netcoreapp3.0 NuGet;Google;Cloud The libraries to host BaGet on the Google Cloud Platform. diff --git a/src/BaGet/BaGet.csproj b/src/BaGet/BaGet.csproj index edd807a3a..fa398ca19 100644 --- a/src/BaGet/BaGet.csproj +++ b/src/BaGet/BaGet.csproj @@ -1,25 +1,18 @@ - + - netcoreapp2.2 + netcoreapp3.0 + + + $(NoWarn);MVC1005 ..\BaGet.UI\ $(DefaultItemExcludes);$(SpaRoot)node_modules\** - - - - - - - - - - - + @@ -28,9 +21,9 @@ + - diff --git a/src/BaGet/Extensions/IServiceCollectionExtensions.cs b/src/BaGet/Extensions/IServiceCollectionExtensions.cs index 0741feb96..f2dc78a8e 100644 --- a/src/BaGet/Extensions/IServiceCollectionExtensions.cs +++ b/src/BaGet/Extensions/IServiceCollectionExtensions.cs @@ -342,8 +342,8 @@ public static IServiceCollection AddMirrorServices(this IServiceCollection servi return client; }); - services.AddSingleton(); - services.AddSingleton(); + services.AddScoped(); + services.AddScoped(); return services; } diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index c867abccb..7b202f70c 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -1,13 +1,15 @@ using System; using System.Threading; +using System.Threading.Tasks; using BaGet.Core; using BaGet.Extensions; using McMaster.Extensions.CommandLineUtils; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; namespace BaGet { @@ -40,34 +42,61 @@ await provider app.OnExecute(() => { - CreateWebHostBuilder(args).Build().Run(); + var host = CreateWebHostBuilder(args).Build(); + + RunMigrationsAsync(host).GetAwaiter().GetResult(); + host.Run(); }); app.Execute(args); } - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseKestrel(options => + public static IHostBuilder CreateWebHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - // Remove the upload limit from Kestrel. If needed, an upload limit can - // be enforced by a reverse proxy server, like IIS. - options.Limits.MaxRequestBodySize = null; + webBuilder + .ConfigureKestrel(options => + { + // Remove the upload limit from Kestrel. If needed, an upload limit can + // be enforced by a reverse proxy server, like IIS. + options.Limits.MaxRequestBodySize = null; + }) + .UseStartup(); }) .ConfigureAppConfiguration((builderContext, config) => { var root = Environment.GetEnvironmentVariable("BAGET_CONFIG_ROOT"); if (!string.IsNullOrEmpty(root)) + { config.SetBasePath(root); + } }); public static IHostBuilder CreateHostBuilder(string[] args) { + // TODO: Merge 'CreateWebHostBuilder' and 'CreateHostBuilder' + // See: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#configuration return new HostBuilder() .ConfigureBaGetConfiguration(args) .ConfigureBaGetServices() .ConfigureBaGetLogging(); } + + private static async Task RunMigrationsAsync(IHost host) + { + // Run migrations if necessary. + var options = host.Services.GetRequiredService>(); + + if (options.Value.RunMigrationsAtStartup && options.Value.Database.Type != DatabaseType.AzureTable) + { + using (var scope = host.Services.CreateScope()) + { + var ctx = scope.ServiceProvider.GetRequiredService(); + + await ctx.Database.MigrateAsync(); + } + } + } } } diff --git a/src/BaGet/Startup.cs b/src/BaGet/Startup.cs index 91db5481f..b0fc71554 100644 --- a/src/BaGet/Startup.cs +++ b/src/BaGet/Startup.cs @@ -6,9 +6,9 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace BaGet { @@ -33,26 +33,17 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + var options = Configuration.Get(); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); } - // Run migrations if necessary. - var options = Configuration.Get(); - if (options.RunMigrationsAtStartup && options.Database.Type != DatabaseType.AzureTable) - { - using (var scope = app.ApplicationServices.CreateScope()) - { - scope.ServiceProvider - .GetRequiredService() - .Database - .Migrate(); - } - } + app.UseRouting(); app.UsePathBase(options.PathBase); app.UseForwardedHeaders(); diff --git a/src/Directory.Build.props b/src/Directory.Build.props index b33392b4d..7c50b3116 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -27,9 +27,9 @@ - 2.2.0 - 2.2.2 - 2.2.0 + 3.0.2 + 3.0.2 + 3.0.2 5.0.0-rtm.5856 diff --git a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj index 118b67b1e..78820ba3a 100644 --- a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj +++ b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj @@ -1,21 +1,17 @@  - netcoreapp2.2 - 7.1 - - false + netcoreapp3.0 - - - + + + all runtime; build; native; contentfiles; analyzers - diff --git a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj index b7bd2a388..e633d8895 100644 --- a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj +++ b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj @@ -1,21 +1,17 @@  - netcoreapp2.2 - 7.1 - - false + netcoreapp3.0 - - - + + + all runtime; build; native; contentfiles; analyzers - @@ -37,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/BaGet.Tests/BaGet.Tests.csproj b/tests/BaGet.Tests/BaGet.Tests.csproj index d375c7756..4bc67f7c5 100644 --- a/tests/BaGet.Tests/BaGet.Tests.csproj +++ b/tests/BaGet.Tests/BaGet.Tests.csproj @@ -1,27 +1,23 @@  - netcoreapp2.2 - 7.1 - - false + netcoreapp3.0 - + - - - + + + - - + + all runtime; build; native; contentfiles; analyzers - diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props new file mode 100644 index 000000000..1dec614f6 --- /dev/null +++ b/tests/Directory.Build.props @@ -0,0 +1,22 @@ + + + + 7.2 + false + + + + portable + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + + + + 3.0.2 + 4.10.0 + 12.0.2 + 5.0.0-rtm.5856 + 2.4.1 + + + From 6e2f939c3782ab78a35760adaeb874112465cf4e Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sat, 18 Jan 2020 23:42:27 -0800 Subject: [PATCH 02/19] Clean --- nuget.config | 1 - 1 file changed, 1 deletion(-) diff --git a/nuget.config b/nuget.config index 6ce97590a..fbcef1011 100644 --- a/nuget.config +++ b/nuget.config @@ -1,7 +1,6 @@ - From fd258035ef1fe3a3572b6f39d932ee1b74005aa5 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 19 Jan 2020 11:51:42 -0800 Subject: [PATCH 03/19] Fix routes --- .../Extensions/IRouteBuilderExtensions.cs | 20 +++++++++---------- .../IServiceCollectionExtensions.cs | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs b/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs index 2a172c9b3..12f63120a 100644 --- a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs @@ -11,7 +11,7 @@ public static IRouteBuilder MapServiceIndexRoutes(this IRouteBuilder routes) return routes.MapRoute( name: Routes.IndexRouteName, template: "v3/index.json", - defaults: new { controller = "ServiceIndex", action = "GetAsync" }); + defaults: new { controller = "ServiceIndex", action = "Get" }); } public static IRouteBuilder MapPackagePublishRoutes(this IRouteBuilder routes) @@ -63,18 +63,18 @@ public static IRouteBuilder MapSearchRoutes(this IRouteBuilder routes) routes.MapRoute( name: Routes.SearchRouteName, template: "v3/search", - defaults: new { controller = "Search", action = "SearchAsync" }); + defaults: new { controller = "Search", action = "Search" }); routes.MapRoute( name: Routes.AutocompleteRouteName, template: "v3/autocomplete", - defaults: new { controller = "Search", action = "AutocompleteAsync" }); + defaults: new { controller = "Search", action = "Autocomplete" }); // This is an unofficial API to find packages that depend on a given package. routes.MapRoute( name: Routes.DependentsRouteName, template: "v3/dependents", - defaults: new { controller = "Search", action = "DependentsAsync" }); + defaults: new { controller = "Search", action = "Dependents" }); return routes; } @@ -84,12 +84,12 @@ public static IRouteBuilder MapPackageMetadataRoutes(this IRouteBuilder routes) routes.MapRoute( name: Routes.RegistrationIndexRouteName, template: "v3/registration/{id}/index.json", - defaults: new { controller = "PackageMetadata", action = "RegistrationIndexAsync" }); + defaults: new { controller = "PackageMetadata", action = "RegistrationIndex" }); routes.MapRoute( name: Routes.RegistrationLeafRouteName, template: "v3/registration/{id}/{version}.json", - defaults: new { controller = "PackageMetadata", action = "RegistrationLeafAsync" }); + defaults: new { controller = "PackageMetadata", action = "RegistrationLeaf" }); return routes; } @@ -99,22 +99,22 @@ public static IRouteBuilder MapPackageContentRoutes(this IRouteBuilder routes) routes.MapRoute( name: Routes.PackageVersionsRouteName, template: "v3/package/{id}/index.json", - defaults: new { controller = "PackageContent", action = "GetPackageVersionsAsync" }); + defaults: new { controller = "PackageContent", action = "GetPackageVersions" }); routes.MapRoute( name: Routes.PackageDownloadRouteName, template: "v3/package/{id}/{version}/{idVersion}.nupkg", - defaults: new { controller = "PackageContent", action = "DownloadPackageAsync" }); + defaults: new { controller = "PackageContent", action = "DownloadPackage" }); routes.MapRoute( name: Routes.PackageDownloadManifestRouteName, template: "v3/package/{id}/{version}/{id2}.nuspec", - defaults: new { controller = "PackageContent", action = "DownloadNuspecAsync" }); + defaults: new { controller = "PackageContent", action = "DownloadNuspec" }); routes.MapRoute( name: Routes.PackageDownloadReadmeRouteName, template: "v3/package/{id}/{version}/readme", - defaults: new { controller = "PackageContent", action = "DownloadReadmeAsync" }); + defaults: new { controller = "PackageContent", action = "DownloadReadme" }); return routes; } diff --git a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs index 610581ae3..5dd89144e 100644 --- a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using BaGet.Configuration; +using BaGet.Controllers; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.AspNetCore.Http.Features; @@ -19,7 +20,7 @@ public static IServiceCollection ConfigureHttpServices(this IServiceCollection s // See: options => options.EnableEndpointRouting = false services .AddControllers(options => options.EnableEndpointRouting = false) - .AddApplicationPart(typeof(BaGet.Controllers.PackageContentController).Assembly) + .AddApplicationPart(typeof(PackageContentController).Assembly) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(options => { From 58a705076ba2e7f65aca821515ed7da526c9ae43 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 19 Jan 2020 12:19:41 -0800 Subject: [PATCH 04/19] Convert entry points to async; track EF Core 3.0 bug --- src/BaGet/BaGet.csproj | 2 +- src/BaGet/Program.cs | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/BaGet/BaGet.csproj b/src/BaGet/BaGet.csproj index fa398ca19..7741430e4 100644 --- a/src/BaGet/BaGet.csproj +++ b/src/BaGet/BaGet.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 7b202f70c..7125fedd4 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -15,7 +15,7 @@ namespace BaGet { public class Program { - public static void Main(string[] args) + public static async Task Main(string[] args) { var app = new CommandLineApplication { @@ -29,26 +29,26 @@ public static void Main(string[] args) { import.Command("downloads", downloads => { - downloads.OnExecute(async () => + downloads.OnExecuteAsync(async cancellationToken => { var provider = CreateHostBuilder(args).Build().Services; await provider .GetRequiredService() - .ImportAsync(CancellationToken.None); + .ImportAsync(cancellationToken); }); }); }); - app.OnExecute(() => + app.OnExecuteAsync(async cancellationToken => { var host = CreateWebHostBuilder(args).Build(); - RunMigrationsAsync(host).GetAwaiter().GetResult(); - host.Run(); + await RunMigrationsAsync(host, cancellationToken); + await host.RunAsync(cancellationToken); }); - app.Execute(args); + await app.ExecuteAsync(args); } public static IHostBuilder CreateWebHostBuilder(string[] args) => @@ -83,7 +83,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) .ConfigureBaGetLogging(); } - private static async Task RunMigrationsAsync(IHost host) + private static async Task RunMigrationsAsync(IHost host, CancellationToken cancellationToken) { // Run migrations if necessary. var options = host.Services.GetRequiredService>(); @@ -94,7 +94,10 @@ private static async Task RunMigrationsAsync(IHost host) { var ctx = scope.ServiceProvider.GetRequiredService(); - await ctx.Database.MigrateAsync(); + // TODO: An "InvalidOperationException" is thrown and caught due to a bug + // in EF Core 3.0. This is fixed in 3.1. + // See: https://github.com/dotnet/efcore/issues/18307 + await ctx.Database.MigrateAsync(cancellationToken); } } } From 2ef87b5992283ec7e68fb1302e9a57f9c20785f6 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 19 Jan 2020 19:31:54 -0800 Subject: [PATCH 05/19] Add endpoint routing --- ....cs => IEndpointRouteBuilderExtensions.cs} | 88 ++++++++----------- .../IServiceCollectionExtensions.cs | 2 +- src/BaGet/Startup.cs | 21 +++-- 3 files changed, 50 insertions(+), 61 deletions(-) rename src/BaGet.Core.Server/Extensions/{IRouteBuilderExtensions.cs => IEndpointRouteBuilderExtensions.cs} (58%) diff --git a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs b/src/BaGet.Core.Server/Extensions/IEndpointRouteBuilderExtensions.cs similarity index 58% rename from src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs rename to src/BaGet.Core.Server/Extensions/IEndpointRouteBuilderExtensions.cs index 12f63120a..fb5c888f6 100644 --- a/src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IEndpointRouteBuilderExtensions.cs @@ -4,119 +4,109 @@ namespace BaGet.Extensions { - public static class IRouteBuilderExtensions + public static class IEndpointRouteBuilderExtensions { - public static IRouteBuilder MapServiceIndexRoutes(this IRouteBuilder routes) + public static void MapServiceIndexRoutes(this IEndpointRouteBuilder endpoints) { - return routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.IndexRouteName, - template: "v3/index.json", + pattern: "v3/index.json", defaults: new { controller = "ServiceIndex", action = "Get" }); } - public static IRouteBuilder MapPackagePublishRoutes(this IRouteBuilder routes) + public static void MapPackagePublishRoutes(this IEndpointRouteBuilder endpoints) { - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.UploadPackageRouteName, - template: "api/v2/package", + pattern: "api/v2/package", defaults: new { controller = "PackagePublish", action = "Upload" }, constraints: new { httpMethod = new HttpMethodRouteConstraint("PUT") }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.DeleteRouteName, - template: "api/v2/package/{id}/{version}", + pattern: "api/v2/package/{id}/{version}", defaults: new { controller = "PackagePublish", action = "Delete" }, constraints: new { httpMethod = new HttpMethodRouteConstraint("DELETE") }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.RelistRouteName, - template: "api/v2/package/{id}/{version}", + pattern: "api/v2/package/{id}/{version}", defaults: new { controller = "PackagePublish", action = "Relist" }, constraints: new { httpMethod = new HttpMethodRouteConstraint("POST") }); - - return routes; } - public static IRouteBuilder MapSymbolRoutes(this IRouteBuilder routes) + public static void MapSymbolRoutes(this IEndpointRouteBuilder endpoints) { - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.UploadSymbolRouteName, - template: "api/v2/symbol", + pattern: "api/v2/symbol", defaults: new { controller = "Symbol", action = "Upload" }, constraints: new { httpMethod = new HttpMethodRouteConstraint("PUT") }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.SymbolDownloadRouteName, - template: "api/download/symbols/{file}/{key}/{file2}", + pattern: "api/download/symbols/{file}/{key}/{file2}", defaults: new { controller = "Symbol", action = "Get" }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.PrefixedSymbolDownloadRouteName, - template: "api/download/symbols/{prefix}/{file}/{key}/{file2}", + pattern: "api/download/symbols/{prefix}/{file}/{key}/{file2}", defaults: new { controller = "Symbol", action = "Get" }); - - return routes; } - public static IRouteBuilder MapSearchRoutes(this IRouteBuilder routes) + public static void MapSearchRoutes(this IEndpointRouteBuilder endpoints) { - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.SearchRouteName, - template: "v3/search", + pattern: "v3/search", defaults: new { controller = "Search", action = "Search" }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.AutocompleteRouteName, - template: "v3/autocomplete", + pattern: "v3/autocomplete", defaults: new { controller = "Search", action = "Autocomplete" }); // This is an unofficial API to find packages that depend on a given package. - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.DependentsRouteName, - template: "v3/dependents", + pattern: "v3/dependents", defaults: new { controller = "Search", action = "Dependents" }); - - return routes; } - public static IRouteBuilder MapPackageMetadataRoutes(this IRouteBuilder routes) + public static void MapPackageMetadataRoutes(this IEndpointRouteBuilder endpoints) { - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.RegistrationIndexRouteName, - template: "v3/registration/{id}/index.json", + pattern: "v3/registration/{id}/index.json", defaults: new { controller = "PackageMetadata", action = "RegistrationIndex" }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.RegistrationLeafRouteName, - template: "v3/registration/{id}/{version}.json", + pattern: "v3/registration/{id}/{version}.json", defaults: new { controller = "PackageMetadata", action = "RegistrationLeaf" }); - - return routes; } - public static IRouteBuilder MapPackageContentRoutes(this IRouteBuilder routes) + public static void MapPackageContentRoutes(this IEndpointRouteBuilder endpoints) { - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.PackageVersionsRouteName, - template: "v3/package/{id}/index.json", + pattern: "v3/package/{id}/index.json", defaults: new { controller = "PackageContent", action = "GetPackageVersions" }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.PackageDownloadRouteName, - template: "v3/package/{id}/{version}/{idVersion}.nupkg", + pattern: "v3/package/{id}/{version}/{idVersion}.nupkg", defaults: new { controller = "PackageContent", action = "DownloadPackage" }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.PackageDownloadManifestRouteName, - template: "v3/package/{id}/{version}/{id2}.nuspec", + pattern: "v3/package/{id}/{version}/{id2}.nuspec", defaults: new { controller = "PackageContent", action = "DownloadNuspec" }); - routes.MapRoute( + endpoints.MapControllerRoute( name: Routes.PackageDownloadReadmeRouteName, - template: "v3/package/{id}/{version}/readme", + pattern: "v3/package/{id}/{version}/readme", defaults: new { controller = "PackageContent", action = "DownloadReadme" }); - - return routes; } } } diff --git a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs index 5dd89144e..4afb9c171 100644 --- a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs @@ -19,7 +19,7 @@ public static IServiceCollection ConfigureHttpServices(this IServiceCollection s // TODO: Consider replacing "AddMvc" with Endpoint Routing // See: options => options.EnableEndpointRouting = false services - .AddControllers(options => options.EnableEndpointRouting = false) + .AddControllers() .AddApplicationPart(typeof(PackageContentController).Assembly) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(options => diff --git a/src/BaGet/Startup.cs b/src/BaGet/Startup.cs index b0fc71554..c1f8c9f30 100644 --- a/src/BaGet/Startup.cs +++ b/src/BaGet/Startup.cs @@ -43,24 +43,23 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseStatusCodePages(); } + app.UseSpaStaticFiles(); + app.UseRouting(); - app.UsePathBase(options.PathBase); app.UseForwardedHeaders(); - app.UseSpaStaticFiles(); - + app.UsePathBase(options.PathBase); app.UseCors(ConfigureCorsOptions.CorsPolicy); app.UseOperationCancelledMiddleware(); - app.UseMvc(routes => + app.UseEndpoints(endpoints => { - routes - .MapServiceIndexRoutes() - .MapPackagePublishRoutes() - .MapSymbolRoutes() - .MapSearchRoutes() - .MapPackageMetadataRoutes() - .MapPackageContentRoutes(); + endpoints.MapServiceIndexRoutes(); + endpoints.MapPackagePublishRoutes(); + endpoints.MapSymbolRoutes(); + endpoints.MapSearchRoutes(); + endpoints.MapPackageMetadataRoutes(); + endpoints.MapPackageContentRoutes(); }); app.UseSpa(spa => From e006f701ce074c9c9d8d4ad17eef9d8b03ccdf09 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Sun, 19 Jan 2020 21:54:17 -0800 Subject: [PATCH 06/19] Fix semver2 issues on display package page --- .../src/DisplayPackage/DisplayPackage.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/BaGet.UI/src/DisplayPackage/DisplayPackage.tsx b/src/BaGet.UI/src/DisplayPackage/DisplayPackage.tsx index 89114c706..bb4eb7076 100644 --- a/src/BaGet.UI/src/DisplayPackage/DisplayPackage.tsx +++ b/src/BaGet.UI/src/DisplayPackage/DisplayPackage.tsx @@ -2,7 +2,7 @@ import { Icon } from 'office-ui-fabric-react/lib/Icon'; import * as React from 'react'; import ReactMarkdown from 'react-markdown'; import timeago from 'timeago.js'; -import { coerce, gt, SemVer } from 'semver'; +import { coerce, eq, gt, SemVer } from 'semver'; import { config } from '../config'; import Dependencies from './Dependencies'; @@ -27,7 +27,6 @@ interface IDisplayPackageProps { interface IPackage { id: string; - latestVersion: string; hasReadme: boolean; description: string; readme: string; @@ -62,7 +61,7 @@ class DisplayPackage extends React.Component Date: Mon, 20 Jan 2020 15:39:17 -0800 Subject: [PATCH 07/19] Update runtime and SDK versions --- .azure/pipelines/ci-official.yml | 4 ++-- Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.azure/pipelines/ci-official.yml b/.azure/pipelines/ci-official.yml index ce45dd170..c8ac0aaac 100644 --- a/.azure/pipelines/ci-official.yml +++ b/.azure/pipelines/ci-official.yml @@ -40,9 +40,9 @@ jobs: vmImage: vs2017-win2016 steps: - task: DotNetCoreInstaller@0 - displayName: 'Use .NET Core SDK 2.2.100' + displayName: 'Use .NET Core SDK 3.0.X' inputs: - version: 2.2.100 + version: 3.0.x - task: Npm@1 displayName: Install frontend dependencies diff --git a/Dockerfile b/Dockerfile index 62e9cbad7..d418fa6a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base +FROM microsoft/dotnet:3.0-aspnetcore-runtime AS base WORKDIR /app EXPOSE 80 -FROM microsoft/dotnet:2.2-sdk AS build +FROM microsoft/dotnet:3.0-sdk AS build RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - RUN apt-get install -y nodejs WORKDIR /src From 489f12a59ee7d2ac0c92276bd874af7d182bc537 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 15:44:26 -0800 Subject: [PATCH 08/19] Fix? --- .azure/pipelines/ci-official.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure/pipelines/ci-official.yml b/.azure/pipelines/ci-official.yml index c8ac0aaac..2c24acd9a 100644 --- a/.azure/pipelines/ci-official.yml +++ b/.azure/pipelines/ci-official.yml @@ -40,9 +40,9 @@ jobs: vmImage: vs2017-win2016 steps: - task: DotNetCoreInstaller@0 - displayName: 'Use .NET Core SDK 3.0.X' + displayName: 'Use .NET Core SDK 3.0.102' inputs: - version: 3.0.x + version: 3.0.102 - task: Npm@1 displayName: Install frontend dependencies From e327370fcd679f603823d6d69b2f684165b9249e Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 15:54:34 -0800 Subject: [PATCH 09/19] Updates --- .azure/pipelines/ci-official.yml | 6 +++--- Dockerfile | 2 +- samples/BaGet.Protocol.Samples.Tests.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure/pipelines/ci-official.yml b/.azure/pipelines/ci-official.yml index 2c24acd9a..7a998dfe5 100644 --- a/.azure/pipelines/ci-official.yml +++ b/.azure/pipelines/ci-official.yml @@ -39,10 +39,10 @@ jobs: pool: vmImage: vs2017-win2016 steps: - - task: DotNetCoreInstaller@0 - displayName: 'Use .NET Core SDK 3.0.102' + - task: UseDotNet@2 + displayName: 'Use .NET Core SDK 3.0.X' inputs: - version: 3.0.102 + version: 3.0.x - task: Npm@1 displayName: Install frontend dependencies diff --git a/Dockerfile b/Dockerfile index d418fa6a5..7bac310a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ WORKDIR /app EXPOSE 80 FROM microsoft/dotnet:3.0-sdk AS build -RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - RUN apt-get install -y nodejs WORKDIR /src COPY /src . diff --git a/samples/BaGet.Protocol.Samples.Tests.csproj b/samples/BaGet.Protocol.Samples.Tests.csproj index dfb63b894..c02c49a32 100644 --- a/samples/BaGet.Protocol.Samples.Tests.csproj +++ b/samples/BaGet.Protocol.Samples.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.0 false IDE0007 From aedba2e6c3725469b0a3d9692ed781515bf116d0 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 16:01:33 -0800 Subject: [PATCH 10/19] Test? --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7bac310a1..82a21626b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM microsoft/dotnet:3.0-aspnetcore-runtime AS base WORKDIR /app EXPOSE 80 -FROM microsoft/dotnet:3.0-sdk AS build +FROM microsoft/dotnet:3.1-sdk AS build RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - RUN apt-get install -y nodejs WORKDIR /src From b23e2859b80233acefa942a386687f404091aef1 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 16:05:45 -0800 Subject: [PATCH 11/19] Clean --- .../Extensions/IHostExtensions.cs | 32 +++++++++++++++++++ src/BaGet/Program.cs | 21 +----------- 2 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 src/BaGet.Core.Server/Extensions/IHostExtensions.cs diff --git a/src/BaGet.Core.Server/Extensions/IHostExtensions.cs b/src/BaGet.Core.Server/Extensions/IHostExtensions.cs new file mode 100644 index 000000000..1314e23d6 --- /dev/null +++ b/src/BaGet.Core.Server/Extensions/IHostExtensions.cs @@ -0,0 +1,32 @@ +using System.Threading; +using System.Threading.Tasks; +using BaGet.Core; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; + +namespace BaGet.Extensions +{ + public static class IHostExtensions + { + public static async Task RunMigrationsAsync(this IHost host, CancellationToken cancellationToken) + { + // Run migrations if necessary. + var options = host.Services.GetRequiredService>(); + + if (options.Value.RunMigrationsAtStartup && options.Value.Database.Type != DatabaseType.AzureTable) + { + using (var scope = host.Services.CreateScope()) + { + var ctx = scope.ServiceProvider.GetRequiredService(); + + // TODO: An "InvalidOperationException" is thrown and caught due to a bug + // in EF Core 3.0. This is fixed in 3.1. + // See: https://github.com/dotnet/efcore/issues/18307 + await ctx.Database.MigrateAsync(cancellationToken); + } + } + } + } +} diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 7125fedd4..e74483abc 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -44,7 +44,7 @@ await provider { var host = CreateWebHostBuilder(args).Build(); - await RunMigrationsAsync(host, cancellationToken); + await host.RunMigrationsAsync(cancellationToken); await host.RunAsync(cancellationToken); }); @@ -82,24 +82,5 @@ public static IHostBuilder CreateHostBuilder(string[] args) .ConfigureBaGetServices() .ConfigureBaGetLogging(); } - - private static async Task RunMigrationsAsync(IHost host, CancellationToken cancellationToken) - { - // Run migrations if necessary. - var options = host.Services.GetRequiredService>(); - - if (options.Value.RunMigrationsAtStartup && options.Value.Database.Type != DatabaseType.AzureTable) - { - using (var scope = host.Services.CreateScope()) - { - var ctx = scope.ServiceProvider.GetRequiredService(); - - // TODO: An "InvalidOperationException" is thrown and caught due to a bug - // in EF Core 3.0. This is fixed in 3.1. - // See: https://github.com/dotnet/efcore/issues/18307 - await ctx.Database.MigrateAsync(cancellationToken); - } - } - } } } From 434417daeb56f8b0d2a972f83e9574f9bf06dcc8 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 16:12:59 -0800 Subject: [PATCH 12/19] WIP --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 82a21626b..89450422b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/dotnet:3.0-aspnetcore-runtime AS base +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/dotnet:3.1-sdk AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - RUN apt-get install -y nodejs WORKDIR /src From a31c600d100f762f5455fe988a1e2d9422536a4a Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 17:19:26 -0800 Subject: [PATCH 13/19] Work around EF Core 3 bug --- src/BaGet.Core/Search/DatabaseSearchService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet.Core/Search/DatabaseSearchService.cs b/src/BaGet.Core/Search/DatabaseSearchService.cs index 593e70850..83c7529af 100644 --- a/src/BaGet.Core/Search/DatabaseSearchService.cs +++ b/src/BaGet.Core/Search/DatabaseSearchService.cs @@ -214,8 +214,8 @@ IQueryable AddSearchFilters(IQueryable packageQuery) } var packageIds = search.Select(p => p.Id) - .OrderBy(id => id) .Distinct() + .OrderBy(id => id) .Skip(skip) .Take(take); From 15e2b1abc22d2601802f16250f77484d5e128e5e Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 17:28:42 -0800 Subject: [PATCH 14/19] Improve error message --- src/BaGet.Core/Storage/PackageStorageService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BaGet.Core/Storage/PackageStorageService.cs b/src/BaGet.Core/Storage/PackageStorageService.cs index f1c8f2521..8b887676e 100644 --- a/src/BaGet.Core/Storage/PackageStorageService.cs +++ b/src/BaGet.Core/Storage/PackageStorageService.cs @@ -62,7 +62,7 @@ public async Task SavePackageContentAsync( lowercasedNormalizedVersion, packagePath); - throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion}"); + throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion} due to conflict"); } // Store the package's nuspec. @@ -82,7 +82,7 @@ public async Task SavePackageContentAsync( lowercasedNormalizedVersion, nuspecPath); - throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion} nuspec"); + throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion} nuspec due to conflict"); } // Store the package's readme, if one exists. @@ -104,7 +104,7 @@ public async Task SavePackageContentAsync( lowercasedNormalizedVersion, readmePath); - throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion} readme"); + throw new InvalidOperationException($"Failed to store package {lowercasedId} {lowercasedNormalizedVersion} readme due to conflict"); } } From 95ad4a64d6c86dad90c6b4aafe848d16be00781e Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 17:30:54 -0800 Subject: [PATCH 15/19] Remove stale comment --- .../Extensions/IServiceCollectionExtensions.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs index 4afb9c171..eacef94a0 100644 --- a/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs +++ b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs @@ -14,10 +14,6 @@ public static class IServiceCollectionExtensions { public static IServiceCollection ConfigureHttpServices(this IServiceCollection services) { - // TODO: Consider replacing "AddMvc" with "AddControllers". - // See: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.1&tabs=visual-studio#mvc-service-registration - // TODO: Consider replacing "AddMvc" with Endpoint Routing - // See: options => options.EnableEndpointRouting = false services .AddControllers() .AddApplicationPart(typeof(PackageContentController).Assembly) From bb1b290ce9bf8caf5fa2d18878d851aae62f24ad Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 17:52:33 -0800 Subject: [PATCH 16/19] Show host logs by default --- src/BaGet/appsettings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BaGet/appsettings.json b/src/BaGet/appsettings.json index 0d51c3392..09f1283fc 100644 --- a/src/BaGet/appsettings.json +++ b/src/BaGet/appsettings.json @@ -31,6 +31,7 @@ }, "Console": { "LogLevel": { + "Microsoft.Hosting.Lifetime": "Information", "Default": "Warning" } } From 7d90d0325968bd570efda1047128f043284708eb Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 17:57:06 -0800 Subject: [PATCH 17/19] Remove stale warning suppression --- src/BaGet/BaGet.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/BaGet/BaGet.csproj b/src/BaGet/BaGet.csproj index 7741430e4..74045017a 100644 --- a/src/BaGet/BaGet.csproj +++ b/src/BaGet/BaGet.csproj @@ -3,9 +3,6 @@ netcoreapp3.0 - - $(NoWarn);MVC1005 - ..\BaGet.UI\ $(DefaultItemExcludes);$(SpaRoot)node_modules\** From f6eeb03db618593f8a4772dee67cc7401ca813f6 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 18:09:19 -0800 Subject: [PATCH 18/19] Bump version --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7c50b3116..089bde4bf 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,7 +3,7 @@ BaGet - 0.1.0-prerelease + 0.3.0-prerelease https://loic-sharma.github.io/BaGet/ MIT https://raw.githubusercontent.com/NuGet/Media/master/Images/MainLogo/256x256/nuget_256.png From dc51b37f1f3222dd1af93bf4115f084365006dd6 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 20 Jan 2020 18:30:49 -0800 Subject: [PATCH 19/19] Undo incorrect version change --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 089bde4bf..7c50b3116 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,7 +3,7 @@ BaGet - 0.3.0-prerelease + 0.1.0-prerelease https://loic-sharma.github.io/BaGet/ MIT https://raw.githubusercontent.com/NuGet/Media/master/Images/MainLogo/256x256/nuget_256.png