Skip to content

Commit 68e246c

Browse files
authored
Merge pull request #9 from drwatson1/rel-2.3
Rel 2.3
2 parents a399fde + 9fbd6bb commit 68e246c

File tree

8 files changed

+57
-30
lines changed

8 files changed

+57
-30
lines changed

ProjectTemplates/ReferenceProject/Program.cs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,54 @@
55
using Microsoft.Extensions.Configuration;
66
using Serilog;
77
using Microsoft.Extensions.Hosting;
8+
using System.IO;
9+
using System;
810

911
namespace ReferenceProject
1012
{
1113
public class Program
1214
{
13-
public static void Main(string[] args)
15+
public static int Main(string[] args)
1416
{
15-
CreateHostBuilder(args).Build().Run();
17+
try
18+
{
19+
CreateHostBuilder(args).Build().Run();
20+
21+
return 0;
22+
}
23+
catch(Exception ex)
24+
{
25+
var msg = "An unhandled exception occurred. The application will be closed";
26+
Log.Logger?.Fatal(ex, msg);
27+
if( Log.Logger == null )
28+
{
29+
Console.WriteLine(msg + Environment.NewLine + ex);
30+
}
31+
return 1;
32+
}
1633
}
1734

1835
public static IHostBuilder CreateHostBuilder(string[] args) =>
1936
Host.CreateDefaultBuilder(args)
2037
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
38+
.ConfigureAppConfiguration((hostingContext, config) =>
39+
{
40+
// https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#using-environment-variables-in-configuration-options
41+
var envPath = Path.Combine(hostingContext.HostingEnvironment.ContentRootPath, ".env");
42+
DotNetEnv.Env.Load(envPath);
43+
44+
config.AddEnvironmentVariables();
45+
})
2146
.ConfigureLogging((context, logging) =>
2247
{
2348
logging.ClearProviders();
2449

25-
/*
26-
* You can use a global logger as this, but I don't recommend this way
27-
* More information: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#logging
50+
// https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#logging
2851
Log.Logger = new LoggerConfiguration()
2952
.ReadFrom.Configuration(context.Configuration)
3053
.CreateLogger();
31-
*/
3254

33-
logging.AddSerilog(new LoggerConfiguration()
34-
.ReadFrom.Configuration(context.Configuration)
35-
.CreateLogger());
36-
})
37-
.ConfigureAppConfiguration(x =>
38-
{
39-
x.AddEnvironmentVariables();
55+
logging.AddSerilog(Log.Logger);
4056
})
4157
.ConfigureWebHostDefaults(webBuilder =>
4258
{

ProjectTemplates/ReferenceProject/ReferenceProject.csproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@
3030
</ItemGroup>
3131

3232
<ItemGroup>
33-
<PackageReference Include="Autofac.Configuration" Version="5.1.0" />
34-
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
35-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
33+
<PackageReference Include="Autofac.Configuration" Version="6.0.0" />
34+
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
35+
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
3636
<PackageReference Include="Contrib.Extensions.Configuration.AutoBind" Version="1.0.0" />
37-
<PackageReference Include="Contrib.Extensions.Configuration.VariablesSubstitution" Version="1.1.0" />
38-
<PackageReference Include="DotNetEnv" Version="1.4.0" />
37+
<PackageReference Include="Contrib.Extensions.Configuration.VariablesSubstitution" Version="1.2.0" />
38+
<PackageReference Include="DotNetEnv" Version="2.1.0" />
3939
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
40+
<PackageReference Include="Serilog" Version="2.10.0" />
4041
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
41-
<PackageReference Include="Serilog.Filters.Expressions" Version="2.1.0" />
42+
<PackageReference Include="Serilog.Expressions" Version="1.0.0" />
43+
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
4244
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
4345
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
4446
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
45-
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
46-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
47+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.0.7" />
48+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.0.7" />
4749
<PackageReference Include="System.Net.Http" Version="4.3.4" />
4850
</ItemGroup>
4951

ProjectTemplates/ReferenceProject/Startup.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public Startup(IConfiguration configuration, IHostEnvironment env)
3737
{
3838
Startup.Configuration = configuration;
3939

40-
// https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#using-environment-variables-in-configuration-options
41-
var envPath = Path.Combine(env.ContentRootPath, ".env");
42-
DotNetEnv.Env.Load(envPath);
43-
4440
// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#content-formatting
4541
JsonConvert.DefaultSettings = () =>
4642
{

ProjectTemplates/ReferenceProject/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"Name": "File",
1515
"Args": {
16-
"path": "%AppData%/Logs/ReferenceProject.log",
16+
"path": "%APPDATA%/Logs/ReferenceProject.log",
1717
"rollOnFileSizeLimit": true,
1818
"fileSizeLimitBytes": 10485760,
1919
"retainedFileCountLimit": 10,
@@ -34,7 +34,7 @@
3434
},
3535
"Products": {
3636
"TempFolder": "%TEMP%",
37-
"BackendServiceUrl": "http://%gateway%/backend"
37+
"BackendServiceUrl": "http://%GATEWAY%/backend"
3838
},
3939
"AllowedHosts": "*",
4040
"Urls": "http://localhost:5000"

ProjectTemplates/ReferenceProject/web.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<!--
3+
<!--
44
This file is intended to be deployed to IIS.
55
See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#deploying-to-iis
66
-->
@@ -17,7 +17,7 @@
1717
<clear />
1818
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
1919
</handlers>
20-
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
20+
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="InProcess">
2121
<environmentVariables />
2222
</aspNetCore>
2323
<httpProtocol>

ProjectTemplates/ReferenceProjectVSIX/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="ASP.Net Core RESTful Service Template-1" Version="2.2" Language="en-US" Publisher="Sergey Tregub" />
4+
<Identity Id="ASP.Net Core RESTful Service Template-1" Version="2.3" Language="en-US" Publisher="Sergey Tregub" />
55
<DisplayName>ASP.Net Core 3.1 RESTful Service Template</DisplayName>
66
<Description xml:space="preserve">Project template to create production-ready RESTful service based on ASP.Net Core 3.1. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features</Description>
77
<MoreInfo>https://github.com/drwatson1/AspNet-Core-REST-Service</MoreInfo>

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@ Let me know, what do you think. Any suggestions and bug reports are very appreci
3737
Visit project [Wiki](https://github.com/drwatson1/AspNet-Core-REST-Service/wiki) pages to learn more about the template.
3838

3939
Have fun and happy hacking!
40+
41+
# Release Notes
42+
43+
|Date | Version | Release Notes |
44+
|-----|---------|---------------|
45+
|2021-02-23|2.3|<p>- Load .env before Serilog initialization to make it possible to use environment variables in Serilog configuration options<p>- Catch and log unhandled exceptions <p>- Update NuGet packages to the latest versions|
46+
|2020-08-14|2.2|<p>- Allow Swagger to work behind a proxy<p>- Improve Application Settings with `Options Pattern` and [Configuration Extensions](https://github.com/drwatson1/configuration-extensions)<p>- Update NuGet packages to the latest versions
47+
|2020-01-22|2.1|<p>- Fix deploying to IIS<p>- Fix publishing the service
48+
|2020-01-22|2.0|<p>- Change target framework to .Net Core 3.1<p>- Add health check service
49+
|2020-01-21|1.3|<p>- Update target framework to .Net Core 2.2
50+
|2019-08-22|1.2|<p>- Project tags are added to make it simple to find this project template in a VS2019 project creation wizard<p>- Update NuGet packages to the latest versions|
51+
|2019-04-03|1.1|- Support VS2019
52+
|2019-01-21|1.0|- Initial version

0 commit comments

Comments
 (0)