Skip to content

Commit fe40711

Browse files
authored
Merge pull request #13 from drwatson1/vNext
Update to .Net 6
2 parents ffb105f + 0b10a0a commit fe40711

File tree

11 files changed

+173
-63
lines changed

11 files changed

+173
-63
lines changed

ProjectTemplates/DrWatson1.ProjectTemplate.RestAPI.csproj

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,65 @@
22

33
<PropertyGroup>
44
<PackageType>Template</PackageType>
5-
<PackageVersion>2.6</PackageVersion>
5+
<PackageVersion>3.0</PackageVersion>
66
<PackageId>DrWatson1.ProjectTemplate.RestAPI</PackageId>
7-
<Title>ASP.Net Core RESTful Service Template</Title>
7+
<Title>ASP.Net REST API Service Template</Title>
88
<Authors>Sergey Tregub</Authors>
9-
<Description>Project template to create production-ready RESTful service based on ASP.Net Core v3.1 or 5.0. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features</Description>
9+
<Description>Project template to create production-ready RESTful service based on ASP.Net 6. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features</Description>
1010
<PackageTags>dotnet-new;templates;webapi;web;rest-api</PackageTags>
1111
<TargetFramework>netcoreapp3.1</TargetFramework>
1212

1313
<IncludeContentInPack>true</IncludeContentInPack>
1414
<IncludeBuildOutput>false</IncludeBuildOutput>
1515
<ContentTargetFolders>content</ContentTargetFolders>
1616
<NoWarn>$(NoWarn);NU5128</NoWarn>
17-
<PackageReleaseNotes>Support of .Net Core 5.0 and dotnet new custom template</PackageReleaseNotes>
17+
<PackageReleaseNotes>3.0 - 2022-06-13
18+
- BREAKING CHANGES: Drop support of .Net Core 3.1
19+
- The template now uses .Net 6.0 by default
20+
- Support of Visual Studio 2022
21+
- All packages was updated to the latest versions
22+
23+
2.6 - 2021-05-03
24+
- Support of .Net 5.0
25+
- Add `dotnet new` custom template
26+
27+
2.5 - 2021-03-07
28+
- Minor fixes
29+
30+
2.4 - 2021-02-27
31+
- Improve logging
32+
33+
2.3 - 2021-02-23
34+
- Load .env before Serilog initialization to make it possible to use environment variables in Serilog configuration options
35+
- Catch and log unhandled exceptions
36+
- Update NuGet packages to the latest versions
37+
38+
2.2 - 2020-08-14
39+
- Allow Swagger to work behind a proxy
40+
- Improve Application Settings with `Options Pattern` and [Configuration Extensions](https://github.com/drwatson1/configuration-extensions)
41+
- Update NuGet packages to the latest versions
42+
43+
2.1 - 2020-01-22
44+
- Fix deploying to IIS
45+
- Fix publishing the service
46+
47+
2.0 - 2020-01-22
48+
- Change target framework to .Net Core 3.1
49+
- Add health check service
50+
51+
1.3 - 2020-01-21
52+
- Update target framework to .Net Core 2.2
53+
54+
1.2 - 2019-08-22
55+
- Project tags are added to make it simple to find this project template in a VS2019 project creation wizard
56+
- Update NuGet packages to the latest versions
57+
58+
1.1 - 2019-04-03
59+
- Support VS2019
60+
61+
1.0 - 2019-01-21
62+
- Initial version
63+
</PackageReleaseNotes>
1864
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1965
<PackageProjectUrl>https://github.com/drwatson1/AspNet-Core-REST-Service</PackageProjectUrl>
2066
<RepositoryUrl>https://github.com/drwatson1/AspNet-Core-REST-Service</RepositoryUrl>

ProjectTemplates/How to create a new template.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@ After making any changes do:
66
1. Select Release configuration for a solution
77
1. Select ReferenceProject in "Solution Explorer" and click "Project/Export Template..." menu item from the VS main menu
88
1. In the appeared dialog box select "Project template" option and "ReferenceProject" in the combobox below and click Next
9-
1. Set the value `ASP.Net Core RESTful Service` as a template name and the `Project template to create production-ready RESTful service based on ASP.Net Core v3.1 or 5.0. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features` as a description
9+
1. Set the value `ASP.Net REST API` as a template name and the `Project template to create production-ready RESTful service based on .Net 6. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features` as a description
1010
1. Don't foget to replace .Net Core version in the description above to the appropriate one.
1111
1. Clear checkbox "Automatically import the template into Visual Studio" if you don't want immediately import it and click Finish button
12-
1. Extract all files from the created zip-archive to any folder as you want. Typically, the file can be found in `C:\Users\<YOU>\Documents\Visual Studio 2019\My Exported Templates` folder
12+
1. Extract all files from the created zip-archive to any folder as you want. Typically, the file can be found in `C:\Users\<YOU>\Documents\Visual Studio 2022\My Exported Templates` folder
1313
1. Open a file "MyTemplate.vstemplate"
14-
1. Replace content of the tag `DefaultName` in the section `TemplateData` to `ASPNetCore.Service`
14+
1. Replace content of the tag `DefaultName` in the section `TemplateData` to `RestApi.Service`
1515
1. Add the following tags to the same section:
1616
```xml
1717
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
1818
<LanguageTag>C#</LanguageTag>
1919
<PlatformTag>windows</PlatformTag>
2020
<PlatformTag>linux</PlatformTag>
21-
<ProjectTypeTag>web</ProjectTypeTag>
21+
<ProjectTypeTag>WebApi</ProjectTypeTag>
22+
<ProjectTypeTag>REST API</ProjectTypeTag>
2223
<ProjectTypeTag>RESTful Service</ProjectTypeTag>
2324
```
24-
1. Add all files from the folder to zip-archive with a name `ASP.Net Core RESTful Service.zip`. All added files must be in the root of the archive
25+
1. Add all files from the folder to zip-archive with a name `ASP.Net REST API.zip`. All added files must be in the root of the archive
2526
1. Copy this file to `ProjectTemplates\ReferenceProjectVSIX\ProjectTemplates\CSharp\.NET Core` folder and replace an existing one
2627
1. Go to VS, expand a ReferenceProjectVSIX project and double click on source.extension.vsixmanifest file
2728
1. Increase minor version number on the tab "Metadata" in the top right corner
2829
1. Update template description
29-
1. Add Release Notes
30-
1. Rebuild the ReferenceProjectVSIX project and get "ASP.Net Core RESTful Service Template.vsix"
30+
1. Update ReleaseNotes.txt
31+
1. Rebuild the ReferenceProjectVSIX project and get "ASP.Net REST API Service Template.vsix"
3132

3233
**Create a .Net Core Custom template**
3334
1. Open the `DrWatson1.ProjectTemplate.RestAPI.csproj`

ProjectTemplates/ReferenceProject/ReferenceProject.csproj

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>
77
</PropertyGroup>
@@ -31,27 +31,27 @@
3131

3232
<ItemGroup>
3333
<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" />
34+
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
35+
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
3636
<PackageReference Include="Contrib.Extensions.Configuration.AutoBind" Version="1.0.0" />
3737
<PackageReference Include="Contrib.Extensions.Configuration.VariablesSubstitution" Version="1.2.0" />
38-
<PackageReference Include="DotNetEnv" Version="2.1.1" />
39-
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
40-
<PackageReference Include="Serilog" Version="2.10.0" />
41-
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
42-
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
43-
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
38+
<PackageReference Include="DotNetEnv" Version="2.3.0" />
39+
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
40+
<PackageReference Include="Serilog" Version="2.11.0" />
41+
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
42+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
43+
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
4444
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
45-
<PackageReference Include="Serilog.Exceptions" Version="6.1.0" />
46-
<PackageReference Include="Serilog.Expressions" Version="2.0.0" />
47-
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
48-
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
45+
<PackageReference Include="Serilog.Exceptions" Version="8.3.0" />
46+
<PackageReference Include="Serilog.Expressions" Version="3.4.0" />
47+
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
48+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
4949
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
50-
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
51-
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
52-
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
53-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
54-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.1.4" />
50+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
51+
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
52+
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
53+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
54+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.4.0" />
5555
<PackageReference Include="System.Net.Http" Version="4.3.4" />
5656
</ItemGroup>
5757

ProjectTemplates/ReferenceProject/Startup.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.AspNetCore.Builder;
66
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
77
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.AspNetCore.Hosting.Server.Features;
89
using Microsoft.AspNetCore.Http;
910
using Microsoft.AspNetCore.Mvc;
1011
using Microsoft.AspNetCore.Mvc.Infrastructure;
@@ -20,7 +21,9 @@
2021
using ReferenceProject.Filters;
2122
using ReferenceProject.Modules;
2223
using Serilog;
24+
using System;
2325
using System.IO;
26+
using System.Linq;
2427
using System.Text.Json;
2528
using System.Text.Json.Serialization;
2629

@@ -76,13 +79,12 @@ public void ConfigureServices(IServiceCollection services)
7679
})
7780
.AddJsonOptions(options =>
7881
{
79-
options.JsonSerializerOptions.IgnoreNullValues = true;
82+
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
8083
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
8184
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
8285
options.JsonSerializerOptions.WriteIndented = HostEnvironment.IsDevelopment();
8386
})
84-
.AddApiExplorer()
85-
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
87+
.AddApiExplorer();
8688

8789
services
8890
.AddAutoMapper(typeof(Startup)) // Check out Configuration/AutoMapperProfiles/DefaultProfile to do actual configuration. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#automapper
@@ -146,13 +148,15 @@ public void Configure(IApplicationBuilder app, ILogger<Startup> logger)
146148

147149
// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
148150
app.UseCors(builder => builder
149-
.AllowAnyOrigin()
150151
.AllowAnyMethod()
151-
.AllowAnyHeader());
152+
.AllowAnyHeader()
153+
.AllowAnyOrigin() // <-- Comment this line out and uncomment two lines below to use with SignalR
154+
/*.AllowCredentials()
155+
.SetIsOriginAllowed(origin => true)*/
156+
);
152157

153-
app
154-
.UseOptionsVerbHandler() // Options verb handler must be added after CORS. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
155-
.UseSwaggerWithOptions(); // Check out Configuration/MiddlewareConfig.cs/UseSwaggerWithOptions to do actual configuration. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api
158+
app.UseOptionsVerbHandler() // Options verb handler must be added after CORS. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
159+
.UseSwaggerWithOptions(); // Check out Configuration/MiddlewareConfig.cs/UseSwaggerWithOptions to do actual configuration. See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api
156160

157161
app.UseEndpoints(endpoints =>
158162
{
@@ -161,6 +165,12 @@ public void Configure(IApplicationBuilder app, ILogger<Startup> logger)
161165
});
162166

163167
logger.LogInformation("Server configuration is completed");
168+
var addr = app.ServerFeatures.Get<IServerAddressesFeature>().Addresses.FirstOrDefault();
169+
if (!string.IsNullOrWhiteSpace(addr))
170+
{
171+
var uri = new Uri(new Uri(addr), "swagger");
172+
logger.LogInformation("Open {uri} to browse the server API", uri);
173+
}
164174
}
165175
}
166176
}

ProjectTemplates/ReferenceProject/web.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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" hostingModel="InProcess">
20+
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="inprocess">
2121
<environmentVariables />
2222
</aspNetCore>
2323
<httpProtocol>
Binary file not shown.

ProjectTemplates/ReferenceProjectVSIX/ReferenceProjectVSIX.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<OutputType>Library</OutputType>
1515
<AppDesignerFolder>Properties</AppDesignerFolder>
1616
<RootNamespace>ReferenceProjectVSIX</RootNamespace>
17-
<AssemblyName>ASP.Net Core RESTful Service Template</AssemblyName>
17+
<AssemblyName>ASP.Net REST API Service Template</AssemblyName>
1818
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
1919
<GeneratePkgDefFile>false</GeneratePkgDefFile>
2020
<IncludeAssemblyInVSIXContainer>false</IncludeAssemblyInVSIXContainer>
@@ -43,7 +43,7 @@
4343
<DefineConstants>TRACE</DefineConstants>
4444
<ErrorReport>prompt</ErrorReport>
4545
<WarningLevel>4</WarningLevel>
46-
<DeployExtension>False</DeployExtension>
46+
<DeployExtension>True</DeployExtension>
4747
</PropertyGroup>
4848
<ItemGroup>
4949
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -53,8 +53,12 @@
5353
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5454
<IncludeInVSIX>true</IncludeInVSIX>
5555
</Content>
56+
<Content Include="ReleaseNotes.txt">
57+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
58+
<IncludeInVSIX>true</IncludeInVSIX>
59+
</Content>
5660
<None Include="Assets\logo.xcf" />
57-
<Content Include="ProjectTemplates\CSharp\.NET Core\ASP.Net Core RESTful Service.zip">
61+
<Content Include="ProjectTemplates\ASP.Net REST API.zip">
5862
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5963
<IncludeInVSIX>true</IncludeInVSIX>
6064
</Content>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
3.0 - 2022-06-13
2+
- BREAKING CHANGES: Drop support of .Net Core 3.1
3+
- The template now uses .Net 6.0 by default
4+
- Support of Visual Studio 2022
5+
- All packages was updated to the latest versions
6+
7+
2.6 - 2021-05-03
8+
- Support of .Net 5.0
9+
- Add `dotnet new` custom template
10+
11+
2.5 - 2021-03-07
12+
- Minor fixes
13+
14+
2.4 - 2021-02-27
15+
- Improve logging
16+
17+
2.3 - 2021-02-23
18+
- Load .env before Serilog initialization to make it possible to use environment variables in Serilog configuration options
19+
- Catch and log unhandled exceptions
20+
- Update NuGet packages to the latest versions
21+
22+
2.2 - 2020-08-14
23+
- Allow Swagger to work behind a proxy
24+
- Improve Application Settings with `Options Pattern` and [Configuration Extensions](https://github.com/drwatson1/configuration-extensions)
25+
- Update NuGet packages to the latest versions
26+
27+
2.1 - 2020-01-22
28+
- Fix deploying to IIS
29+
- Fix publishing the service
30+
31+
2.0 - 2020-01-22
32+
- Change target framework to .Net Core 3.1
33+
- Add health check service
34+
35+
1.3 - 2020-01-21
36+
- Update target framework to .Net Core 2.2
37+
38+
1.2 - 2019-08-22
39+
- Project tags are added to make it simple to find this project template in a VS2019 project creation wizard
40+
- Update NuGet packages to the latest versions
41+
42+
1.1 - 2019-04-03
43+
- Support VS2019
44+
45+
1.0 - 2019-01-21
46+
- Initial version

ProjectTemplates/ReferenceProjectVSIX/source.extension.vsixmanifest

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
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.6" Language="en-US" Publisher="Sergey Tregub" />
5-
<DisplayName>ASP.Net Core 3.1/5.0 RESTful Service Template</DisplayName>
6-
<Description xml:space="preserve">Project template to create production-ready RESTful service based on ASP.Net Core 3.1 or 5.0. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features</Description>
4+
<Identity Id="ASP.Net Core RESTful Service Template-1" Version="3.0" Language="en-US" Publisher="Sergey Tregub" />
5+
<DisplayName>ASP.Net REST API Service Template</DisplayName>
6+
<Description xml:space="preserve">Project template to create production-ready RESTful service based on ASP.Net 5.0 or 6.0. 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>
88
<GettingStartedGuide>https://github.com/drwatson1/AspNet-Core-REST-Service/wiki</GettingStartedGuide>
9-
<ReleaseNotes>Support of .Net Core 5.0 and dotnet new custom template</ReleaseNotes>
9+
<ReleaseNotes>ReleaseNotes.txt</ReleaseNotes>
1010
<Icon>Assets\logo.png</Icon>
11-
<Tags>asp-net-core restful-api vs2017 vs2019 visual-studio project-template web-api</Tags>
11+
<Tags>asp-net-core restful-api vs2019 vs2022 visual-studio project-template web-api</Tags>
1212
</Metadata>
1313
<Installation>
14-
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0, 17.0)" />
14+
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0, 17.0)">
15+
<ProductArchitecture>x86</ProductArchitecture>
16+
</InstallationTarget>
17+
<InstallationTarget Version="[17.0,18.0)" Id="Microsoft.VisualStudio.Community">
18+
<ProductArchitecture>amd64</ProductArchitecture>
19+
</InstallationTarget>
1520
</Installation>
1621
<Dependencies>
1722
</Dependencies>
1823
<Assets>
19-
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" d:Source="File" Path="ProjectTemplates" d:TargetPath="ProjectTemplates\CSharp\.NET Core\ASP.Net Core RESTful Service.zip" />
24+
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" d:Source="File" Path="ProjectTemplates" d:TargetPath="ProjectTemplates\ASP.Net REST API.zip" />
2025
</Assets>
2126
<Prerequisites>
2227
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />

0 commit comments

Comments
 (0)