diff --git a/.azure/pipelines/ci-official.yml b/.azure/pipelines/ci-official.yml
index ce45dd170..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 2.2.100'
+ - task: UseDotNet@2
+ 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/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/Dockerfile b/Dockerfile
index 62e9cbad7..89450422b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,9 @@
-FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
+FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
-FROM microsoft/dotnet:2.2-sdk AS build
-RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
+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
COPY /src .
diff --git a/nuget.config b/nuget.config
new file mode 100644
index 000000000..fbcef1011
--- /dev/null
+++ b/nuget.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
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
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/IEndpointRouteBuilderExtensions.cs
similarity index 51%
rename from src/BaGet.Core.Server/Extensions/IRouteBuilderExtensions.cs
rename to src/BaGet.Core.Server/Extensions/IEndpointRouteBuilderExtensions.cs
index a83a0d6f4..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",
- defaults: new { controller = "ServiceIndex", action = "GetAsync" });
+ 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(
- name: Routes.SymbolDownloadRouteName,
- template: "api/download/symbols/{file}/{key}/{file2}",
- defaults: new { controller = "Symbol", action = "Get" });
-
- routes.MapRoute(
+ endpoints.MapControllerRoute(
name: Routes.SymbolDownloadRouteName,
- template: "api/download/symbols/{prefix}/{file}/{key}/{file2}",
+ pattern: "api/download/symbols/{file}/{key}/{file2}",
defaults: new { controller = "Symbol", action = "Get" });
- return routes;
+ endpoints.MapControllerRoute(
+ name: Routes.PrefixedSymbolDownloadRouteName,
+ pattern: "api/download/symbols/{prefix}/{file}/{key}/{file2}",
+ defaults: new { controller = "Symbol", action = "Get" });
}
- public static IRouteBuilder MapSearchRoutes(this IRouteBuilder routes)
+ public static void MapSearchRoutes(this IEndpointRouteBuilder endpoints)
{
- routes.MapRoute(
+ endpoints.MapControllerRoute(
name: Routes.SearchRouteName,
- template: "v3/search",
- defaults: new { controller = "Search", action = "SearchAsync" });
+ pattern: "v3/search",
+ defaults: new { controller = "Search", action = "Search" });
- routes.MapRoute(
+ endpoints.MapControllerRoute(
name: Routes.AutocompleteRouteName,
- template: "v3/autocomplete",
- defaults: new { controller = "Search", action = "AutocompleteAsync" });
+ 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",
- defaults: new { controller = "Search", action = "DependentsAsync" });
-
- return routes;
+ pattern: "v3/dependents",
+ defaults: new { controller = "Search", action = "Dependents" });
}
- 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",
- defaults: new { controller = "PackageMetadata", action = "RegistrationIndexAsync" });
+ 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",
- defaults: new { controller = "PackageMetadata", action = "RegistrationLeafAsync" });
-
- return routes;
+ pattern: "v3/registration/{id}/{version}.json",
+ defaults: new { controller = "PackageMetadata", action = "RegistrationLeaf" });
}
- 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",
- defaults: new { controller = "PackageContent", action = "GetPackageVersionsAsync" });
+ 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",
- defaults: new { controller = "PackageContent", action = "DownloadPackageAsync" });
+ 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",
- defaults: new { controller = "PackageContent", action = "DownloadNuspecAsync" });
+ 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",
- defaults: new { controller = "PackageContent", action = "DownloadReadmeAsync" });
-
- return routes;
+ pattern: "v3/package/{id}/{version}/readme",
+ defaults: new { controller = "PackageContent", action = "DownloadReadme" });
}
}
}
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.Core.Server/Extensions/IServiceCollectionExtensions.cs b/src/BaGet.Core.Server/Extensions/IServiceCollectionExtensions.cs
index 394059f05..eacef94a0 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;
@@ -14,15 +15,14 @@ public static class IServiceCollectionExtensions
public static IServiceCollection ConfigureHttpServices(this IServiceCollection services)
{
services
- .AddMvc()
- .AddApplicationPart(typeof(BaGet.Controllers.PackageContentController).Assembly)
- .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
- .AddJsonOptions(options =>
+ .AddControllers()
+ .AddApplicationPart(typeof(PackageContentController).Assembly)
+ .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.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);
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");
}
}
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.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
+
- netcoreapp2.2
+ netcoreapp3.0
..\BaGet.UI\
$(DefaultItemExcludes);$(SpaRoot)node_modules\**
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -28,9 +18,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..e74483abc 100644
--- a/src/BaGet/Program.cs
+++ b/src/BaGet/Program.cs
@@ -1,19 +1,21 @@
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
{
public class Program
{
- public static void Main(string[] args)
+ public static async Task Main(string[] args)
{
var app = new CommandLineApplication
{
@@ -27,43 +29,54 @@ 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 =>
{
- CreateWebHostBuilder(args).Build().Run();
+ var host = CreateWebHostBuilder(args).Build();
+
+ await host.RunMigrationsAsync(cancellationToken);
+ await host.RunAsync(cancellationToken);
});
- app.Execute(args);
+ await app.ExecuteAsync(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()
diff --git a/src/BaGet/Startup.cs b/src/BaGet/Startup.cs
index 91db5481f..c1f8c9f30 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,43 +33,33 @@ 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.UsePathBase(options.PathBase);
- app.UseForwardedHeaders();
app.UseSpaStaticFiles();
+ app.UseRouting();
+
+ app.UseForwardedHeaders();
+ 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 =>
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"
}
}
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
+
+
+