Restore netcoreapp3.1 templates for Steeltoe 2.4
This commit is contained in:
Родитель
3bedd2d99e
Коммит
1a90e0be85
|
@ -1,14 +1,19 @@
|
|||
using Microsoft.AspNetCore;
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
{{#AzureSpringCloud}}
|
||||
using Microsoft.Azure.SpringCloud.Client;
|
||||
{{/AzureSpringCloud}}
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
{{#ActuatorsOrDynamicLogger}}
|
||||
using Steeltoe.Extensions.Logging.DynamicSerilog;
|
||||
using Steeltoe.Extensions.Logging;
|
||||
{{/ActuatorsOrDynamicLogger}}
|
||||
{{#CloudFoundry}}
|
||||
{{^ConfigServer}}
|
||||
using Steeltoe.Common.Hosting;
|
||||
using Steeltoe.Extensions.Configuration;
|
||||
using Steeltoe.Extensions.Configuration.CloudFoundry;
|
||||
{{/ConfigServer}}
|
||||
{{/CloudFoundry}}
|
||||
|
@ -16,12 +21,11 @@ using Steeltoe.Extensions.Configuration.CloudFoundry;
|
|||
using Steeltoe.Extensions.Configuration.ConfigServer;
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
using Steeltoe.Extensions.Configuration.Placeholder;
|
||||
using Steeltoe.Extensions.Configuration.PlaceholderCore;
|
||||
{{/PlaceholderConfig}}
|
||||
{{#RandomValueConfig}}
|
||||
using Steeltoe.Extensions.Configuration.RandomValue;
|
||||
{{/ RandomValueConfig}}
|
||||
|
||||
namespace {{ProjectNameSpace}}
|
||||
{
|
||||
public class Program
|
||||
|
@ -34,34 +38,36 @@ namespace {{ProjectNameSpace}}
|
|||
.InitializeDbContexts()
|
||||
{{/AnyEFCore}}
|
||||
.Run();
|
||||
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||
{
|
||||
var builder = WebHost.CreateDefaultBuilder(args)
|
||||
.UseDefaultServiceProvider(configure => configure.ValidateScopes = false)
|
||||
{{#CloudFoundry}}
|
||||
.UseCloudHosting() //Enable listening on a Env provided port
|
||||
{{^ConfigServer}}
|
||||
.AddCloudFoundryConfiguration() //Add cloudfoundry environment variables as a configuration source
|
||||
{{/ConfigServer}}
|
||||
{{/CloudFoundry}}
|
||||
{{#ConfigServer}}
|
||||
.AddConfigServer()
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
{{#CloudFoundry}}
|
||||
.UseCloudFoundryHosting() //Enable listening on a Env provided port
|
||||
{{^ConfigServer}}
|
||||
.AddCloudFoundry() //Add cloudfoundry environment variables as a configuration source
|
||||
{{/ConfigServer}}
|
||||
{{/CloudFoundry}}
|
||||
{{#ConfigServer}}
|
||||
.AddConfigServer()
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
.AddPlaceholderResolver()
|
||||
{{/PlaceholderConfig}}
|
||||
{{#RandomValueConfig}}
|
||||
{{/PlaceholderConfig}}
|
||||
{{#RandomValueConfig}}
|
||||
.ConfigureAppConfiguration((b) => b.AddRandomValueSource())
|
||||
{{/RandomValueConfig}}
|
||||
{{#AzureSpringCloud}}
|
||||
.UseAzureSpringCloudService()
|
||||
{{/AzureSpringCloud}}
|
||||
{{#ActuatorsOrDynamicLogger}}
|
||||
.ConfigureLogging((context, builder) => builder.AddSerilogDynamicConsole())
|
||||
{{/ActuatorsOrDynamicLogger}}
|
||||
{{/RandomValueConfig}}
|
||||
.UseStartup<Startup>();
|
||||
{{#ActuatorsOrDynamicLogger}}
|
||||
builder.ConfigureLogging((hostingContext, loggingBuilder) =>
|
||||
{
|
||||
loggingBuilder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
||||
loggingBuilder.AddDynamicConsole();
|
||||
});
|
||||
{{/ActuatorsOrDynamicLogger}}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,71 +21,60 @@
|
|||
{{#RequiresHttps}}
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="{{AspNetCoreVersion}}" />
|
||||
{{/RequiresHttps}}
|
||||
{{#AnyEFCore}}
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="{{AspNetCoreVersion}}" />
|
||||
{{/AnyEFCore}}
|
||||
{{#MongoDB}}
|
||||
<PackageReference Include="MongoDB.Driver" Version="{{MongoDBVersion}}" />
|
||||
{{/MongoDB}}
|
||||
{{#CloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/CloudFoundry}}
|
||||
{{#ConfigServer}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ConfigServer}}
|
||||
{{#PlaceholderConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/PlaceholderConfig}}
|
||||
{{#RandomValueConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.RandomValueBase" Version="{{SteeltoeVersion}}" />
|
||||
{{/RandomValueConfig}}
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Management.ExporterCore" Version="{{SteeltoeVersion}}"/>
|
||||
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ActuatorsOrCloudFoundry}}
|
||||
{{#CircuitBreaker}}
|
||||
<PackageReference Include="Steeltoe.CircuitBreaker.HystrixCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/CircuitBreaker}}
|
||||
{{#MySql}}
|
||||
<PackageReference Include="MySql.Data" Version="{{MySqlVersion}}" />
|
||||
{{/MySql}}
|
||||
{{#Postgres}}
|
||||
<PackageReference Include="Npgsql" Version="{{NpgSqlVersion}}" />
|
||||
{{/Postgres}}
|
||||
{{#CircuitBreaker}}
|
||||
<PackageReference Include="Steeltoe.CircuitBreaker.HystrixCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/CircuitBreaker}}
|
||||
{{#CloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Common.Hosting" Version="{{SteeltoeVersion}}" />
|
||||
{{/CloudFoundry}}
|
||||
{{#AnyConnector}}
|
||||
<PackageReference Include="Steeltoe.Connector.ConnectorCore" Version="{{SteeltoeVersion}}"/>
|
||||
<PackageReference Include="Steeltoe.Connector.CloudFoundry" Version="{{SteeltoeVersion}}"/>
|
||||
{{/AnyConnector}}
|
||||
{{#AnyEFCore}}
|
||||
<PackageReference Include="Steeltoe.Connector.EFCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/AnyEFCore}}
|
||||
{{#SQLServer}}
|
||||
<PackageReference Include="Steeltoe.Connector.EFCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/SQLServer}}
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
{{#Discovery}}
|
||||
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="{{SteeltoeVersion}}"/>
|
||||
{{/Discovery}}
|
||||
{{#CloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/CloudFoundry}}
|
||||
{{#PlaceholderConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/PlaceholderConfig}}
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Logging.DynamicSerilogCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ActuatorsOrCloudFoundry}}
|
||||
{{#DynamicLogger}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Logging.DynamicSerilogCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/DynamicLogger}}
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ActuatorsOrCloudFoundry}}
|
||||
{{#ConfigServer}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/ConfigServer}}
|
||||
{{#RandomValueConfig}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.RandomValueBase" Version="{{SteeltoeVersion}}" />
|
||||
{{/RandomValueConfig}}
|
||||
{{#AzureSpringCloud}}
|
||||
<PackageReference Include="Microsoft.Azure.SpringCloud.Client" Version="1.0.0-alpha.1" />
|
||||
{{/AzureSpringCloud}}
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
{{#SQLServer}}
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="{{AspNetCoreVersion}}" />
|
||||
{{/SQLServer}}
|
||||
{{#Redis}}
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="3.1.0" />
|
||||
{{/Redis}}
|
||||
{{#AnyEFCore}}
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="{{AspNetCoreVersion}}" />
|
||||
<PackageReference Include="Steeltoe.CloudFoundry.Connector.EFCore" Version="{{SteeltoeVersion}}" />
|
||||
{{/AnyEFCore}}
|
||||
{{#AnyConnector}}
|
||||
<PackageReference Include="Steeltoe.CloudFoundry.ConnectorCore" Version="{{SteeltoeVersion}}"/>
|
||||
{{/AnyConnector}}
|
||||
{{#PostgresEFCore}}
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
|
||||
{{/PostgresEFCore}}
|
||||
{{#MongoDB}}
|
||||
<PackageReference Include="MongoDB.Driver" Version="{{MongoDBVersion}}" />
|
||||
{{/MongoDB}}
|
||||
{{#RabbitMQ}}
|
||||
<PackageReference Include="RabbitMQ.Client" Version="{{RabbitMQVersion}}" />
|
||||
{{/RabbitMQ}}
|
||||
{{#DynamicLogger}}
|
||||
<PackageReference Include="Steeltoe.Extensions.Logging.DynamicLogger" Version="{{SteeltoeVersion}}"/>
|
||||
{{/DynamicLogger}}
|
||||
</ItemGroup>
|
||||
{{#CircuitBreaker}}
|
||||
<ItemGroup Condition="'$(BUILD)' == ''">
|
||||
|
|
|
@ -1,44 +1,13 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
{{#MongoDB}}
|
||||
using Steeltoe.Connector.MongoDb;
|
||||
{{/MongoDB}}
|
||||
{{#MySqlOrMySqlEFCore}}
|
||||
using Steeltoe.Connector.MySql;
|
||||
{{/MySqlOrMySqlEFCore}}
|
||||
{{#MySqlEFCore}}
|
||||
using Steeltoe.Connector.MySql.EFCore;
|
||||
{{/MySqlEFCore}}
|
||||
{{#OAuthConnector}}
|
||||
using Steeltoe.Connector.OAuth;
|
||||
{{/OAuthConnector}}
|
||||
{{#Postgres}}
|
||||
using Steeltoe.Connector.PostgreSql;
|
||||
{{/Postgres}}
|
||||
{{#PostgresEFCore}}
|
||||
using Steeltoe.Connector.PostgreSql.EFCore;
|
||||
{{/PostgresEFCore}}
|
||||
{{#RabbitMQ}}
|
||||
using Steeltoe.Connector.RabbitMQ;
|
||||
{{/RabbitMQ}}
|
||||
{{#Redis}}
|
||||
using Steeltoe.Connector.Redis;
|
||||
{{/Redis}}
|
||||
{{#SQLServer}}
|
||||
using Steeltoe.Connector.SqlServer.EFCore;
|
||||
{{/SQLServer}}
|
||||
{{#Discovery}}
|
||||
using Steeltoe.Discovery.Client;
|
||||
{{/Discovery}}
|
||||
{{#Actuators}}
|
||||
using Steeltoe.Management.CloudFoundry;
|
||||
{{/Actuators}}
|
||||
{{#RequiresHttps}}
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
{{/RequiresHttps}}
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
{{#Auth}}
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
{{/Auth}}
|
||||
|
@ -48,10 +17,51 @@ using Microsoft.AspNetCore.Authentication.AzureAD.UI;
|
|||
{{#IndividualB2CAuth}}
|
||||
using Microsoft.AspNetCore.Authentication.AzureADB2C.UI;
|
||||
{{/IndividualB2CAuth}}
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
{{#ActuatorsOrCloudFoundry}}
|
||||
using Steeltoe.Management.CloudFoundry;
|
||||
using Steeltoe.Management.Endpoint;
|
||||
using Steeltoe.Management.Hypermedia;
|
||||
{{/ActuatorsOrCloudFoundry}}
|
||||
|
||||
{{#CircuitBreaker}}
|
||||
using Steeltoe.CircuitBreaker.Hystrix;
|
||||
{{/CircuitBreaker}}
|
||||
|
||||
{{#MySqlOrMySqlEFCore}}
|
||||
using Steeltoe.CloudFoundry.Connector.MySql;
|
||||
{{/MySqlOrMySqlEFCore}}
|
||||
{{#MySqlEFCore}}
|
||||
using Steeltoe.CloudFoundry.Connector.MySql.EFCore;
|
||||
{{/MySqlEFCore}}
|
||||
{{#SQLServer}}
|
||||
using Steeltoe.CloudFoundry.Connector.SqlServer;
|
||||
{{/SQLServer}}
|
||||
{{#Discovery}}
|
||||
using Steeltoe.Discovery.Client;
|
||||
{{/Discovery}}
|
||||
{{#Postgres}}
|
||||
using Steeltoe.CloudFoundry.Connector.PostgreSql;
|
||||
{{/Postgres}}
|
||||
{{#RabbitMQ}}
|
||||
using Steeltoe.CloudFoundry.Connector.RabbitMQ;
|
||||
{{/RabbitMQ}}
|
||||
{{#Redis}}
|
||||
using Steeltoe.CloudFoundry.Connector.Redis;
|
||||
{{/Redis}}
|
||||
{{#MongoDB}}
|
||||
using Steeltoe.CloudFoundry.Connector.MongoDb;
|
||||
{{/MongoDB}}
|
||||
{{#OAuthConnector}}
|
||||
using Steeltoe.CloudFoundry.Connector.OAuth;
|
||||
{{/OAuthConnector}}
|
||||
{{#PostgresEFCore}}
|
||||
using Steeltoe.CloudFoundry.Connector.PostgreSql.EFCore;
|
||||
{{/PostgresEFCore}}
|
||||
namespace {{ProjectNameSpace}}
|
||||
{
|
||||
public class Startup
|
||||
|
@ -79,10 +89,10 @@ namespace {{ProjectNameSpace}}
|
|||
{{/MySql}}
|
||||
{{#Actuators}}
|
||||
{{#CloudFoundry}}
|
||||
services.ConfigureCloudFoundryOptions(Configuration, MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);
|
||||
services.AddCloudFoundryActuators(Configuration, MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);
|
||||
{{/CloudFoundry}}
|
||||
{{^CloudFoundry}}
|
||||
services.AddCloudFoundryActuators(Configuration);
|
||||
services.AddCloudFoundryActuators(Configuration);
|
||||
{{/CloudFoundry}}
|
||||
{{/Actuators}}
|
||||
{{#Discovery}}
|
||||
|
@ -96,16 +106,19 @@ namespace {{ProjectNameSpace}}
|
|||
{{/RabbitMQ}}
|
||||
{{#Redis}}
|
||||
// Add the Redis distributed cache.
|
||||
|
||||
// We are using the Steeltoe Redis Connector to pickup the CloudFoundry
|
||||
// Redis Service binding and use it to configure the underlying RedisCache
|
||||
// This adds a IDistributedCache to the container
|
||||
services.AddDistributedRedisCache(Configuration);
|
||||
|
||||
// This works like the above, but adds a IConnectionMultiplexer to the container
|
||||
// services.AddRedisConnectionMultiplexer(Configuration);
|
||||
{{/Redis}}
|
||||
{{#MongoDB}}
|
||||
services.AddMongoClient(Configuration);
|
||||
{{/MongoDB}}
|
||||
|
||||
{{#OAuthConnector}}
|
||||
services.AddOAuthServiceOptions(Configuration);
|
||||
{{/OAuthConnector}}
|
||||
|
@ -113,6 +126,9 @@ namespace {{ProjectNameSpace}}
|
|||
// Add Context and use Postgres as provider ... provider will be configured from VCAP_ info
|
||||
// services.AddDbContext<MyDbContext>(options => options.UseNpgsql(Configuration));
|
||||
{{/PostgresEFCore}}
|
||||
{{#SQLServer}}
|
||||
services.AddSqlServerConnection(Configuration);
|
||||
{{/SQLServer}}
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
|
@ -123,7 +139,7 @@ namespace {{ProjectNameSpace}}
|
|||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
{{#RequiresHttps}}
|
||||
{{#RequiresHttps}}
|
||||
else
|
||||
{
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
|
@ -131,14 +147,25 @@ namespace {{ProjectNameSpace}}
|
|||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
{{/RequiresHttps}}
|
||||
{{#Auth}}
|
||||
app.UseAuthentication();
|
||||
{{/Auth}}
|
||||
{{/RequiresHttps}}
|
||||
|
||||
{{#Discovery}}
|
||||
|
||||
{{#Auth}}
|
||||
app.UseAuthentication();
|
||||
{{/Auth}}
|
||||
|
||||
{{#Actuators}}
|
||||
{{#CloudFoundry}}
|
||||
app.UseCloudFoundryActuators(MediaTypeVersion.V2, ActuatorContext.ActuatorAndCloudFoundry);
|
||||
{{/CloudFoundry}}
|
||||
{{^CloudFoundry}}
|
||||
app.UseCloudFoundryActuators();
|
||||
{{/CloudFoundry}}
|
||||
{{/Actuators}}
|
||||
|
||||
{{#Discovery}}
|
||||
app.UseDiscoveryClient();
|
||||
{{/Discovery}}
|
||||
{{/Discovery}}
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
|
|
|
@ -32,12 +32,6 @@
|
|||
"DefaultValue": false,
|
||||
"Description": "Steeltoe: Add Dynamic Logger"
|
||||
},
|
||||
{
|
||||
"Name": "AzureSpringCloud",
|
||||
"DefaultValue": false,
|
||||
"Description": "Steeltoe: Target Microsoft Azure Spring Cloud Hosting",
|
||||
"FriendlyName": "Microsoft Azure Spring Cloud"
|
||||
},
|
||||
{
|
||||
"Name": "MongoDB",
|
||||
"DefaultValue": false,
|
||||
|
@ -184,10 +178,6 @@
|
|||
{
|
||||
"choice": "2.4.4",
|
||||
"Description": "Target Steeltoe version 2.4.4"
|
||||
},
|
||||
{
|
||||
"choice": "3.0.0-rc1",
|
||||
"Description": "Target Steeltoe version 3.0.0-rc1"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -196,6 +186,10 @@
|
|||
"DefaultValue": "netcoreapp3.1",
|
||||
"Description": "Target the appropriate Dotnet framework version",
|
||||
"choices": [
|
||||
{
|
||||
"Choice": "netcoreapp3.0",
|
||||
"Description": "Target Dotnet framework version 3.0"
|
||||
},
|
||||
{
|
||||
"Choice": "netcoreapp3.1",
|
||||
"Description": "Target Dotnet framework version 3.1"
|
||||
|
|
Загрузка…
Ссылка в новой задаче