diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index d4b62d6..742ea6b 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -2,17 +2,12 @@
"version": 1,
"isRoot": true,
"tools": {
- "dotnet-reportgenerator-globaltool": {
- "version": "4.6.4",
- "commands": [
- "reportgenerator"
- ]
- },
"nbgv": {
- "version": "3.4.244",
+ "version": "3.7.115",
"commands": [
"nbgv"
- ]
+ ],
+ "rollForward": false
}
}
}
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
index 830710e..ddd4480 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -2,17 +2,13 @@ root = true
[*]
indent_style = space
-end_of_line = lf
+indent_size = 4
+tab-width = 4
+charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
-max_line_length = 120
-charset = utf-8
-
-[*.cs]
-indent_size = 4
-
-[*.{config, csproj, props}]
-indent_size = 2
+max_line_length = 160
-[*.{json, yaml}]
+[*.{build,config,csproj,js,json,proj,props,targets,xml,ruleset,xsd,yml,yaml}]
indent_size = 2
+tab-width = 2
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..a23eeec
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,59 @@
+name: build-and-test
+on:
+ pull_request:
+ branches:
+ - main
+ push:
+ branches:
+ - main
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
+
+env:
+ DOTNET_NOLOGO: true
+ DOTNET_CLI_TELEMETRY_OPTOUT: true
+
+jobs:
+ build-and-test:
+ timeout-minutes: 60
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, windows-latest, macos-latest]
+ runs-on: ${{ matrix.os }}
+ steps:
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: |
+ 6.0.*
+ 8.0.*
+ 9.0.*
+ - name: Git checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Restore tools
+ run: |
+ dotnet tool restore
+ - name: Restore packages
+ run: |
+ dotnet restore
+ - name: Build
+ run: |
+ dotnet build --no-restore --configuration Release
+ - name: Test
+ run: |
+ dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
+ - name: Generate packages
+ shell: pwsh
+ run: |
+ dotnet pack src --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages
+ - name: Upload packages to artifacts
+ if: matrix.os == 'ubuntu-latest'
+ uses: actions/upload-artifact@v4
+ with:
+ name: packages
+ path: artifacts/packages
diff --git a/.gitignore b/.gitignore
index 6d15496..a4fe18b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,400 @@
-# build output
-bin/
-obj/
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
-# user settings
-*.DotSettings.User
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
-# Visual Studio
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+# but not Directory.Build.rsp, as it configures directory-level build defaults
+!Directory.Build.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
-# Visual Studio Code
-.vscode/
+# Local History for Visual Studio Code
+.history/
-# Rider
-.idea/
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
-# local tools
-tools/
+# JetBrains Rider
+*.sln.iml
diff --git a/.grenrc.yaml b/.grenrc.yaml
deleted file mode 100644
index ccd30ea..0000000
--- a/.grenrc.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-dataSource: "issues"
-prefix: ""
-onlyMilestones: false
-groupBy:
- "Enhancements": ["enhancement"]
- "Bug Fixes": ["bug"]
-changelogFilename: "CHANGELOG.md"
-template:
- issue: "- {{name}} [{{text}}]({{url}})"
diff --git a/DEVELOPER.md b/DEVELOPER.md
index ad6b753..9801677 100644
--- a/DEVELOPER.md
+++ b/DEVELOPER.md
@@ -130,7 +130,7 @@ Add the new option to the `symbolInfo` object in `src/Content/NetCoreTool.Templa
If you haven't already, install the project template so that it can be invoked using `dotnet new`:
```
-$ dotnet new --install src/Content
+$ dotnet new install src/Content
```
Run the `steeltoe-webapi` template with the `--help` option to see the newly added option:
diff --git a/README.md b/README.md
index 18aa778..265c9bc 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,14 @@
-# Steeltoe NetCoreToolTemplates
+# Steeltoe.NetCoreTool.Templates
[](https://dev.azure.com/SteeltoeOSS/Steeltoe/_build/latest?definitionId=46&branchName=main)
-[](https://github-tools.github.io/github-release-notes/)
+ [](https://www.nuget.org/packages/Steeltoe.NetCoreTool.Templates)
+ [](LICENSE)
-Steeltoe NetCoreToolTemplates is a collection of .NET Core Tool templates.
+This repository contains a collection of [.NET Template Packages](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new),
+which can be used from IDEs such as Visual Studio and from the .NET CLI using `dotnet new`. They are also used by [Initializr](https://start.steeltoe.io/).
Project templates:
-
- - steeltoe-webapi
- - Creates a Steeltoe-influenced .NET Web API project
-
+- `steeltoe-webapi`: Add Steeltoe components to the default `webapi` C# template.
This document describes template installation and template general usage help.
For learning how to develop additional options for the templates, see [DEVELOPER.md](DEVELOPER.md).
@@ -26,15 +25,23 @@ $ dotnet new install Steeltoe.NetCoreTool.Templates
```
$ dotnet nuget add source https://pkgs.dev.azure.com/dotnet/Steeltoe/_packaging/dev/nuget/v3/index.json -n SteeltoeDev
-$ dotnet new --install Steeltoe.NetCoreTool.Templates
+$ dotnet new install Steeltoe.NetCoreTool.Templates
```
### From Source (development)
```
-$ dotnet new --install src/Content
+$ dotnet new install src/Content
```
-Note: To see templates in Visual Studio, you may need to enable:
-
-_Tools->Options..._ _Preview Features:_ _Show all .NET Core templates in the NEW project dialog_
+## Tips when making changes
+- When searching for occurrences of options, Visual Studio doesn't show everything by default. Change the **File types** from `!*\bin\*;!*\obj\*;!*\.*\*` to `!*\bin\*;!*\obj\*` to fix this.
+- If you've added a new option to `template.json`, `dotnetcli.host.json` and `ide.host.json`, but it doesn't appear, make sure it is listed in one of the `HasAny*` computed options in `template.json`.
+- To observe changes in Visual Studio's **File** > **New** > **Project** dialog, close all instances and run `devenv.exe /updateconfiguration`.
+- Unit tests are available for all options (CLI only), be sure to update them.
+- To verify all relevant options are exposed, temporarily add `"defaultSymbolVisibility": true` to `ide.host.json`.
+- Documentation links
+ - https://learn.microsoft.com/en-us/dotnet/core/tools/custom-templates
+ - https://github.com/dotnet/templating/wiki
+ - https://github.com/dotnet/templating?tab=readme-ov-file#template-content-repositories
+ - https://github.com/sayedihashimi/template-sample
diff --git a/Steeltoe.NetCoreToolTemplates.sln b/Steeltoe.NetCoreToolTemplates.sln
index 0d5040e..a0de8cb 100644
--- a/Steeltoe.NetCoreToolTemplates.sln
+++ b/Steeltoe.NetCoreToolTemplates.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.6.30114.105
+# Visual Studio Version 17
+VisualStudioVersion = 17.13.35806.99
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A45E423-F8A2-4421-81B6-24E6A9E9A64D}"
EndProject
@@ -8,8 +8,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Company.WebApplication.CS",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E6A8112D-A16A-481D-844B-E941C29A6BC4}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.NetCoreTool.Template.Test.Utilities", "test\NetCoreTool.Template.Test.Utilities\Steeltoe.NetCoreTool.Template.Test.Utilities.csproj", "{3AE7F581-8327-4723-9D82-246AAB87C88D}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.NetCoreTool.Template.WebApi.Test", "test\NetCoreTool.Template.WebApi.Test\Steeltoe.NetCoreTool.Template.WebApi.Test.csproj", "{4AC4F8C3-22A0-4ACE-833F-32EEB2D9A697}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DD28F12-A4AF-45A9-8719-B84F294D9ACD}"
@@ -19,15 +17,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yaml = azure-pipelines.yaml
DEVELOPER.md = DEVELOPER.md
- README.md = README.md
src\Content\NetCoreTool.Template.WebApi\CSharp\Directory.Build.props = src\Content\NetCoreTool.Template.WebApi\CSharp\Directory.Build.props
test\Directory.Build.props = test\Directory.Build.props
+ README.md = README.md
+ version.json = version.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steeltoe.NetCoreTool.Templates", "src\Steeltoe.NetCoreTool.Templates.csproj", "{8C63F895-1AD7-47F1-8074-7E6832E59D62}"
EndProject
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Company.WebApplication.FS", "src\Content\NetCoreTool.Template.WebApi\FSharp\Company.WebApplication.FS.fsproj", "{D898629D-C5A8-4AEC-A028-914BF2DB3878}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -50,18 +47,6 @@ Global
{D991A16C-69AD-457F-B9FA-EB0531CF7288}.Release|x64.Build.0 = Release|Any CPU
{D991A16C-69AD-457F-B9FA-EB0531CF7288}.Release|x86.ActiveCfg = Release|Any CPU
{D991A16C-69AD-457F-B9FA-EB0531CF7288}.Release|x86.Build.0 = Release|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Debug|x64.ActiveCfg = Debug|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Debug|x64.Build.0 = Debug|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Debug|x86.ActiveCfg = Debug|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Debug|x86.Build.0 = Debug|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Release|Any CPU.Build.0 = Release|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Release|x64.ActiveCfg = Release|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Release|x64.Build.0 = Release|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Release|x86.ActiveCfg = Release|Any CPU
- {3AE7F581-8327-4723-9D82-246AAB87C88D}.Release|x86.Build.0 = Release|Any CPU
{4AC4F8C3-22A0-4ACE-833F-32EEB2D9A697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4AC4F8C3-22A0-4ACE-833F-32EEB2D9A697}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4AC4F8C3-22A0-4ACE-833F-32EEB2D9A697}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -86,27 +71,13 @@ Global
{8C63F895-1AD7-47F1-8074-7E6832E59D62}.Release|x64.Build.0 = Release|Any CPU
{8C63F895-1AD7-47F1-8074-7E6832E59D62}.Release|x86.ActiveCfg = Release|Any CPU
{8C63F895-1AD7-47F1-8074-7E6832E59D62}.Release|x86.Build.0 = Release|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Debug|x64.ActiveCfg = Debug|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Debug|x64.Build.0 = Debug|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Debug|x86.ActiveCfg = Debug|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Debug|x86.Build.0 = Debug|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Release|Any CPU.Build.0 = Release|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Release|x64.ActiveCfg = Release|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Release|x64.Build.0 = Release|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Release|x86.ActiveCfg = Release|Any CPU
- {D898629D-C5A8-4AEC-A028-914BF2DB3878}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D991A16C-69AD-457F-B9FA-EB0531CF7288} = {7A45E423-F8A2-4421-81B6-24E6A9E9A64D}
- {3AE7F581-8327-4723-9D82-246AAB87C88D} = {E6A8112D-A16A-481D-844B-E941C29A6BC4}
{4AC4F8C3-22A0-4ACE-833F-32EEB2D9A697} = {E6A8112D-A16A-481D-844B-E941C29A6BC4}
- {D898629D-C5A8-4AEC-A028-914BF2DB3878} = {7A45E423-F8A2-4421-81B6-24E6A9E9A64D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BEFE7160-E269-4B21-A33D-C9FB43E29FD8}
diff --git a/src/Content/Directory.Build.props b/src/Content/Directory.Build.props
deleted file mode 100644
index eb14fd8..0000000
--- a/src/Content/Directory.Build.props
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- false
-
-
-
- 1.3.*
- 5.10.*
- 16.8.*
- 2.4.*
-
-
-
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/.gitignore b/src/Content/NetCoreTool.Template.WebApi/CSharp/.gitignore
index ae48469..a4fe18b 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/.gitignore
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/.gitignore
@@ -1,12 +1,400 @@
-# build output
-bin/
-obj/
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
-# Visual Studio
-/.vs/
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
-# Visual Studio Code
-/.vscode/
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+# but not Directory.Build.rsp, as it configures directory-level build defaults
+!Directory.Build.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
# JetBrains Rider
-/.idea/
+*.sln.iml
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/dotnetcli.host.json b/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/dotnetcli.host.json
index 5bbc2de..678a2d8 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/dotnetcli.host.json
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/dotnetcli.host.json
@@ -1,14 +1,59 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
+ "Framework": {
+ // Do not rename, this is a special entry.
+ "longName": "framework"
+ },
+ "SteeltoeVersionOption": {
+ "longName": "steeltoe"
+ },
+ "ChooseSteeltoeVersionInIDE": {
+ "isHidden": true
+ },
+ "DescriptionOption": {
+ "longName": "description",
+ "shortName": "D"
+ },
+ "DockerfileOption": {
+ "longName": "dockerfile",
+ "shortName": ""
+ },
+ "kestrelHttpPort": {
+ "isHidden": true
+ },
+ "kestrelHttpsPort": {
+ "isHidden": true
+ },
+ "SkipRestoreOption": {
+ "longName": "no-restore",
+ "shortName": ""
+ },
+ // Steeltoe components
"CircuitBreakerHystrixOption": {
"longName": "circuit-breaker-hystrix",
"shortName": ""
},
+ "HostingCloudOption": {
+ "longName": "hosting-cloud",
+ "shortName": ""
+ },
+ "HostingAzureSpringCloudOption": {
+ "longName": "hosting-azure-spring-cloud",
+ "shortName": ""
+ },
+ "HostingCloudFoundryOption": {
+ "longName": "hosting-cloud-foundry",
+ "shortName": ""
+ },
"ConfigurationCloudConfigOption": {
"longName": "configuration-cloud-config",
"shortName": ""
},
+ "ConfigurationEncryptionOption": {
+ "longName": "configuration-encryption",
+ "shortName": ""
+ },
"ConfigurationPlaceholderOption": {
"longName": "configuration-placeholder",
"shortName": ""
@@ -17,30 +62,38 @@
"longName": "configuration-random-value",
"shortName": ""
},
- "ConnectorMongoDbOption": {
- "longName": "connector-mongodb",
+ "ConfigurationSpringBootOption": {
+ "longName": "configuration-spring-boot",
"shortName": ""
},
- "ConnectorMySqlEfCoreOption": {
- "longName": "connector-mysql-efcore",
+ "ConnectorCosmosDbOption": {
+ "longName": "connector-cosmosdb",
+ "shortName": ""
+ },
+ "ConnectorMongoDbOption": {
+ "longName": "connector-mongodb",
"shortName": ""
},
"ConnectorMySqlOption": {
"longName": "connector-mysql",
"shortName": ""
},
- "ConnectorOAuthOption": {
- "longName": "connector-oauth",
+ "ConnectorMySqlEfCoreOption": {
+ "longName": "connector-mysql-efcore",
"shortName": ""
},
- "ConnectorPostgreSqlEfCoreOption": {
- "longName": "connector-postgresql-efcore",
+ "ConnectorOAuthOption": {
+ "longName": "connector-oauth",
"shortName": ""
},
"ConnectorPostgreSqlOption": {
"longName": "connector-postgresql",
"shortName": ""
},
+ "ConnectorPostgreSqlEfCoreOption": {
+ "longName": "connector-postgresql-efcore",
+ "shortName": ""
+ },
"ConnectorRabbitMqOption": {
"longName": "connector-rabbitmq",
"shortName": ""
@@ -53,47 +106,36 @@
"longName": "connector-sqlserver",
"shortName": ""
},
- "DescriptionOption": {
- "longName": "description",
- "shortName": "D"
- },
- "DiscoveryEurekaOption": {
- "longName": "discovery-eureka",
- "shortName": ""
- },
- "DistributedTracingOption": {
- "longName": "distributed-tracing",
- "shortName": ""
- },
- "DockerfileOption": {
- "longName": "dockerfile",
+ "ConnectorSqlServerEfCoreOption": {
+ "longName": "connector-sqlserver-efcore",
"shortName": ""
},
- "Framework": {
- "longName": "framework"
- },
- "HostingAzureSpringCloudOption": {
- "longName": "hosting-azure-spring-cloud",
+ "DiscoveryConsulOption": {
+ "longName": "discovery-consul",
"shortName": ""
},
- "HostingCloudFoundryOption": {
- "longName": "hosting-cloud-foundry",
+ "DiscoveryEurekaOption": {
+ "longName": "discovery-eureka",
"shortName": ""
},
- "HostingCloudOption": {
- "longName": "hosting-cloud",
+ "LoggingDynamicConsoleOption": {
+ "longName": "logging-dynamic-console",
"shortName": ""
},
- "LoggingDynamicLoggerOption": {
- "longName": "logging-dynamic-logger",
+ "LoggingDynamicSerilogOption": {
+ "longName": "logging-dynamic-serilog",
"shortName": ""
},
"ManagementEndpointsOption": {
"longName": "management-endpoints",
"shortName": ""
},
- "MessagingRabbitMqOption": {
- "longName": "messaging-rabbitmq",
+ "ManagementTasksOption": {
+ "longName": "management-tasks",
+ "shortName": ""
+ },
+ "DistributedTracingOption": {
+ "longName": "distributed-tracing",
"shortName": ""
},
"MessagingRabbitMqClientOption": {
@@ -104,12 +146,9 @@
"longName": "messaging-rabbitmq-listener",
"shortName": ""
},
- "SkipRestoreOption": {
- "longName": "no-restore",
+ "DataProtectionRedisOption": {
+ "longName": "data-protection-redis",
"shortName": ""
- },
- "SteeltoeVersionOption": {
- "longName": "steeltoe"
}
}
}
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/ide.host.json b/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/ide.host.json
index 388b104..a79554d 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/ide.host.json
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/ide.host.json
@@ -1,175 +1,357 @@
{
- "$schema": "https://json.schemastore.org/vs-2017.3.host",
- "learnMoreLink": "https://start.steeltoe.io/",
+ "$schema": "https://json.schemastore.org/ide.host",
"icon": "steeltoe-icon.png",
"symbolInfo": [
+ {
+ // Do not rename, this is a special entry.
+ "id": "Framework",
+ "isVisible": true
+ },
+ {
+ "id": "ChooseSteeltoeVersionInIDE",
+ "isVisible": true,
+ "name": {
+ "text": "Steeltoe version"
+ },
+ "description": {
+ "text": "The Steeltoe version to use."
+ },
+ "choices": [
+ {
+ "id": "3.2.*",
+ "name": {
+ "text": "Steeltoe 3.2"
+ }
+ },
+ {
+ "id": "4.0.*-*",
+ "name": {
+ "text": "Steeltoe 4.0"
+ }
+ }
+ ],
+ "defaultValue": "4.0.*-*"
+ },
+ {
+ "id": "DescriptionOption",
+ "name": {
+ "text": "Project description (optional)"
+ },
+ "description": {
+ "text": "Adds a description to the project file."
+ },
+ "isVisible": true
+ },
+ {
+ "id": "DockerfileOption",
+ "name": {
+ "text": "Add a Dockerfile"
+ },
+ "description": {
+ "text": "Adds a Dockerfile to the project for container support."
+ },
+ "isVisible": true
+ },
+ // Steeltoe components
{
"id": "CircuitBreakerHystrixOption",
"name": {
- "text": "Add support for Netflix Hystrix, a latency and fault tolerance library"
+ "text": "Use Netflix Hystrix (Steeltoe 3.x only)"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds support for Netflix Hystrix, a latency and fault tolerance library."
+ },
+ "isVisible": true
+ },
+ {
+ "id": "HostingCloudOption",
+ "name": {
+ "text": "Use dynamic port bindings in cloud environments (Steeltoe 3.x only)"
+ },
+ "description": {
+ "text": "Adds support for listening on the port specified by the hosting environment."
+ },
+ "isVisible": true
+ },
+ {
+ "id": "HostingAzureSpringCloudOption",
+ "name": {
+ "text": "Use Microsoft Azure Spring Cloud (Steeltoe 3.x only)"
+ },
+ "description": {
+ "text": "Adds hosting support for running on Microsoft Azure Spring Cloud."
+ },
+ "isVisible": true
+ },
+ {
+ "id": "HostingCloudFoundryOption",
+ "name": {
+ "text": "Use Cloud Foundry"
+ },
+ "description": {
+ "text": "Adds hosting support for running on Cloud Foundry."
+ },
+ "isVisible": true
},
{
"id": "ConfigurationCloudConfigOption",
"name": {
- "text": "Add a Spring Cloud Config configuration source "
+ "text": "Use Spring Cloud Config Server"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds a client for Spring Cloud Config Server to configuration."
+ },
+ "isVisible": true
+ },
+ {
+ "id": "ConfigurationEncryptionOption",
+ "name": {
+ "text": "Use encrypted configuration (Steeltoe 4.0 or higher)"
+ },
+ "description": {
+ "text": "Adds decryption of encrypted settings in configuration."
+ },
+ "isVisible": true
},
{
"id": "ConfigurationPlaceholderOption",
"name": {
- "text": "Add a placeholder configuration source"
+ "text": "Use placeholder substitution in configuration"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds placeholder substitution to configuration."
+ },
+ "isVisible": true
},
{
"id": "ConfigurationRandomValueOption",
"name": {
- "text": "Add a random value configuration source"
+ "text": "Use random values in configuration"
+ },
+ "description": {
+ "text": "Adds random value generation to configuration."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "ConnectorMongoDbOption",
+ "id": "ConfigurationSpringBootOption",
"name": {
- "text": "Add a connector for MongoDB databases"
+ "text": "Use Spring Boot configuration keys"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds support for reading Spring Boot-style keys from configuration."
+ },
+ "isVisible": true
},
{
- "id": "ConnectorMySqlEfCoreOption",
+ "id": "ConnectorCosmosDbOption",
"name": {
- "text": "Add a connector for MySQL databases using Entity Framework Core"
+ "text": "Use CosmosDB connector"
+ },
+ "description": {
+ "text": "Adds a connector for CosmosDB databases."
},
- "isVisible": "true"
+ "isVisible": true
+ },
+ {
+ "id": "ConnectorMongoDbOption",
+ "name": {
+ "text": "Use MongoDB connector"
+ },
+ "description": {
+ "text": "Adds a connector for MongoDB databases."
+ },
+ "isVisible": true
},
{
"id": "ConnectorMySqlOption",
"name": {
- "text": "Add a connector for MySQL databases"
+ "text": "Use MySQL connector with ADO.NET"
+ },
+ "description": {
+ "text": "Adds a connector for MySQL databases using ADO.NET."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "ConnectorOAuthOption",
+ "id": "ConnectorMySqlEfCoreOption",
"name": {
- "text": "Add a connector for OAuth security"
+ "text": "Use MySQL connector with Entity Framework Core"
+ },
+ "description": {
+ "text": "Adds a connector for MySQL databases using Entity Framework Core."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "ConnectorPostgreSqlEfCoreOption",
+ "id": "ConnectorOAuthOption",
"name": {
- "text": "Add a connector for PostgreSQL databases using Entity Framework Core"
+ "text": "Use OAuth connector (Steeltoe 3.x only)"
+ },
+ "description": {
+ "text": "Adds a connector for OAuth2 security on Cloud Foundry."
},
- "isVisible": "true"
+ "isVisible": true
},
{
"id": "ConnectorPostgreSqlOption",
"name": {
- "text": "Add a connector for PostgreSQL databases"
+ "text": "Use PostgreSQL connector with ADO.NET"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds a connector for PostgreSQL databases using ADO.NET."
+ },
+ "isVisible": true
+ },
+ {
+ "id": "ConnectorPostgreSqlEfCoreOption",
+ "name": {
+ "text": "Use PostgreSQL connector with Entity Framework Core"
+ },
+ "description": {
+ "text": "Adds a connector for PostgreSQL databases using Entity Framework Core."
+ },
+ "isVisible": true
},
{
"id": "ConnectorRabbitMqOption",
"name": {
- "text": "Add a connector for RabbitMQ message brokers"
+ "text": "Use RabbitMQ connector"
+ },
+ "description": {
+ "text": "Adds a connector for RabbitMQ message brokers."
},
- "isVisible": "true"
+ "isVisible": true
},
{
"id": "ConnectorRedisOption",
"name": {
- "text": "Add a connector for Redis data stores"
+ "text": "Use Redis connector"
+ },
+ "description": {
+ "text": "Adds a connector for Redis data stores."
},
- "isVisible": "true"
+ "isVisible": true
},
{
"id": "ConnectorSqlServerOption",
"name": {
- "text": "Add a connector for Microsoft SQL Server databases"
+ "text": "Use Microsoft SQL Server connector with ADO.NET"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds a connector for Microsoft SQL Server databases using ADO.NET."
+ },
+ "isVisible": true
},
{
- "id": "DescriptionOption",
+ "id": "ConnectorSqlServerEfCoreOption",
"name": {
- "text": "Add a project description"
+ "text": "Use Microsoft SQL Server connector with Entity Framework Core"
+ },
+ "description": {
+ "text": "Adds a connector for Microsoft SQL Server databases using Entity Framework Core."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "DiscoveryEurekaOption",
+ "id": "DiscoveryConsulOption",
"name": {
- "text": "Add access to Eureka, a REST-based service for locating services"
+ "text": "Use service discovery with HashiCorp Consul"
+ },
+ "description": {
+ "text": "Adds a service discovery client for HashiCorp Consul."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "DistributedTracingOption",
+ "id": "DiscoveryEurekaOption",
"name": {
- "text": "Add distributed tracing support"
+ "text": "Use service discovery with Netflix Eureka"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds a service discovery client for Netflix Eureka."
+ },
+ "isVisible": true
},
{
- "id": "DockerfileOption",
+ "id": "LoggingDynamicConsoleOption",
"name": {
- "text": "Add a Dockerfile"
+ "text": "Use dynamic console logger"
},
- "isVisible": "true"
+ "description": {
+ "text": "Enables dynamically changing minimum levels at runtime using the .NET console logger."
+ },
+ "isVisible": true
},
{
- "id": "HostingAzureSpringCloudOption",
+ "id": "LoggingDynamicSerilogOption",
"name": {
- "text": "Add hosting support for Microsoft Azure Spring Cloud"
+ "text": "Use dynamic Serilog logger"
+ },
+ "description": {
+ "text": "Enables dynamically changing minimum levels at runtime using Serlog."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "HostingCloudFoundryOption",
+ "id": "ManagementEndpointsOption",
"name": {
- "text": "Add hosting support for Cloud Foundry"
+ "text": "Use management endpoints"
+ },
+ "description": {
+ "text": "Adds management endpoints, providing info about versions, configuration, mapped routes and HTTP traffic, heap/thread dumps, health checks and changing log levels."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "HostingCloudOption",
+ "id": "ManagementTasksOption",
"name": {
- "text": "Add hosting support for clouds"
+ "text": "Use management tasks"
+ },
+ "description": {
+ "text": "Adds task execution, based on command-line arguments."
},
- "isVisible": "true"
+ "isVisible": true
},
{
- "id": "LoggingDynamicLoggerOption",
+ "id": "DistributedTracingOption",
"name": {
- "text": "Add a dynamic logger"
+ "text": "Use distributed tracing"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds distributed tracing support."
+ },
+ "isVisible": true
},
{
- "id": "ManagementEndpointsOption",
+ "id": "MessagingRabbitMqClientOption",
"name": {
- "text": "Add application management endpoints, such as health and metrics"
+ "text": "Use RabbitMQ client service (Steeltoe 3.x only)"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds a RabbitMQ client service for sending and receiving messages."
+ },
+ "isVisible": true
},
{
- "id": "MessagingRabbitMqClientOption",
+ "id": "MessagingRabbitMqListenerOption",
"name": {
- "text": "Add a RabbitMQ client service for sending and receiving messages"
+ "text": "Use RabbitMQ listener service (Steeltoe 3.x only)"
},
- "isVisible": "true"
+ "description": {
+ "text": "Adds a RabbitMQ listener service for processing messages."
+ },
+ "isVisible": true
},
{
- "id": "MessagingRabbitMqListenerOption",
+ "id": "DataProtectionRedisOption",
"name": {
- "text": "Add a RabbitMQ listener service for processing messages"
+ "text": "Use data protection with Redis"
+ },
+ "description": {
+ "text": "Configures the ASP.NET data protection system to persist keys in a Redis database."
},
- "isVisible": "true"
+ "isVisible": true
}
]
}
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/template.json b/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/template.json
index 3248b2b..12b8355 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/template.json
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/.template.config/template.json
@@ -1,12 +1,15 @@
{
"$schema": "https://json.schemastore.org/template",
- "author": "VMware",
+ "author": "Broadcom",
"classifications": [
"Web",
- "WebAPI",
+ "Web API",
+ "API",
+ "Cloud",
"Steeltoe"
],
- "name": "Steeltoe Web API",
+ "name": "Steeltoe ASP.NET Core Web API",
+ "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs with Steeltoe components.",
"identity": "steeltoe.webapi.csharp",
"groupIdentity": "steeltoe.webapi",
"shortName": "steeltoe-webapi",
@@ -15,6 +18,7 @@
"language": "C#"
},
"sourceName": "Company.WebApplication.CS",
+ "defaultName": "SteeltoeWebApi",
"sources": [
{
"modifiers": [
@@ -26,14 +30,13 @@
]
},
{
- "condition": "(!AnyEfCore)",
+ "condition": "(!HasAnyEfCoreConnector)",
"exclude": [
- "Models/ErrorViewModel.cs",
- "Models/SampleContext.cs"
+ "AppDbContext.cs"
]
},
{
- "condition": "(!CircuitBreakerHystrixOption)",
+ "condition": "(!HasCircuitBreakerHystrixInSteeltoeV3)",
"exclude": [
"HelloHystrixCommand.cs"
]
@@ -45,350 +48,738 @@
]
},
{
- "condition": "(!MessagingRabbitMqClient)",
+ "condition": "(!HasMessagingRabbitMqListenerInSteeltoeV3)",
"exclude": [
- "Controllers/RabbitMessageController.cs"
- ]
- },
- {
- "condition": "(!MessagingRabbitMqListener)",
- "exclude": [
- "Services/RabbitListenerService.cs"
+ "RabbitListenerService.cs"
]
}
]
}
],
"symbols": {
- "AnyCloudManagement": {
- "type": "computed",
- "value": "CircuitBreakerHystrixOption || DiscoveryEurekaOption || HostingAzureSpringCloudOption || HostingCloudFoundryOption || LoggingDynamicLoggerOption || ManagementEndpointsOption"
+ "Framework": {
+ "description": "The target framework for the project.",
+ "type": "parameter",
+ "datatype": "choice",
+ "choices": [
+ {
+ "choice": "net6.0",
+ "description": "Target net6.0"
+ },
+ {
+ "choice": "net8.0",
+ "description": "Target net8.0"
+ },
+ {
+ "choice": "net9.0",
+ "description": "Target net9.0"
+ }
+ ],
+ "defaultValue": "net8.0",
+ "replaces": "$(FrameworkOption)"
},
- "AnyConfiguration": {
- "type": "computed",
- "value": "ConfigurationCloudConfigOption || ConfigurationPlaceholderOption || ConfigurationRandomValueOption"
+ "IsFrameworkNet60": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "Framework",
+ "pattern": "^net6\\.0$"
+ }
},
- "AnyConnector": {
- "type": "computed",
- "value": "ConnectorMongoDbOption || ConnectorMySqlEfCoreOption || ConnectorMySqlOption || ConnectorOAuthOption || ConnectorPostgreSqlEfCoreOption || ConnectorPostgreSqlOption || ConnectorRedisOption || ConnectorRabbitMqOption || ConnectorSqlServerOption"
+ "IsFrameworkNet80": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "Framework",
+ "pattern": "^net8\\.0$"
+ }
},
- "AnyEfCore": {
- "type": "computed",
- "value": "ConnectorMySqlEfCoreOption || ConnectorPostgreSqlEfCoreOption"
+ "IsFrameworkNet90": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "Framework",
+ "pattern": "^net9\\.0$"
+ }
},
- "AnyHosting": {
- "type": "computed",
- "value": "HostingCloudFoundryOption || HostingCloudOption"
+ "SteeltoeVersionOption": {
+ "description": "The Steeltoe version to use.",
+ "type": "parameter",
+ "datatype": "string",
+ "defaultValue": "4.0.*-*",
+ "replaces": "$(SteeltoeVersionInCLI)"
},
- "AnyMessagingRabbitMq": {
- "type": "computed",
- "value": "MessagingRabbitMqClient || MessagingRabbitMqListener"
+ "IsSteeltoeV3InCLI": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "SteeltoeVersionOption",
+ "pattern": "^3"
+ }
},
- "AnySql": {
- "type": "computed",
- "value": "ConnectorMySqlOption || ConnectorPostgreSqlOption || ConnectorSqlServerOption"
+ "IsSteeltoeV4InCLI": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "SteeltoeVersionOption",
+ "pattern": "^4"
+ }
+ },
+ "ChooseSteeltoeVersionInIDE": {
+ "type": "parameter",
+ "datatype": "choice",
+ "choices": [
+ {
+ "choice": "3.2.*"
+ },
+ {
+ "choice": "4.0.*-*"
+ }
+ ],
+ "replaces": "$(ChosenSteeltoeVersionInIDE)"
+ },
+ "HasChosenSteeltoeVersionInIDE": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "ChooseSteeltoeVersionInIDE",
+ "pattern": "^.+$"
+ }
+ },
+ "HasChosenSteeltoeV3InIDE": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "ChooseSteeltoeVersionInIDE",
+ "pattern": "^3"
+ }
},
- "AnySteeltoe": {
+ "HasChosenSteeltoeV4InIDE": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "ChooseSteeltoeVersionInIDE",
+ "pattern": "^4"
+ }
+ },
+ "IsSteeltoeV3": {
"type": "computed",
- "value": "AnyCloudManagement || AnyConfiguration || AnyConnector || AnyHosting || AnyMessagingRabbitMq || AnyTracing"
+ "value": "(HasChosenSteeltoeVersionInIDE && HasChosenSteeltoeV3InIDE) || (!HasChosenSteeltoeVersionInIDE && IsSteeltoeV3InCLI)"
},
- "AnyTracing": {
+ "IsSteeltoeV4": {
"type": "computed",
- "value": "DistributedTracingOption"
+ "value": "(HasChosenSteeltoeVersionInIDE && HasChosenSteeltoeV4InIDE) || (!HasChosenSteeltoeVersionInIDE && IsSteeltoeV4InCLI)"
},
- "ApplicationPort": {
+ "DescriptionOption": {
+ "description": "Add a project description.",
+ "type": "parameter",
+ "datatype": "string",
+ "defaultValue": "",
+ "replaces": "$(DescriptionOption)"
+ },
+ "HasDescription": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "source": "DescriptionOption",
+ "pattern": "^.+$"
+ }
+ },
+ "DockerfileOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add a Dockerfile.",
+ "defaultValue": "false"
+ },
+ "kestrelHttpPort": {
+ "type": "parameter",
+ "datatype": "integer",
+ "description": "Port number to use for the HTTP endpoint in launchSettings.json."
+ },
+ "kestrelHttpPortGenerated": {
+ "type": "generated",
+ "generator": "port",
+ "parameters": {
+ "low": 5002,
+ "high": 5300
+ }
+ },
+ "kestrelHttpPortReplacer": {
+ "type": "generated",
+ "generator": "coalesce",
+ "parameters": {
+ "sourceVariableName": "kestrelHttpPort",
+ "fallbackVariableName": "kestrelHttpPortGenerated"
+ },
+ "replaces": "5000"
+ },
+ "kestrelHttpsPort": {
+ "type": "parameter",
+ "datatype": "integer",
+ "description": "Port number to use for the HTTPS endpoint in launchSettings.json."
+ },
+ "kestrelHttpsPortGenerated": {
"type": "generated",
"generator": "port",
- "replaces": "8080"
+ "parameters": {
+ "low": 7000,
+ "high": 7300
+ }
},
- "AzureOAuthVersion": {
+ "kestrelHttpsPortReplacer": {
"type": "generated",
- "generator": "constant",
+ "generator": "coalesce",
"parameters": {
- "value": "3.1.*"
+ "sourceVariableName": "kestrelHttpsPort",
+ "fallbackVariableName": "kestrelHttpsPortGenerated"
},
- "replaces": "$(AzureOAuthVersion)"
+ "replaces": "5001"
+ },
+ "SkipRestoreOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "If specified, skips the automatic restore of the project on create.",
+ "defaultValue": "false"
},
+ // Steeltoe components
"CircuitBreakerHystrixOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add support for Netflix Hystrix, a latency and fault tolerance library.",
+ "description": "Add support for Netflix Hystrix, a latency and fault tolerance library (Steeltoe 3.x only).",
"defaultValue": "false"
},
+ "HasCircuitBreakerHystrixInSteeltoeV3": {
+ "type": "computed",
+ "value": "CircuitBreakerHystrixOption && IsSteeltoeV3"
+ },
+ "HostingCloudOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add support for listening on the port specified by the hosting environment (Steeltoe 3.x only).",
+ "defaultValue": "false"
+ },
+ "HostingAzureSpringCloudOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add hosting support for running on Microsoft Azure Spring Cloud (Steeltoe 3.x only).",
+ "defaultValue": "false"
+ },
+ "HasHostingAzureSpringCloudInSteeltoeV3": {
+ "type": "computed",
+ "value": "HostingAzureSpringCloudOption && IsSteeltoeV3"
+ },
+ "HostingCloudFoundryOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add hosting support for running on Cloud Foundry.",
+ "defaultValue": "false"
+ },
+ "HasHostingCloudFoundryInSteeltoeV3": {
+ "type": "computed",
+ "value": "HostingCloudFoundryOption && IsSteeltoeV3"
+ },
+ "HasHostingCloudFoundryInSteeltoeV4": {
+ "type": "computed",
+ "value": "HostingCloudFoundryOption && IsSteeltoeV4"
+ },
+ "HasAnyNonAzureHostingInSteeltoeV3": {
+ "type": "computed",
+ "value": "(HostingCloudFoundryOption || HostingCloudOption) && IsSteeltoeV3"
+ },
+ "HasAnyHostingInSteeltoeV3": {
+ "type": "computed",
+ "value": "HasHostingAzureSpringCloudInSteeltoeV3 || HasAnyNonAzureHostingInSteeltoeV3"
+ },
"ConfigurationCloudConfigOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a Spring Cloud Config configuration source.",
+ "description": "Add a client for Spring Cloud Config Server to configuration.",
"defaultValue": "false"
},
+ "HasConfigurationCloudConfigInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConfigurationCloudConfigOption && IsSteeltoeV3"
+ },
+ "HasConfigurationCloudConfigInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConfigurationCloudConfigOption && IsSteeltoeV4"
+ },
+ "ConfigurationEncryptionOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add decryption of encrypted settings in configuration (Steeltoe 4.0 or higher).",
+ "defaultValue": "false"
+ },
+ "HasConfigurationEncryptionInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConfigurationEncryptionOption && IsSteeltoeV4"
+ },
"ConfigurationPlaceholderOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a placeholder configuration source.",
+ "description": "Add placeholder substitution to configuration.",
"defaultValue": "false"
},
+ "HasConfigurationPlaceholderInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConfigurationPlaceholderOption && IsSteeltoeV3"
+ },
+ "HasConfigurationPlaceholderInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConfigurationPlaceholderOption && IsSteeltoeV4"
+ },
"ConfigurationRandomValueOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a random value configuration source.",
+ "description": "Add random value generation to configuration.",
+ "defaultValue": "false"
+ },
+ "HasConfigurationRandomValueInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConfigurationRandomValueOption && IsSteeltoeV3"
+ },
+ "HasConfigurationRandomValueInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConfigurationRandomValueOption && IsSteeltoeV4"
+ },
+ "ConfigurationSpringBootOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add support for reading Spring Boot-style keys from configuration.",
"defaultValue": "false"
},
+ "HasConfigurationSpringBootInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConfigurationSpringBootOption && IsSteeltoeV3"
+ },
+ "HasConfigurationSpringBootInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConfigurationSpringBootOption && IsSteeltoeV4"
+ },
+ "HasAnyConfiguration": {
+ "type": "computed",
+ "value": "HostingCloudFoundryOption || ConfigurationCloudConfigOption || HasConfigurationEncryptionInSteeltoeV4 || ConfigurationPlaceholderOption || ConfigurationRandomValueOption || ConfigurationSpringBootOption"
+ },
+ "ConnectorCosmosDbOption": {
+ "type": "parameter",
+ "datatype": "bool",
+ "description": "Add a connector for CosmosDB databases.",
+ "defaultValue": "false"
+ },
+ "HasConnectorCosmosDbInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorCosmosDbOption && IsSteeltoeV3"
+ },
+ "HasConnectorCosmosDbInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConnectorCosmosDbOption && IsSteeltoeV4"
+ },
"ConnectorMongoDbOption": {
"type": "parameter",
"datatype": "bool",
"description": "Add a connector for MongoDB databases.",
"defaultValue": "false"
},
- "ConnectorMySqlEfCoreOption": {
+ "HasConnectorMongoDbInV3": {
+ "type": "computed",
+ "value": "ConnectorMongoDbOption && IsSteeltoeV3"
+ },
+ "HasConnectorMongoDbInV4": {
+ "type": "computed",
+ "value": "ConnectorMongoDbOption && IsSteeltoeV4"
+ },
+ "ConnectorMySqlOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a connector for MySQL databases using Entity Framework Core.",
+ "description": "Add a connector for MySQL databases using ADO.NET.",
"defaultValue": "false"
},
- "ConnectorMySqlOption": {
+ "HasConnectorMySqlInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorMySqlOption && IsSteeltoeV3"
+ },
+ "HasConnectorMySqlInSteeltoeV4": {
+ "type": "computed",
+ "value": "(ConnectorMySqlOption || ConnectorMySqlEfCoreOption) && IsSteeltoeV4"
+ },
+ "ConnectorMySqlEfCoreOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a connector for MySQL databases.",
+ "description": "Add a connector for MySQL databases using Entity Framework Core.",
"defaultValue": "false"
},
+ "HasConnectorMySqlEfCoreInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorMySqlEfCoreOption && IsSteeltoeV3"
+ },
+ "HasConnectorMySqlEfCoreInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConnectorMySqlEfCoreOption && IsSteeltoeV4"
+ },
"ConnectorOAuthOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a connector for OAuth security.",
+ "description": "Add a connector for OAuth2 security on Cloud Foundry (Steeltoe 3.x only).",
"defaultValue": "false"
},
- "ConnectorPostgreSqlEfCoreOption": {
+ "HasConnectorOAuthInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorOAuthOption && IsSteeltoeV3"
+ },
+ "ConnectorPostgreSqlOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a connector for PostgreSQL databases using Entity Framework Core.",
+ "description": "Add a connector for PostgreSQL databases using ADO.NET.",
"defaultValue": "false"
},
- "ConnectorPostgreSqlOption": {
+ "HasConnectorPostgreSqlInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorPostgreSqlOption && IsSteeltoeV3"
+ },
+ "HasConnectorPostgreSqlInSteeltoeV4": {
+ "type": "computed",
+ "value": "(ConnectorPostgreSqlOption || ConnectorPostgreSqlEfCoreOption) && IsSteeltoeV4"
+ },
+ "ConnectorPostgreSqlEfCoreOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a connector for PostgreSQL databases.",
+ "description": "Add a connector for PostgreSQL databases using Entity Framework Core.",
"defaultValue": "false"
},
+ "HasConnectorPostgreSqlEfCoreInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorPostgreSqlEfCoreOption && IsSteeltoeV3"
+ },
+ "HasConnectorPostgreSqlEfCoreInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConnectorPostgreSqlEfCoreOption && IsSteeltoeV4"
+ },
"ConnectorRabbitMqOption": {
"type": "parameter",
"datatype": "bool",
"description": "Add a connector for RabbitMQ message brokers.",
"defaultValue": "false"
},
+ "HasConnectorRabbitMqInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorRabbitMqOption && IsSteeltoeV3"
+ },
+ "HasConnectorRabbitMqInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConnectorRabbitMqOption && IsSteeltoeV4"
+ },
"ConnectorRedisOption": {
"type": "parameter",
"datatype": "bool",
"description": "Add a connector for Redis data stores.",
"defaultValue": "false"
},
+ "HasConnectorRedisInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorRedisOption && IsSteeltoeV3"
+ },
+ "HasConnectorRedisInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConnectorRedisOption && IsSteeltoeV4"
+ },
"ConnectorSqlServerOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a connector for Microsoft SQL Server databases.",
+ "description": "Add a connector for Microsoft SQL Server databases using ADO.NET.",
"defaultValue": "false"
},
- "DescriptionOption": {
- "description": "Add a project description.",
- "type": "parameter",
- "datatype": "string",
- "defaultValue": "",
- "replaces": "$(DescriptionOption)"
+ "HasConnectorSqlServerInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorSqlServerOption && IsSteeltoeV3"
},
- "DiscoveryEurekaOption": {
+ "HasConnectorSqlServerInSteeltoeV4": {
+ "type": "computed",
+ "value": "(ConnectorSqlServerOption || ConnectorSqlServerEfCoreOption) && IsSteeltoeV4"
+ },
+ "ConnectorSqlServerEfCoreOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add access to Eureka, a REST-based service for locating services.",
+ "description": "Add a connector for Microsoft SQL Server databases using Entity Framework Core.",
"defaultValue": "false"
},
- "DistributedTracingOption": {
+ "HasConnectorSqlServerEfCoreInSteeltoeV3": {
+ "type": "computed",
+ "value": "ConnectorSqlServerEfCoreOption && IsSteeltoeV3"
+ },
+ "HasConnectorSqlServerEfCoreInSteeltoeV4": {
+ "type": "computed",
+ "value": "ConnectorSqlServerEfCoreOption && IsSteeltoeV4"
+ },
+ "HasAnyConnector": {
+ "type": "computed",
+ "value": "ConnectorCosmosDbOption || ConnectorMongoDbOption || ConnectorMySqlOption || ConnectorMySqlEfCoreOption || HasConnectorOAuthInSteeltoeV3 || ConnectorPostgreSqlOption || ConnectorPostgreSqlEfCoreOption || ConnectorRabbitMqOption || ConnectorRedisOption || ConnectorSqlServerOption || ConnectorSqlServerEfCoreOption"
+ },
+ "HasAnyConnectorInSteeltoeV3": {
+ "type": "computed",
+ "value": "(HasAnyConnector || DataProtectionRedisOption) && IsSteeltoeV3"
+ },
+ "HasAnyConnectorInSteeltoeV4": {
+ "type": "computed",
+ "value": "HasAnyConnector && IsSteeltoeV4"
+ },
+ "HasAnyEfCoreConnector": {
+ "type": "computed",
+ "value": "ConnectorMySqlEfCoreOption || ConnectorPostgreSqlEfCoreOption || ConnectorSqlServerEfCoreOption"
+ },
+ "HasAnyEfCoreConnectorInSteeltoeV3": {
+ "type": "computed",
+ "value": "HasAnyEfCoreConnector && IsSteeltoeV3"
+ },
+ "HasAnyEfCoreConnectorInSteeltoeV4": {
+ "type": "computed",
+ "value": "HasAnyEfCoreConnector && IsSteeltoeV4"
+ },
+ "DiscoveryConsulOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add distributed tracing support.",
+ "description": "Add a service discovery client for HashiCorp Consul.",
"defaultValue": "false"
},
- "DockerImageTag": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.0-alpine"
- }
+ "HasDiscoveryConsulInSteeltoeV4": {
+ "type": "computed",
+ "value": "DiscoveryConsulOption && IsSteeltoeV4"
},
- "DockerfileOption": {
+ "DiscoveryEurekaOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a Dockerfile.",
+ "description": "Add a service discovery client for Netflix Eureka.",
"defaultValue": "false"
},
- "DynamicLogging": {
+ "HasDiscoveryEurekaInSteeltoeV4": {
"type": "computed",
- "value": "LoggingDynamicLoggerOption || ManagementEndpointsOption"
+ "value": "DiscoveryEurekaOption && IsSteeltoeV4"
},
- "AnyBuilderOptions": {
+ "HasAnyDiscovery": {
"type": "computed",
- "value": "ConfigurationPlaceholderOption || HostingAzureSpringCloudOption || AnyHosting || HostingCloudFoundryOption || ConfigurationCloudConfigOption || ConfigurationRandomValueOption || DynamicLogging"
- },
- "EntityFrameworkCoreVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.0.*"
- },
- "replaces": "$(EntityFrameworkCoreVersion)"
+ "value": "DiscoveryConsulOption || DiscoveryEurekaOption"
},
- "Framework": {
- "description": "Set the target framework for the project.",
- "type": "parameter",
- "datatype": "choice",
- "choices": [
- {
- "choice": "net6.0"
- },
- {
- "choice": "net8.0"
- }
- ],
- "defaultValue": "net8.0",
- "replaces": "$(FrameworkOption)"
+ "HasAnyDiscoveryInSteeltoeV3": {
+ "type": "computed",
+ "value": "HasAnyDiscovery && IsSteeltoeV3"
},
- "FrameworkNet60": {
- "type": "generated",
- "generator": "regexMatch",
+ "LoggingDynamicConsoleOption": {
+ "type": "parameter",
"datatype": "bool",
- "parameters": {
- "source": "Framework",
- "pattern": "^net6.0$"
- }
+ "description": "Enable dynamically changing minimum levels at runtime using the .NET console logger.",
+ "defaultValue": "false"
},
- "FrameworkNet80": {
- "type": "generated",
- "generator": "regexMatch",
- "datatype": "bool",
- "parameters": {
- "source": "Framework",
- "pattern": "^net8.0$"
- }
+ "HasLoggingDynamicConsoleInSteeltoeV3": {
+ "type": "computed",
+ "value": "LoggingDynamicConsoleOption && IsSteeltoeV3"
},
- "HasDescription": {
- "type": "generated",
- "generator": "regexMatch",
- "datatype": "bool",
- "parameters": {
- "source": "DescriptionOption",
- "pattern": "^.+"
- }
+ "HasLoggingDynamicConsoleInSteeltoeV4": {
+ "type": "computed",
+ "value": "LoggingDynamicConsoleOption && IsSteeltoeV4"
},
- "HostingAzureSpringCloudOption": {
+ "LoggingDynamicSerilogOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add hosting support for Microsoft Azure Spring Cloud.",
+ "description": "Enable dynamically changing minimum levels at runtime using Serlog.",
"defaultValue": "false"
},
- "HostingCloudFoundryOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add hosting support for Cloud Foundry.",
- "defaultValue": "false"
+ "HasLoggingDynamicSerilogInSteeltoeV3": {
+ "type": "computed",
+ "value": "LoggingDynamicSerilogOption && IsSteeltoeV3"
},
- "HostingCloudOption": {
+ "HasLoggingDynamicSerilogInSteeltoeV4": {
+ "type": "computed",
+ "value": "LoggingDynamicSerilogOption && IsSteeltoeV4"
+ },
+ "HasAnyLogging": {
+ "type": "computed",
+ "value": "LoggingDynamicConsoleOption || LoggingDynamicSerilogOption"
+ },
+ "ManagementEndpointsOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add hosting support for clouds.",
+ "description": "Add management endpoints, providing info about versions, configuration, mapped routes and HTTP traffic, heap/thread dumps, health checks and changing log levels.",
"defaultValue": "false"
},
- "LoggingDynamicLoggerOption": {
+ "HasManagementEndpointsInSteeltoeV3": {
+ "type": "computed",
+ "value": "ManagementEndpointsOption && IsSteeltoeV3"
+ },
+ "HasManagementEndpointsInSteeltoeV4": {
+ "type": "computed",
+ "value": "ManagementEndpointsOption && IsSteeltoeV4"
+ },
+ "ManagementTasksOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a dynamic logger.",
+ "description": "Add task execution, based on command-line arguments.",
"defaultValue": "false"
},
- "ManagementEndpointsOption": {
+ "HasManagementTasksInSteeltoeV3": {
+ "type": "computed",
+ "value": "ManagementTasksOption && IsSteeltoeV3"
+ },
+ "HasManagementTasksInSteeltoeV4": {
+ "type": "computed",
+ "value": "ManagementTasksOption && IsSteeltoeV4"
+ },
+ "DistributedTracingOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add application management endpoints, such as health and metrics.",
+ "description": "Add distributed tracing support.",
"defaultValue": "false"
},
- "MessagingRabbitMq": {
+ "HasDistributedTracingInSteeltoeV3": {
+ "type": "computed",
+ "value": "DistributedTracingOption && IsSteeltoeV3"
+ },
+ "HasDistributedTracingInSteeltoeV4": {
+ "type": "computed",
+ "value": "DistributedTracingOption && IsSteeltoeV4"
+ },
+ "HasAnyManagement": {
"type": "computed",
- "value": "MessagingRabbitMqOption"
+ "value": "ManagementEndpointsOption || ManagementTasksOption || DistributedTracingOption"
},
- "MessagingRabbitMqOption": {
+ "MessagingRabbitMqClientOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add both RabbitMQ client and listener services.\nSame as specifying --messaging-rabbitmq-client and --messaging-rabbitmq-listener.",
+ "description": "Add a RabbitMQ client service for sending and receiving messages (Steeltoe 3.x only).",
"defaultValue": "false"
},
- "MessagingRabbitMqClient": {
+ "HasMessagingRabbitMqClientInSteeltoeV3": {
"type": "computed",
- "value": "(MessagingRabbitMqClientOption) || MessagingRabbitMq"
+ "value": "MessagingRabbitMqClientOption && IsSteeltoeV3"
},
- "MessagingRabbitMqClientOption": {
+ "MessagingRabbitMqListenerOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a RabbitMQ client controller for sending and receiving messages.",
+ "description": "Add a RabbitMQ listener service for processing messages (Steeltoe 3.x only).",
"defaultValue": "false"
},
- "MessagingRabbitMqListener": {
+ "HasMessagingRabbitMqListenerInSteeltoeV3": {
"type": "computed",
- "value": "(MessagingRabbitMqListenerOption) || MessagingRabbitMq"
+ "value": "MessagingRabbitMqListenerOption && IsSteeltoeV3"
},
- "MessagingRabbitMqListenerOption": {
+ "HasAnyMessagingRabbitMqInSteeltoeV3": {
+ "type": "computed",
+ "value": "HasMessagingRabbitMqClientInSteeltoeV3 || HasMessagingRabbitMqListenerInSteeltoeV3"
+ },
+ "DataProtectionRedisOption": {
"type": "parameter",
"datatype": "bool",
- "description": "Add a RabbitMQ listener service for processing messages.",
+ "description": "Configure the ASP.NET data protection system to persist keys in a Redis database.",
"defaultValue": "false"
},
- "MongoDbDriverVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "2.19.*"
- },
- "replaces": "$(MongoDbDriverVersion)"
+ "HasDataProtectionRedisInSteeltoeV3": {
+ "type": "computed",
+ "value": "DataProtectionRedisOption && IsSteeltoeV3"
+ },
+ "HasDataProtectionRedisInSteeltoeV4": {
+ "type": "computed",
+ "value": "DataProtectionRedisOption && IsSteeltoeV4"
},
- "MySqlDriverVersion": {
+ "HasAnyRedisInSteeltoeV3": {
+ "type": "computed",
+ "value": "(ConnectorRedisOption || DataProtectionRedisOption) && IsSteeltoeV3"
+ },
+ "HasAnyRedisInSteeltoeV4": {
+ "type": "computed",
+ "value": "(ConnectorRedisOption || DataProtectionRedisOption) && IsSteeltoeV4"
+ },
+ "HasAnySteeltoe": {
+ "type": "computed",
+ "value": "HasCircuitBreakerHystrixInSteeltoeV3 || HasAnyHostingInSteeltoeV3 || HasAnyConfiguration || HasAnyConnector || HasAnyDiscovery || HasAnyLogging || HasAnyManagement || HasAnyMessagingRabbitMqInSteeltoeV3 || DataProtectionRedisOption"
+ },
+ "RequiresProjectNamespaceImport": {
+ "type": "computed",
+ "value": "HasCircuitBreakerHystrixInSteeltoeV3 || HasAnyEfCoreConnector || HasMessagingRabbitMqListenerInSteeltoeV3"
+ },
+ // NuGet package versions.
+ "CalculateAspNetCorePackageVersion": {
"type": "generated",
- "generator": "constant",
+ "generator": "regex",
+ "datatype": "string",
+ "replaces": "$(AspNetCoreVersion)",
"parameters": {
- "value": "8.0.*"
- },
- "replaces": "$(MySqlDriverVersion)"
+ "source": "Framework",
+ "steps": [
+ {
+ "regex": "^net([0-9]+)\\.0$",
+ "replacement": "$1.0.*"
+ }
+ ]
+ }
},
- "NpgsqlDriverVersion": {
+ "CalculateSqlClientVersion": {
"type": "generated",
- "generator": "constant",
+ "generator": "switch",
+ "replaces": "$(SqlClientVersion)",
"parameters": {
- "value": "6.0.*"
- },
- "replaces": "$(NpgsqlDriverVersion)"
+ "datatype": "string",
+ "cases": [
+ {
+ "condition": "(Framework == 'net9.0')",
+ "value": "6.0.*"
+ },
+ {
+ "condition": "(Framework == 'net8.0')",
+ "value": "6.0.*"
+ },
+ {
+ "condition": "(Framework == 'net6.0')",
+ "value": "5.2.*"
+ }
+ ]
+ }
},
- "RabbitMqDriverVersion": {
+ "CalculateMySqlVersion": {
"type": "generated",
- "generator": "constant",
+ "generator": "switch",
+ "replaces": "$(MySqlVersion)",
"parameters": {
- "value": "6.4.*"
- },
- "replaces": "$(RabbitMqDriverVersion)"
+ "datatype": "string",
+ "cases": [
+ {
+ "condition": "(Framework == 'net9.0')",
+ "value": "9.2.*"
+ },
+ {
+ "condition": "(Framework == 'net8.0')",
+ "value": "9.2.*"
+ },
+ {
+ "condition": "(Framework == 'net6.0')",
+ "value": "9.1.*"
+ }
+ ]
+ }
},
- "RedisDriverVersion": {
+ "CalculateRabbitMqVersion": {
"type": "generated",
- "generator": "constant",
+ "generator": "switch",
+ "replaces": "$(RabbitMqVersion)",
"parameters": {
- "value": "6.0.*"
- },
- "replaces": "$(RedisDriverVersion)"
- },
- "SkipRestoreOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Skip the automatic restore of the project on create.",
- "defaultValue": "false"
- },
- "SteeltoeVersionOption": {
- "description": "Set the Steeltoe version for the project.",
- "type": "parameter",
- "datatype": "string",
- "defaultValue": "3.2.*",
- "replaces": "$(SteeltoeVersionOption)"
+ "datatype": "string",
+ "cases": [
+ {
+ "condition": "(IsSteeltoeV3)",
+ "value": "5.2.*"
+ },
+ {
+ "condition": "True == True",
+ "value": "7.1.*"
+ }
+ ]
+ }
}
},
"primaryOutputs": [
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/AppDbContext.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/AppDbContext.cs
new file mode 100644
index 0000000..61e2fd0
--- /dev/null
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/AppDbContext.cs
@@ -0,0 +1,21 @@
+#if (HasAnyEfCoreConnector)
+using Microsoft.EntityFrameworkCore;
+
+namespace Company.WebApplication.CS;
+
+public sealed class AppDbContext : DbContext
+{
+ public DbSet Entities => Set();
+
+ public AppDbContext(DbContextOptions options)
+ : base(options)
+ {
+ }
+}
+
+public sealed class ExampleEntity
+{
+ public long Id { get; set; }
+ public string? Data { get; set; }
+}
+#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.csproj b/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.csproj
index a038527..6368574 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.csproj
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.csproj
@@ -10,40 +10,69 @@
- $(SteeltoeVersionOption)
+
+ $(ChosenSteeltoeVersionInIDE)
+
+ $(SteeltoeVersionInCLI)
+
-
-
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.http b/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.http
new file mode 100644
index 0000000..bc77e67
--- /dev/null
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/Company.WebApplication.CS.http
@@ -0,0 +1,6 @@
+@Company.WebApplication.CS_HostAddress = http://localhost:5000
+
+GET {{Company.WebApplication.CS_HostAddress}}/weatherforecast/
+Accept: application/json
+
+###
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/RabbitMessageController.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/RabbitMessageController.cs
deleted file mode 100644
index 47967f6..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/RabbitMessageController.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-#if (MessagingRabbitMqClient)
-#if (FrameworkNet60)
-using Microsoft.AspNetCore.Mvc;
-using Steeltoe.Messaging.RabbitMQ.Core;
-
-namespace Company.WebApplication.CS.Controller
-{
- [ApiController]
- [Route("[controller]")]
- public class RabbitMessageController : ControllerBase
- {
- private readonly ILogger _logger;
- private readonly RabbitTemplate _rabbitTemplate;
- private readonly RabbitAdmin _rabbitAdmin;
-
- public RabbitMessageController(ILogger logger, RabbitTemplate rabbitTemplate, RabbitAdmin rabbitAdmin)
- {
- _logger = logger;
- _rabbitTemplate = rabbitTemplate;
- _rabbitAdmin = rabbitAdmin;
- }
-
- [HttpGet()]
- public ActionResult Index()
- {
- var msg = "Hi there from over here.";
- _rabbitTemplate.ConvertAndSend("steeltoe_message_queue", msg);
- _logger.LogInformation($"Sending message '{msg}' to queue 'steeltoe_message_queue'");
- return "Message sent to queue.";
- }
- }
-}
-#endif
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/WeatherForecastController.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/WeatherForecastController.cs
deleted file mode 100644
index 8b1d515..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Controllers/WeatherForecastController.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-#if (FrameworkNet60)
-using Microsoft.AspNetCore.Mvc;
-
-namespace Company.WebApplication.CS.Controllers
-{
- [ApiController]
- [Route("[controller]")]
- public class WeatherForecastController : ControllerBase
- {
- private static readonly string[] Summaries = new[]
- {
- "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
- };
-
- private readonly ILogger _logger;
-
- public WeatherForecastController(ILogger logger)
- {
- _logger = logger;
- }
-
- [HttpGet(Name = "GetWeatherForecast")]
- public IEnumerable Get()
- {
- _logger.LogInformation("Getting forecast");
- var rng = new Random();
- return Enumerable.Range(1, 5).Select(index => new WeatherForecast
- {
- Date = DateTime.Now.AddDays(index),
- TemperatureC = rng.Next(-20, 55),
- Summary = Summaries[rng.Next(Summaries.Length)]
- })
- .ToArray();
- }
- }
-}
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Directory.Build.props b/src/Content/NetCoreTool.Template.WebApi/CSharp/Directory.Build.props
index c30a176..9d6f069 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Directory.Build.props
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/Directory.Build.props
@@ -1,42 +1,7 @@
-
- 3.1.*
- 2.0.0-preview.1
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
-
- false
- false
- 6.0.*
- net6.0
- true
- false
- false
- false
- false
- false
- false
- false
- false
- 2.19.*
- 8.0.*
- 6.0.*
- 6.4.*
- 6.0.*
- 3.2.*
- false
+
+ net8.0
+ true
-
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Dockerfile b/src/Content/NetCoreTool.Template.WebApi/CSharp/Dockerfile
index 535ce9f..5cc9380 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Dockerfile
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/Dockerfile
@@ -1,31 +1,51 @@
-#if (FrameworkNet60)
-FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base
+# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
+
+# This stage is used when running from VS in fast mode (Default for Debug configuration)
+#if (IsFrameworkNet60)
+FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
+#elif (IsFrameworkNet80)
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
+#elif (IsFrameworkNet90)
+FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
#endif
-#if (FrameworkNet80)
-FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base
+#if (IsFrameworkNet80 || IsFrameworkNet90)
+USER $APP_UID
#endif
-USER app
WORKDIR /app
+#if (IsFrameworkNet60)
+EXPOSE 80
+EXPOSE 443
+#else
EXPOSE 8080
EXPOSE 8081
-#if (FrameworkNet60)
-FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
#endif
-#if (FrameworkNet80)
-FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
+
+
+# This stage is used to build the service project
+#if (IsFrameworkNet60)
+FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
+#endif
+#if (IsFrameworkNet80)
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
+#endif
+#if (IsFrameworkNet90)
+FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
#endif
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Company.WebApplication.CS.csproj", "."]
-RUN dotnet restore "Company.WebApplication.CS.csproj"
+RUN dotnet restore "./Company.WebApplication.CS.csproj"
COPY . .
-RUN dotnet build "Company.WebApplication.CS.csproj" -c $BUILD_CONFIGURATION -o /app
+WORKDIR "/src/."
+RUN dotnet build "./Company.WebApplication.CS.csproj" -c $BUILD_CONFIGURATION -o /app/build
+# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
-RUN dotnet publish "Company.WebApplication.CS.csproj" -c $BUILD_CONFIGURATION -o /app /p:UseAppHost=false
+RUN dotnet publish "./Company.WebApplication.CS.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
+# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
-COPY --from=publish /app .
+COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Company.WebApplication.CS.dll"]
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/HelloHystrixCommand.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/HelloHystrixCommand.cs
index 7640168..458009b 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/HelloHystrixCommand.cs
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/HelloHystrixCommand.cs
@@ -1,5 +1,4 @@
-#if (CircuitBreakerHystrixOption)
-using System.Threading.Tasks;
+#if (HasCircuitBreakerHystrixInSteeltoeV3)
using Steeltoe.CircuitBreaker.Hystrix;
namespace Company.WebApplication.CS
@@ -8,7 +7,8 @@ public sealed class HelloHystrixCommand : HystrixCommand
{
private readonly string _name;
- public HelloHystrixCommand(string name) : base(HystrixCommandGroupKeyDefault.AsKey("MyCircuitBreakers"))
+ public HelloHystrixCommand(string name)
+ : base(HystrixCommandGroupKeyDefault.AsKey("ExampleCircuitBreakers"))
{
_name = name;
IsFallbackUserDefined = true;
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Models/ErrorViewModel.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/Models/ErrorViewModel.cs
deleted file mode 100644
index 3c0675e..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Models/ErrorViewModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-#if (AnyEfCore)
-namespace Company.WebApplication.CS.Models
-{
- public class ErrorViewModel
- {
- public string? RequestId { get; set; }
-
- public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
- }
-}
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Models/SampleContext.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/Models/SampleContext.cs
deleted file mode 100644
index 10639a2..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Models/SampleContext.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-#if (AnyEfCore)
-using Microsoft.EntityFrameworkCore;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-
-namespace Company.WebApplication.CS.Models
-{
- public class SampleContext : DbContext
- {
- public SampleContext(DbContextOptions options) : base(options)
- {
- }
-
- public DbSet? TestData { get; set; }
- }
-
- public class TestData
- {
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.None)]
- public int Id { get; set; }
-
- public string? Data { get; set; }
- }
-}
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Program.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/Program.cs
index b6614c6..1640cd9 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Program.cs
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/Program.cs
@@ -1,191 +1,360 @@
-#if (HostingAzureSpringCloudOption)
+#if (DataProtectionRedisOption)
+using Microsoft.AspNetCore.DataProtection;
+#endif
+#if (HasMessagingRabbitMqClientInSteeltoeV3)
+using Microsoft.AspNetCore.Mvc;
+#endif
+#if (HasHostingAzureSpringCloudInSteeltoeV3)
using Microsoft.Azure.SpringCloud.Client;
#endif
-#if (CircuitBreakerHystrixOption)
+#if (HasCircuitBreakerHystrixInSteeltoeV3)
using Steeltoe.CircuitBreaker.Hystrix;
-using Company.WebApplication.CS;
#endif
-#if (AnyHosting)
+#if (HasAnyNonAzureHostingInSteeltoeV3)
using Steeltoe.Common.Hosting;
#endif
-#if(ConnectorMongoDbOption)
+#if (HasConnectorMongoDbInV3)
using Steeltoe.Connector.MongoDb;
+#elif (HasConnectorMongoDbInV4)
+using Steeltoe.Connectors.MongoDb;
#endif
-#if(ConnectorMySqlOption)
+#if (HasConnectorCosmosDbInSteeltoeV3)
+using Steeltoe.Connector;
+using Steeltoe.Connector.CosmosDb;
+#elif (HasConnectorCosmosDbInSteeltoeV4)
+using Steeltoe.Connectors.CosmosDb;
+#endif
+#if (HasConnectorMySqlInSteeltoeV3)
using Steeltoe.Connector.MySql;
+#elif (HasConnectorMySqlInSteeltoeV4)
+using Steeltoe.Connectors.MySql;
#endif
-#if(ConnectorMySqlEfCoreOption)
+#if (HasConnectorMySqlEfCoreInSteeltoeV3)
using Steeltoe.Connector.MySql.EFCore;
+#elif (HasConnectorMySqlEfCoreInSteeltoeV4)
+using Steeltoe.Connectors.EntityFrameworkCore.MySql;
#endif
-#if(ConnectorOAuthOption)
+#if (HasConnectorOAuthInSteeltoeV3)
using Steeltoe.Connector.OAuth;
#endif
-#if(ConnectorPostgreSqlOption)
+#if (HasConnectorPostgreSqlInSteeltoeV3)
using Steeltoe.Connector.PostgreSql;
+#elif (HasConnectorPostgreSqlInSteeltoeV4)
+using Steeltoe.Connectors.PostgreSql;
#endif
-#if(ConnectorPostgreSqlEfCoreOption)
+#if (HasConnectorPostgreSqlEfCoreInSteeltoeV3)
using Steeltoe.Connector.PostgreSql.EFCore;
+#elif (HasConnectorPostgreSqlEfCoreInSteeltoeV4)
+using Steeltoe.Connectors.EntityFrameworkCore.PostgreSql;
#endif
-#if(ConnectorRabbitMqOption)
+#if (HasConnectorRabbitMqInSteeltoeV3)
using Steeltoe.Connector.RabbitMQ;
+#elif (HasConnectorRabbitMqInSteeltoeV4)
+using Steeltoe.Connectors.RabbitMQ;
#endif
-#if(ConnectorRedisOption)
+#if (HasAnyRedisInSteeltoeV3)
using Steeltoe.Connector.Redis;
+#elif (HasAnyRedisInSteeltoeV4)
+using Steeltoe.Connectors.Redis;
#endif
-#if(ConnectorSqlServerOption)
+#if (HasConnectorSqlServerInSteeltoeV3)
using Steeltoe.Connector.SqlServer;
+#elif (HasConnectorSqlServerInSteeltoeV4)
+using Steeltoe.Connectors.SqlServer;
+#endif
+#if (HasConnectorSqlServerEfCoreInSteeltoeV3)
+using Steeltoe.Connector.SqlServer.EFCore;
+#elif (HasConnectorSqlServerEfCoreInSteeltoeV4)
+using Steeltoe.Connectors.EntityFrameworkCore.SqlServer;
#endif
-#if (DiscoveryEurekaOption)
+#if (HasAnyDiscoveryInSteeltoeV3)
using Steeltoe.Discovery.Client;
+#else
+#if (HasDiscoveryConsulInSteeltoeV44)
+using Steeltoe.Discovery.Consul;
#endif
-#if (HostingCloudFoundryOption)
+#if (HasDiscoveryEurekaInSteeltoeV4)
+using Steeltoe.Discovery.Eureka;
+#endif
+#endif
+#if (HasHostingCloudFoundryInSteeltoeV3)
using Steeltoe.Extensions.Configuration.CloudFoundry;
+#elif (HasHostingCloudFoundryInSteeltoeV4)
+using Steeltoe.Configuration.CloudFoundry;
#endif
-#if (ConfigurationCloudConfigOption)
+#if (HasConfigurationCloudConfigInSteeltoeV3)
using Steeltoe.Extensions.Configuration.ConfigServer;
+#elif (HasConfigurationCloudConfigInSteeltoeV4)
+using Steeltoe.Configuration.ConfigServer;
+#endif
+#if (HasConfigurationEncryptionInSteeltoeV4)
+using Steeltoe.Configuration.Encryption;
#endif
-#if (ConfigurationPlaceholderOption)
+#if (HasConfigurationPlaceholderInSteeltoeV3)
using Steeltoe.Extensions.Configuration.Placeholder;
+#elif (HasConfigurationPlaceholderInSteeltoeV4)
+using Steeltoe.Configuration.Placeholder;
#endif
-#if (ConfigurationRandomValueOption)
+#if (HasConfigurationRandomValueInSteeltoeV3)
using Steeltoe.Extensions.Configuration.RandomValue;
+#elif (HasConfigurationRandomValueInSteeltoeV4)
+using Steeltoe.Configuration.RandomValue;
+#endif
+#if (HasConfigurationSpringBootInSteeltoeV3)
+using Steeltoe.Extensions.Configuration.SpringBoot;
+#elif (HasConfigurationSpringBootInSteeltoeV4)
+using Steeltoe.Configuration.SpringBoot;
#endif
-#if (DynamicLogging)
+#if (HasLoggingDynamicSerilogInSteeltoeV3)
+using Steeltoe.Extensions.Logging.DynamicSerilog;
+#elif (HasLoggingDynamicSerilogInSteeltoeV4)
+using Steeltoe.Logging.DynamicSerilog;
+#endif
+#if (HasLoggingDynamicConsoleInSteeltoeV3)
using Steeltoe.Extensions.Logging;
+#elif (HasLoggingDynamicConsoleInSteeltoeV4)
+using Steeltoe.Logging.DynamicConsole;
#endif
-#if(ManagementEndpointsOption)
+#if (HasManagementEndpointsInSteeltoeV3)
using Steeltoe.Management.Endpoint;
+#elif (HasManagementEndpointsInSteeltoeV4)
+using Steeltoe.Management.Endpoint.Actuators.All;
+#endif
+#if (HasManagementTasksInSteeltoeV3)
+using Steeltoe.Management.TaskCore;
+#elif (HasManagementTasksInSteeltoeV4)
+using Steeltoe.Management.Tasks;
#endif
-#if (AnyTracing)
+#if (DistributedTracingOption)
using Steeltoe.Management.Tracing;
#endif
-#if (AnyMessagingRabbitMq)
-using Microsoft.AspNetCore.Mvc;
+#if (HasAnyMessagingRabbitMqInSteeltoeV3)
using Steeltoe.Messaging.RabbitMQ.Config;
using Steeltoe.Messaging.RabbitMQ.Extensions;
+#endif
+#if (HasMessagingRabbitMqClientInSteeltoeV3)
using Steeltoe.Messaging.RabbitMQ.Core;
#endif
-#if (AnyEfCore)
-using Company.WebApplication.CS.Models;
+#if (HasDataProtectionRedisInSteeltoeV3)
+using Steeltoe.Security.DataProtection;
+#elif (HasDataProtectionRedisInSteeltoeV4)
+using Steeltoe.Security.DataProtection.Redis;
#endif
-#if(MessagingRabbitMqListener)
-using Company.WebApplication.CS.Services;
+#if (RequiresProjectNamespaceImport)
+using Company.WebApplication.CS;
#endif
-var builder = WebApplication.CreateBuilder(args)
-#if (ConfigurationPlaceholderOption)
- .AddPlaceholderResolver()
+var builder = WebApplication.CreateBuilder(args);
+
+// Add services to the container.
+#if (IsFrameworkNet60 || IsFrameworkNet80)
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+#elif (IsFrameworkNet90)
+// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
+builder.Services.AddOpenApi();
#endif
-#if (AnyHosting)
-#if (HostingCloudOption)
- .UseCloudHosting(8080)
-#else
- .UseCloudHosting()
+#if (HasAnySteeltoe)
+
+// Configure Steeltoe components.
#endif
+#if (HasConfigurationPlaceholderInSteeltoeV3)
+builder.AddPlaceholderResolver();
+#elif (HasConfigurationPlaceholderInSteeltoeV4)
+builder.Configuration.AddPlaceholderResolver();
+#endif
+#if (HasAnyNonAzureHostingInSteeltoeV3)
+builder.UseCloudHosting();
#endif
#if (HostingCloudFoundryOption)
- .AddCloudFoundryConfiguration()
+builder.AddCloudFoundryConfiguration();
#endif
-;
-
-#if (HostingAzureSpringCloudOption)
+#if (HasHostingAzureSpringCloudInSteeltoeV3)
builder.WebHost.UseAzureSpringCloudService();
#endif
#if (ConfigurationCloudConfigOption)
-builder.Configuration.AddConfigServer();
+builder.AddConfigServer();
+#endif
+#if (HasConfigurationEncryptionInSteeltoeV4)
+builder.Configuration.AddDecryption();
#endif
#if (ConfigurationRandomValueOption)
builder.Configuration.AddRandomValueSource();
#endif
-#if (DynamicLogging)
+#if (HasConfigurationSpringBootInSteeltoeV3)
+builder.Configuration.AddSpringBootEnv();
+builder.Configuration.AddSpringBootCmd(builder.Configuration);
+#elif (HasConfigurationSpringBootInSteeltoeV4)
+builder.Configuration.AddSpringBootFromEnvironmentVariable();
+builder.Configuration.AddSpringBootFromCommandLine(args);
+#endif
+#if (HasLoggingDynamicSerilogInSteeltoeV3)
+builder.AddDynamicSerilog();
+#elif (HasLoggingDynamicSerilogInSteeltoeV4)
+builder.Logging.AddDynamicSerilog();
+#endif
+#if (LoggingDynamicConsoleOption)
builder.Logging.AddDynamicConsole();
#endif
-
-#if (AnyMessagingRabbitMq)
+#if (HasAnyMessagingRabbitMqInSteeltoeV3)
builder.Services.AddRabbitServices(true);
// Add Steeltoe RabbitAdmin services to get queues declared
builder.Services.AddRabbitAdmin();
// Add a queue to the message container that the rabbit admin will discover and declare at startup
builder.Services.AddRabbitQueue(new Queue("steeltoe_message_queue"));
#endif
-#if (MessagingRabbitMqClient)
+#if (HasMessagingRabbitMqClientInSteeltoeV3)
// Add Steeltoe RabbitTemplate for sending/receiving
builder.Services.AddRabbitTemplate();
#endif
-#if (MessagingRabbitMqListener)
+#if (HasMessagingRabbitMqListenerInSteeltoeV3)
// Add singleton that will process incoming messages
builder.Services.AddSingleton();
// Tell steeltoe about singleton so it can wire up queues with methods to process queues
builder.Services.AddRabbitListeners();
#endif
-#if (ConnectorOAuthOption)
+#if (HasConnectorOAuthInSteeltoeV3)
builder.Services.AddOAuthServiceOptions(builder.Configuration);
#endif
-#if (HostingCloudFoundryOption)
+#if (HasHostingCloudFoundryInSteeltoeV3)
builder.Services.ConfigureCloudFoundryOptions(builder.Configuration);
#endif
-#if (DiscoveryEurekaOption)
+#if (HasAnyDiscoveryInSteeltoeV3)
builder.Services.AddDiscoveryClient(builder.Configuration);
+#else
+#if (HasDiscoveryConsulInSteeltoeV44)
+builder.Services.AddConsulDiscoveryClient();
#endif
-#if (ConnectorMongoDbOption)
-builder.Services.AddMongoClient(builder.Configuration);
+#if (HasDiscoveryEurekaInSteeltoeV4)
+builder.Services.AddEurekaDiscoveryClient();
#endif
-#if (ConnectorMySqlOption)
+#endif
+#if (HasConnectorMongoDbInV3)
+// TODO: Add your connection string at configuration key: MongoDb:Client:ConnectionString
+builder.Services.AddMongoClient(builder.Configuration);
+#elif (HasConnectorMongoDbInV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:MongoDb:Default:ConnectionString
+builder.AddMongoDb();
+#endif
+#if (HasConnectorCosmosDbInSteeltoeV3)
+// TODO: Add your connection string at configuration key: CosmosDb:Client:ConnectionString
+var manager = new ConnectionStringManager(builder.Configuration);
+var cosmosInfo = manager.Get();
+#elif (HasConnectorCosmosDbInSteeltoeV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:CosmosDb:Default:ConnectionString
+builder.AddCosmosDb();
+#endif
+#if (HasConnectorMySqlInSteeltoeV3)
+// TODO: Add your connection string at configuration key: MySql:Client:ConnectionString
builder.Services.AddMySqlConnection(builder.Configuration);
+#elif (HasConnectorMySqlInSteeltoeV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:MySql:Default:ConnectionString
+builder.AddMySql();
+#endif
+#if (HasConnectorMySqlEfCoreInSteeltoeV3)
+// TODO: Add your connection string at configuration key: MySql:Client:ConnectionString
+builder.Services.AddDbContext(options => options.UseMySql(builder.Configuration));
+#elif (HasConnectorMySqlEfCoreInSteeltoeV4)
+builder.Services.AddDbContext((serviceProvider, options) => options.UseMySql(serviceProvider));
+#endif
+#if (HasConnectorPostgreSqlInSteeltoeV3)
+// TODO: Add your connection string at configuration key: Postgres:Client:ConnectionString
+builder.Services.AddPostgresConnection(builder.Configuration);
+#elif (HasConnectorPostgreSqlInSteeltoeV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:PostgreSql:Default:ConnectionString
+builder.AddPostgreSql();
+#endif
+#if (HasConnectorPostgreSqlEfCoreInSteeltoeV3)
+// TODO: Add your connection string at configuration key: Postgres:Client:ConnectionString
+builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration));
+#elif (HasConnectorPostgreSqlEfCoreInSteeltoeV4)
+builder.Services.AddDbContext((serviceProvider, options) => options.UseNpgsql(serviceProvider));
+#endif
+#if (HasConnectorRabbitMqInSteeltoeV3)
+// TODO: Add your connection string at configuration key: RabbitMq:Client:Url
+builder.Services.AddRabbitMQConnection(builder.Configuration);
+#elif (HasConnectorRabbitMqInSteeltoeV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:RabbitMQ:Default:ConnectionString
+builder.AddRabbitMQ();
#endif
-#if (ConnectorMySqlEfCoreOption)
-builder.Services.AddDbContext(options => options.UseMySql(builder.Configuration));
+#if (HasAnyRedisInSteeltoeV3)
+// TODO: Add your connection string at configuration key: Redis:Client:ConnectionString
#endif
-#if (ConnectorPostgreSqlOption)
-builder.Services.AddPostgresConnection(builder.Configuration);
+#if (HasConnectorRedisInSteeltoeV3)
+builder.Services.AddDistributedRedisCache(builder.Configuration);
#endif
-#if (ConnectorPostgreSqlEfCoreOption)
-builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration));
+#if (HasDataProtectionRedisInSteeltoeV3)
+builder.Services.AddRedisConnectionMultiplexer(builder.Configuration);
#endif
-#if (ConnectorRabbitMqOption)
-builder.Services.AddRabbitMQConnection(builder.Configuration);
+#if (HasAnyRedisInSteeltoeV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:Redis:Default:ConnectionString
+builder.AddRedis();
#endif
-#if (ConnectorRedisOption)
-builder.Services.AddDistributedRedisCache(builder.Configuration);
+#if (DataProtectionRedisOption)
+builder.Services.AddDataProtection().PersistKeysToRedis().SetApplicationName("Company.WebApplication.CS");
#endif
-#if (ConnectorSqlServerOption)
+#if (HasConnectorSqlServerInSteeltoeV3)
+// TODO: Add your connection string at configuration key: SqlServer:Credentials:ConnectionString
builder.Services.AddSqlServerConnection(builder.Configuration);
-#endif
-#if (CircuitBreakerHystrixOption)
-builder.Services.AddHystrixCommand("MyCircuitBreakers", builder.Configuration);
+#elif (HasConnectorSqlServerInSteeltoeV4)
+// TODO: Add your connection string at configuration key: Steeltoe:Client:SqlServer:Default:ConnectionString
+builder.AddSqlServer();
+#endif
+#if (HasConnectorSqlServerEfCoreInSteeltoeV3)
+// TODO: Add your connection string at configuration key: SqlServer:Credentials:ConnectionString
+builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration));
+#elif (HasConnectorSqlServerEfCoreInSteeltoeV4)
+builder.Services.AddDbContext((serviceProvider, options) => options.UseSqlServer(serviceProvider));
+#endif
+#if (HasCircuitBreakerHystrixInSteeltoeV3)
+builder.Services.AddHystrixCommand("ExampleCircuitBreakers", builder.Configuration);
builder.Services.AddHystrixMetricsStream(builder.Configuration);
#endif
-#if (ManagementEndpointsOption)
-builder.Services.AddAllActuators(builder.Configuration);
-builder.Services.ActivateActuatorEndpoints();
+#if (HasManagementEndpointsInSteeltoeV3)
+builder.AddAllActuators();
+#elif (HasManagementEndpointsInSteeltoeV4)
+builder.Services.AddAllActuators();
#endif
-#if (AnyTracing)
-builder.Services.AddDistributedTracingAspNetCore();
+#if (HasManagementTasksInSteeltoeV3)
+builder.Services.AddTask("run-me", _ =>
+{
+ // Run this app with command-line argument: runtask=run-me
+ Console.WriteLine("Hello from application task.");
+});
+#elif (HasManagementTasksInSteeltoeV4)
+builder.Services.AddTask("run-me", (_, _) =>
+{
+ // Run this app with command-line argument: runtask=run-me
+ Console.WriteLine("Hello from application task.");
+ return Task.CompletedTask;
+});
#endif
-#if (FrameworkNet60)
-builder.Services.AddControllers();
+#if (HasDistributedTracingInSteeltoeV3)
+builder.Services.AddDistributedTracingAspNetCore();
+builder.Services.AddDistributedTracing();
+#elif (HasDistributedTracingInSteeltoeV4)
+builder.Services.AddTracingLogProcessor();
#endif
-builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen();
var app = builder.Build();
+// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
+#if (IsFrameworkNet60 || IsFrameworkNet80)
app.UseSwagger();
app.UseSwaggerUI();
+#elif (IsFrameworkNet90)
+ app.MapOpenApi();
+#endif
}
-#if (CircuitBreakerHystrixOption)
+#if (HasCircuitBreakerHystrixInSteeltoeV3)
app.UseHystrixRequestContext();
#endif
app.UseHttpsRedirection();
-app.UseRouting();
-#if (FrameworkNet60)
-app.MapControllers();
-#endif
-#if (FrameworkNet80)
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
@@ -196,30 +365,50 @@
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
+#if (IsFrameworkNet60)
+ DateTime.Now.AddDays(index),
+#else
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
+#endif
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
-.WithName("GetWeatherForecast").WithOpenApi();
+#if (IsFrameworkNet60)
+.WithName("GetWeatherForecast");
+#else
+.WithName("GetWeatherForecast")
+.WithOpenApi();
+#endif
-#if (MessagingRabbitMqClient)
+#if (HasMessagingRabbitMqClientInSteeltoeV3)
app.MapGet("/sendtoqueue", ([FromServices] RabbitTemplate rabbitTemplate, [FromServices] RabbitAdmin rabbitAdmin) =>
{
- var msg = "Hi there from over here.";
- rabbitTemplate.ConvertAndSend("steeltoe_message_queue", msg);
- app.Logger.LogInformation($"Sending message '{msg}' to queue 'steeltoe_message_queue'");
+ var message = "Hi there from over here.";
+ rabbitTemplate.ConvertAndSend("steeltoe_message_queue", message);
+ app.Logger.LogInformation("Sending message '{Message}' to queue 'steeltoe_message_queue'", message);
return "Message sent to queue.";
})
.WithName("SendToQueue");
+
#endif
-#endif
+#if (HasManagementTasksInSteeltoeV3)
+app.RunWithTasks();
+#elif (HasManagementTasksInSteeltoeV4)
+await app.RunWithTasksAsync(CancellationToken.None);
+#else
app.Run();
+#endif
-#if (FrameworkNet80)
-record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
+#if (IsFrameworkNet60)
+internal record WeatherForecast(DateTime Date, int TemperatureC, string? Summary)
+{
+ public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
+}
+#else
+internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Properties/launchSettings.json b/src/Content/NetCoreTool.Template.WebApi/CSharp/Properties/launchSettings.json
index 4576874..a9af8c6 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Properties/launchSettings.json
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/Properties/launchSettings.json
@@ -1,14 +1,33 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
- "Company.WebApplication.CS": {
+ "http": {
"commandName": "Project",
+ "dotnetRunMessages": true,
+ //#if (IsFrameworkNet90)
+ "launchBrowser": false,
+ //#else
"launchBrowser": true,
"launchUrl": "swagger",
+ //#endif
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
+ },
+ "https": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ //#if (IsFrameworkNet90)
+ "launchBrowser": false,
+ //#else
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ //#endif
+ "applicationUrl": "https://localhost:5001;http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
}
}
}
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/RabbitListenerService.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/RabbitListenerService.cs
new file mode 100644
index 0000000..7d3e21b
--- /dev/null
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/RabbitListenerService.cs
@@ -0,0 +1,21 @@
+#if (HasMessagingRabbitMqListenerInSteeltoeV3)
+using Steeltoe.Messaging.RabbitMQ.Attributes;
+
+namespace Company.WebApplication.CS;
+
+public sealed class RabbitListenerService
+{
+ private readonly ILogger _logger;
+
+ public RabbitListenerService(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ [RabbitListener("steeltoe_message_queue")]
+ public void ListenForAMessage(string message)
+ {
+ _logger.LogInformation($"Received the message '{message}' from the queue.");
+ }
+}
+#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/Services/RabbitListenerService.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/Services/RabbitListenerService.cs
deleted file mode 100644
index 81057dc..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/Services/RabbitListenerService.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-#if (MessagingRabbitMqListener)
-using Microsoft.Extensions.Logging;
-using Steeltoe.Messaging.RabbitMQ.Attributes;
-
-namespace Company.WebApplication.CS.Services
-{
- public class RabbitListenerService
- {
- private ILogger _logger;
-
- public RabbitListenerService(ILogger logger)
- {
- _logger = logger;
- }
-
- [RabbitListener("steeltoe_message_queue")]
- public void ListenForAMessage(string msg)
- {
- _logger.LogInformation($"Received the message '{msg}' from the queue.");
- }
- }
-}
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/WeatherForecast.cs b/src/Content/NetCoreTool.Template.WebApi/CSharp/WeatherForecast.cs
deleted file mode 100644
index 66fc2ce..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/WeatherForecast.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-#if (FrameworkNet60)
-namespace Company.WebApplication.CS
-{
- public class WeatherForecast
- {
- public DateTime Date { get; set; }
-
- public int TemperatureC { get; set; }
-
- public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
-
- public string? Summary { get; set; }
- }
-}
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.Development.json b/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.Development.json
index dd52ebf..f0e6b7d 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.Development.json
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.Development.json
@@ -1,12 +1,11 @@
{
- "$schema": "https://steeltoe.io/schema/latest/schema.json",
+ //#if (IsSteeltoeV3)
+ "$schema": "https://steeltoe.io/schema/v3/schema.json",
+ //#endif
"Logging": {
"LogLevel": {
"Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information",
- "Steeltoe": "Information",
- "Company.WebApplication.CS": "Debug"
+ "Microsoft.AspNetCore": "Warning"
}
}
}
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.json b/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.json
index e09f0a0..8ed33f6 100644
--- a/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.json
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/appsettings.json
@@ -1,5 +1,7 @@
{
- "$schema": "https://steeltoe.io/schema/latest/schema.json",
+ //#if (IsSteeltoeV3)
+ "$schema": "https://steeltoe.io/schema/v3/schema.json",
+ //#endif
//#if (ConfigurationPlaceholderOption)
"ResolvedPlaceholderFromEnvVariables": "${PATH?NotFound}",
"UnresolvedPlaceholder": "${SomKeyNotFound?NotFound}",
@@ -8,10 +10,7 @@
"Logging": {
"LogLevel": {
"Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information",
- "Steeltoe": "Warning",
- "Company.WebApplication.CS": "Information"
+ "Microsoft.AspNetCore": "Warning"
}
}
}
diff --git a/src/Content/NetCoreTool.Template.WebApi/CSharp/nuget.config b/src/Content/NetCoreTool.Template.WebApi/CSharp/nuget.config
new file mode 100644
index 0000000..7a8af6c
--- /dev/null
+++ b/src/Content/NetCoreTool.Template.WebApi/CSharp/nuget.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/.gitignore b/src/Content/NetCoreTool.Template.WebApi/FSharp/.gitignore
deleted file mode 100644
index f44e822..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/.gitignore
+++ /dev/null
@@ -1,16 +0,0 @@
-# build output
-bin/
-obj/
-
-# Visual Studio
-/.vs/
-
-# Visual Studio Code
-/.vscode/
-
-# JetBrains Rider
-/.idea/
-
-# Ionide
-.fake
-.ionide
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/dotnetcli.host.json b/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/dotnetcli.host.json
deleted file mode 100644
index 5bbc2de..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/dotnetcli.host.json
+++ /dev/null
@@ -1,115 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/dotnetcli.host",
- "symbolInfo": {
- "CircuitBreakerHystrixOption": {
- "longName": "circuit-breaker-hystrix",
- "shortName": ""
- },
- "ConfigurationCloudConfigOption": {
- "longName": "configuration-cloud-config",
- "shortName": ""
- },
- "ConfigurationPlaceholderOption": {
- "longName": "configuration-placeholder",
- "shortName": ""
- },
- "ConfigurationRandomValueOption": {
- "longName": "configuration-random-value",
- "shortName": ""
- },
- "ConnectorMongoDbOption": {
- "longName": "connector-mongodb",
- "shortName": ""
- },
- "ConnectorMySqlEfCoreOption": {
- "longName": "connector-mysql-efcore",
- "shortName": ""
- },
- "ConnectorMySqlOption": {
- "longName": "connector-mysql",
- "shortName": ""
- },
- "ConnectorOAuthOption": {
- "longName": "connector-oauth",
- "shortName": ""
- },
- "ConnectorPostgreSqlEfCoreOption": {
- "longName": "connector-postgresql-efcore",
- "shortName": ""
- },
- "ConnectorPostgreSqlOption": {
- "longName": "connector-postgresql",
- "shortName": ""
- },
- "ConnectorRabbitMqOption": {
- "longName": "connector-rabbitmq",
- "shortName": ""
- },
- "ConnectorRedisOption": {
- "longName": "connector-redis",
- "shortName": ""
- },
- "ConnectorSqlServerOption": {
- "longName": "connector-sqlserver",
- "shortName": ""
- },
- "DescriptionOption": {
- "longName": "description",
- "shortName": "D"
- },
- "DiscoveryEurekaOption": {
- "longName": "discovery-eureka",
- "shortName": ""
- },
- "DistributedTracingOption": {
- "longName": "distributed-tracing",
- "shortName": ""
- },
- "DockerfileOption": {
- "longName": "dockerfile",
- "shortName": ""
- },
- "Framework": {
- "longName": "framework"
- },
- "HostingAzureSpringCloudOption": {
- "longName": "hosting-azure-spring-cloud",
- "shortName": ""
- },
- "HostingCloudFoundryOption": {
- "longName": "hosting-cloud-foundry",
- "shortName": ""
- },
- "HostingCloudOption": {
- "longName": "hosting-cloud",
- "shortName": ""
- },
- "LoggingDynamicLoggerOption": {
- "longName": "logging-dynamic-logger",
- "shortName": ""
- },
- "ManagementEndpointsOption": {
- "longName": "management-endpoints",
- "shortName": ""
- },
- "MessagingRabbitMqOption": {
- "longName": "messaging-rabbitmq",
- "shortName": ""
- },
- "MessagingRabbitMqClientOption": {
- "longName": "messaging-rabbitmq-client",
- "shortName": ""
- },
- "MessagingRabbitMqListenerOption": {
- "longName": "messaging-rabbitmq-listener",
- "shortName": ""
- },
- "SkipRestoreOption": {
- "longName": "no-restore",
- "shortName": ""
- },
- "SteeltoeVersionOption": {
- "longName": "steeltoe"
- }
- }
-}
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/ide.host.json b/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/ide.host.json
deleted file mode 100644
index 388b104..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/ide.host.json
+++ /dev/null
@@ -1,175 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/vs-2017.3.host",
- "learnMoreLink": "https://start.steeltoe.io/",
- "icon": "steeltoe-icon.png",
- "symbolInfo": [
- {
- "id": "CircuitBreakerHystrixOption",
- "name": {
- "text": "Add support for Netflix Hystrix, a latency and fault tolerance library"
- },
- "isVisible": "true"
- },
- {
- "id": "ConfigurationCloudConfigOption",
- "name": {
- "text": "Add a Spring Cloud Config configuration source "
- },
- "isVisible": "true"
- },
- {
- "id": "ConfigurationPlaceholderOption",
- "name": {
- "text": "Add a placeholder configuration source"
- },
- "isVisible": "true"
- },
- {
- "id": "ConfigurationRandomValueOption",
- "name": {
- "text": "Add a random value configuration source"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorMongoDbOption",
- "name": {
- "text": "Add a connector for MongoDB databases"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorMySqlEfCoreOption",
- "name": {
- "text": "Add a connector for MySQL databases using Entity Framework Core"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorMySqlOption",
- "name": {
- "text": "Add a connector for MySQL databases"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorOAuthOption",
- "name": {
- "text": "Add a connector for OAuth security"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorPostgreSqlEfCoreOption",
- "name": {
- "text": "Add a connector for PostgreSQL databases using Entity Framework Core"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorPostgreSqlOption",
- "name": {
- "text": "Add a connector for PostgreSQL databases"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorRabbitMqOption",
- "name": {
- "text": "Add a connector for RabbitMQ message brokers"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorRedisOption",
- "name": {
- "text": "Add a connector for Redis data stores"
- },
- "isVisible": "true"
- },
- {
- "id": "ConnectorSqlServerOption",
- "name": {
- "text": "Add a connector for Microsoft SQL Server databases"
- },
- "isVisible": "true"
- },
- {
- "id": "DescriptionOption",
- "name": {
- "text": "Add a project description"
- },
- "isVisible": "true"
- },
- {
- "id": "DiscoveryEurekaOption",
- "name": {
- "text": "Add access to Eureka, a REST-based service for locating services"
- },
- "isVisible": "true"
- },
- {
- "id": "DistributedTracingOption",
- "name": {
- "text": "Add distributed tracing support"
- },
- "isVisible": "true"
- },
- {
- "id": "DockerfileOption",
- "name": {
- "text": "Add a Dockerfile"
- },
- "isVisible": "true"
- },
- {
- "id": "HostingAzureSpringCloudOption",
- "name": {
- "text": "Add hosting support for Microsoft Azure Spring Cloud"
- },
- "isVisible": "true"
- },
- {
- "id": "HostingCloudFoundryOption",
- "name": {
- "text": "Add hosting support for Cloud Foundry"
- },
- "isVisible": "true"
- },
- {
- "id": "HostingCloudOption",
- "name": {
- "text": "Add hosting support for clouds"
- },
- "isVisible": "true"
- },
- {
- "id": "LoggingDynamicLoggerOption",
- "name": {
- "text": "Add a dynamic logger"
- },
- "isVisible": "true"
- },
- {
- "id": "ManagementEndpointsOption",
- "name": {
- "text": "Add application management endpoints, such as health and metrics"
- },
- "isVisible": "true"
- },
- {
- "id": "MessagingRabbitMqClientOption",
- "name": {
- "text": "Add a RabbitMQ client service for sending and receiving messages"
- },
- "isVisible": "true"
- },
- {
- "id": "MessagingRabbitMqListenerOption",
- "name": {
- "text": "Add a RabbitMQ listener service for processing messages"
- },
- "isVisible": "true"
- }
- ]
-}
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/steeltoe-icon.png b/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/steeltoe-icon.png
deleted file mode 100644
index 15a1e20..0000000
Binary files a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/steeltoe-icon.png and /dev/null differ
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/template.json b/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/template.json
deleted file mode 100644
index ace5a17..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/.template.config/template.json
+++ /dev/null
@@ -1,416 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/template",
- "author": "VMware",
- "classifications": [
- "Web",
- "WebAPI",
- "Steeltoe"
- ],
- "name": "Steeltoe Web API",
- "identity": "steeltoe.webapi.fsharp",
- "groupIdentity": "steeltoe.webapi",
- "shortName": "steeltoe-webapi",
- "tags": {
- "type": "project",
- "language": "F#"
- },
- "sourceName": "Company.WebApplication.FS",
- "sources": [
- {
- "modifiers": [
- {
- "exclude": [
- "Directory.Build.props",
- ".idea/**",
- ".vscode/**"
- ]
- },
- {
- "condition": "(!AnyEfCore)",
- "exclude": [
- "Models/ErrorViewModel.fs",
- "Models/SampleContext.fs"
- ]
- },
- {
- "condition": "(!CircuitBreakerHystrixOption)",
- "exclude": [
- "HelloHystrixCommand.fs"
- ]
- },
- {
- "condition": "(!DockerfileOption)",
- "exclude": [
- "Dockerfile"
- ]
- },
- {
- "condition": "(!MessagingRabbitMqClient)",
- "exclude": [
- "Controllers/RabbitMessageController.fs"
- ]
- },
- {
- "condition": "(!MessagingRabbitMqListener)",
- "exclude": [
- "Services/RabbitListenerService.fs"
- ]
- }
- ]
- }
- ],
- "symbols": {
- "AnyCloudManagement": {
- "type": "computed",
- "value": "CircuitBreakerHystrixOption || DiscoveryEurekaOption || HostingAzureSpringCloudOption || HostingCloudFoundryOption || LoggingDynamicLoggerOption || ManagementEndpointsOption"
- },
- "AnyConfiguration": {
- "type": "computed",
- "value": "ConfigurationCloudConfigOption || ConfigurationPlaceholderOption || ConfigurationRandomValueOption"
- },
- "AnyConnector": {
- "type": "computed",
- "value": "ConnectorMongoDbOption || ConnectorMySqlEfCoreOption || ConnectorMySqlOption || ConnectorOAuthOption || ConnectorPostgreSqlEfCoreOption || ConnectorPostgreSqlOption || ConnectorRedisOption || ConnectorRabbitMqOption || ConnectorSqlServerOption"
- },
- "AnyEfCore": {
- "type": "computed",
- "value": "ConnectorMySqlEfCoreOption || ConnectorPostgreSqlEfCoreOption"
- },
- "AnyHosting": {
- "type": "computed",
- "value": "HostingCloudFoundryOption || HostingCloudOption"
- },
- "AnyMessagingRabbitMq": {
- "type": "computed",
- "value": "MessagingRabbitMqClient || MessagingRabbitMqListener"
- },
- "AnySql": {
- "type": "computed",
- "value": "ConnectorMySqlOption || ConnectorPostgreSqlOption || ConnectorSqlServerOption"
- },
- "AnySteeltoe": {
- "type": "computed",
- "value": "AnyCloudManagement || AnyConfiguration || AnyConnector || AnyHosting || AnyMessagingRabbitMq || AnyTracing"
- },
- "AnyTracing": {
- "type": "computed",
- "value": "DistributedTracingOption"
- },
- "ApplicationPort": {
- "type": "generated",
- "generator": "port",
- "replaces": "8080"
- },
- "AzureOAuthVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "3.1.*"
- },
- "replaces": "$(AzureOAuthVersion)"
- },
- "CircuitBreakerHystrixOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add support for Netflix Hystrix, a latency and fault tolerance library.",
- "defaultValue": "false"
- },
- "ConfigurationCloudConfigOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a Spring Cloud Config configuration source.",
- "defaultValue": "false"
- },
- "ConfigurationPlaceholderOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a placeholder configuration source.",
- "defaultValue": "false"
- },
- "ConfigurationRandomValueOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a random value configuration source.",
- "defaultValue": "false"
- },
- "ConnectorMongoDbOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for MongoDB databases.",
- "defaultValue": "false"
- },
- "ConnectorMySqlEfCoreOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for MySQL databases using Entity Framework Core.",
- "defaultValue": "false"
- },
- "ConnectorMySqlOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for MySQL databases.",
- "defaultValue": "false"
- },
- "ConnectorOAuthOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for OAuth security.",
- "defaultValue": "false"
- },
- "ConnectorPostgreSqlEfCoreOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for PostgreSQL databases using Entity Framework Core.",
- "defaultValue": "false"
- },
- "ConnectorPostgreSqlOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for PostgreSQL databases.",
- "defaultValue": "false"
- },
- "ConnectorRabbitMqOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for RabbitMQ message brokers.",
- "defaultValue": "false"
- },
- "ConnectorRedisOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for Redis data stores.",
- "defaultValue": "false"
- },
- "ConnectorSqlServerOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a connector for Microsoft SQL Server databases.",
- "defaultValue": "false"
- },
- "DescriptionOption": {
- "description": "Add a project description.",
- "type": "parameter",
- "datatype": "string",
- "defaultValue": "",
- "replaces": "$(DescriptionOption)"
- },
- "DiscoveryEurekaOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add access to Eureka, a REST-based service for locating services.",
- "defaultValue": "false"
- },
- "DistributedTracingOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add distributed tracing support.",
- "defaultValue": "false"
- },
- "DockerImageTag": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.0-alpine"
- }
- },
- "DockerfileOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a Dockerfile.",
- "defaultValue": "false"
- },
- "DynamicLogging": {
- "type": "computed",
- "value": "LoggingDynamicLoggerOption || ManagementEndpointsOption"
- },
- "AnyBuilderOptions": {
- "type": "computed",
- "value": "ConfigurationPlaceholderOption || HostingAzureSpringCloudOption || AnyHosting || HostingCloudFoundryOption || ConfigurationCloudConfigOption || ConfigurationRandomValueOption || DynamicLogging"
- },
- "EntityFrameworkCoreVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.0.*"
- },
- "replaces": "$(EntityFrameworkCoreVersion)"
- },
- "Framework": {
- "description": "Set the target framework for the project.",
- "type": "parameter",
- "datatype": "choice",
- "choices": [
- {
- "choice": "net6.0"
- },
- {
- "choice": "net8.0"
- }
- ],
- "defaultValue": "net8.0",
- "replaces": "$(FrameworkOption)"
- },
- "FrameworkNet60": {
- "type": "generated",
- "generator": "regexMatch",
- "datatype": "bool",
- "parameters": {
- "source": "Framework",
- "pattern": "^net6.0$"
- }
- },
- "FrameworkNet80": {
- "type": "generated",
- "generator": "regexMatch",
- "datatype": "bool",
- "parameters": {
- "source": "Framework",
- "pattern": "^net8.0$"
- }
- },
- "HasDescription": {
- "type": "generated",
- "generator": "regexMatch",
- "datatype": "bool",
- "parameters": {
- "source": "DescriptionOption",
- "pattern": "^.+"
- }
- },
- "HostingAzureSpringCloudOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add hosting support for Microsoft Azure Spring Cloud.",
- "defaultValue": "false"
- },
- "HostingCloudFoundryOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add hosting support for Cloud Foundry.",
- "defaultValue": "false"
- },
- "HostingCloudOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add hosting support for clouds.",
- "defaultValue": "false"
- },
- "LoggingDynamicLoggerOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a dynamic logger.",
- "defaultValue": "false"
- },
- "ManagementEndpointsOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add application management endpoints, such as health and metrics.",
- "defaultValue": "false"
- },
- "MessagingRabbitMq": {
- "type": "computed",
- "value": "MessagingRabbitMqOption"
- },
- "MessagingRabbitMqOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add both RabbitMQ client and listener services.\nSame as specifying --messaging-rabbitmq-client and --messaging-rabbitmq-listener.",
- "defaultValue": "false"
- },
- "MessagingRabbitMqClient": {
- "type": "computed",
- "value": "(MessagingRabbitMqClientOption) || MessagingRabbitMq"
- },
- "MessagingRabbitMqClientOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a RabbitMQ client controller for sending and receiving messages.",
- "defaultValue": "false"
- },
- "MessagingRabbitMqListener": {
- "type": "computed",
- "value": "(MessagingRabbitMqListenerOption) || MessagingRabbitMq"
- },
- "MessagingRabbitMqListenerOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Add a RabbitMQ listener service for processing messages.",
- "defaultValue": "false"
- },
- "MongoDbDriverVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "2.19.*"
- },
- "replaces": "$(MongoDbDriverVersion)"
- },
- "MySqlDriverVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "8.0.*"
- },
- "replaces": "$(MySqlDriverVersion)"
- },
- "NeedsSelf": {
- "type": "computed",
- "value": "AnyConnector || CircuitBreakerHystrixOption || DiscoveryEurekaOption || (DistributedTracingOption) || HostingCloudFoundryOption || ManagementEndpointsOption"
- },
- "NpgsqlDriverVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.0.*"
- },
- "replaces": "$(NpgsqlDriverVersion)"
- },
- "RabbitMqDriverVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.4.*"
- },
- "replaces": "$(RabbitMqDriverVersion)"
- },
- "RedisDriverVersion": {
- "type": "generated",
- "generator": "constant",
- "parameters": {
- "value": "6.0.*"
- },
- "replaces": "$(RedisDriverVersion)"
- },
- "SkipRestoreOption": {
- "type": "parameter",
- "datatype": "bool",
- "description": "Skip the automatic restore of the project on create.",
- "defaultValue": "false"
- },
- "SteeltoeVersionOption": {
- "description": "Set the Steeltoe version for the project.",
- "type": "parameter",
- "datatype": "string",
- "defaultValue": "3.2.*",
- "replaces": "$(SteeltoeVersionOption)"
- }
- },
- "primaryOutputs": [
- {
- "path": "Company.WebApplication.FS.fsproj"
- }
- ],
- "postActions": [
- {
- "description": "Restore NuGet packages required by this project.",
- "condition": "!SkipRestoreOption",
- "manualInstructions": [
- {
- "text": "Run 'dotnet restore'"
- }
- ],
- "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
- "continueOnError": true
- }
- ]
-}
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Company.WebApplication.FS.fsproj b/src/Content/NetCoreTool.Template.WebApi/FSharp/Company.WebApplication.FS.fsproj
deleted file mode 100644
index be1829b..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Company.WebApplication.FS.fsproj
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
- $(FrameworkOption)
-
- $(DescriptionOption)
-
- enable
-
-
-
- $(SteeltoeVersionOption)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/RabbitMessageController.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/RabbitMessageController.fs
deleted file mode 100644
index 05ca7b5..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/RabbitMessageController.fs
+++ /dev/null
@@ -1,2 +0,0 @@
-module Company.WebApplication.FS.Controllers.RabbitMessageController
-
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/WeatherForecastController.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/WeatherForecastController.fs
deleted file mode 100644
index ec0b822..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Controllers/WeatherForecastController.fs
+++ /dev/null
@@ -1,38 +0,0 @@
-namespace Company.WebApplication.FS.Controllers
-
-open System
-open System.Collections.Generic
-open System.Linq
-open System.Threading.Tasks
-open Microsoft.AspNetCore.Mvc
-open Microsoft.Extensions.Logging
-open Company.WebApplication.FS
-
-[]
-[]
-type WeatherForecastController (logger : ILogger) =
- inherit ControllerBase()
-
- let summaries =
- [|
- "Freezing"
- "Bracing"
- "Chilly"
- "Cool"
- "Mild"
- "Warm"
- "Balmy"
- "Hot"
- "Sweltering"
- "Scorching"
- |]
-
- []
- member _.Get() =
- let rng = System.Random()
- [|
- for index in 0..4 ->
- { Date = DateTime.Now.AddDays(float index)
- TemperatureC = rng.Next(-20,55)
- Summary = summaries.[rng.Next(summaries.Length)] }
- |]
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Directory.Build.props b/src/Content/NetCoreTool.Template.WebApi/FSharp/Directory.Build.props
deleted file mode 100644
index c30a176..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Directory.Build.props
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- 3.1.*
- 2.0.0-preview.1
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
- false
-
- false
- false
- 6.0.*
- net6.0
- true
- false
- false
- false
- false
- false
- false
- false
- false
- 2.19.*
- 8.0.*
- 6.0.*
- 6.4.*
- 6.0.*
- 3.2.*
- false
-
-
-
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Dockerfile b/src/Content/NetCoreTool.Template.WebApi/FSharp/Dockerfile
deleted file mode 100644
index 7e6c569..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Dockerfile
+++ /dev/null
@@ -1,31 +0,0 @@
-#if (FrameworkNet60)
-FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base
-#endif
-#if (FrameworkNet80)
-FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base
-#endif
-USER app
-WORKDIR /app
-EXPOSE 8080
-EXPOSE 8081
-#if (FrameworkNet60)
-FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
-#endif
-#if (FrameworkNet80)
-FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
-#endif
-ARG BUILD_CONFIGURATION=Release
-WORKDIR /src
-COPY ["Company.WebApplication.FS.fsproj", "."]
-RUN dotnet restore "Company.WebApplication.FS.fsproj"
-COPY . .
-RUN dotnet build "Company.WebApplication.FS.fsproj" -c $BUILD_CONFIGURATION -o /app
-
-FROM build AS publish
-ARG BUILD_CONFIGURATION=Release
-RUN dotnet publish "Company.WebApplication.FS.fsproj" -c $BUILD_CONFIGURATION -o /app /p:UseAppHost=false
-
-FROM base AS final
-WORKDIR /app
-COPY --from=publish /app .
-ENTRYPOINT ["dotnet", "Company.WebApplication.FS.dll"]
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/HelloHystrixCommand.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/HelloHystrixCommand.fs
deleted file mode 100644
index ff7325f..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/HelloHystrixCommand.fs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Company.WebApplication.FS
-#if (CircuitBreakerHystrixOption)
-
-open System.Threading.Tasks
-open Steeltoe.CircuitBreaker.Hystrix
-
-type HelloHystrixCommand(name : string) =
- inherit HystrixCommand(HystrixCommandGroupKeyDefault.AsKey(name))
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Models/ErrorViewModel.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/Models/ErrorViewModel.fs
deleted file mode 100644
index ae5d976..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Models/ErrorViewModel.fs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Company.WebApplication.FS.Models
-#if (AnyEfCore)
-open System
-
-type ErrorViewModel(RequestId: string) =
- member this.ShowRequestId = String.IsNullOrEmpty RequestId
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Models/SampleContext.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/Models/SampleContext.fs
deleted file mode 100644
index 845ea00..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Models/SampleContext.fs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Company.WebApplication.FS.Models
-
-#if (AnyEfCore)
-open Microsoft.EntityFrameworkCore
-open System.ComponentModel.DataAnnotations
-open System.ComponentModel.DataAnnotations.Schema
-
-type SampleContext(options : DbContextOptions) =
- inherit DbContext(options)
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Program.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/Program.fs
deleted file mode 100644
index 10923e0..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Program.fs
+++ /dev/null
@@ -1,198 +0,0 @@
-namespace Company.WebApplication.FS
-
-open Microsoft.AspNetCore.Builder
-open Microsoft.AspNetCore.Hosting
-open Microsoft.Extensions.Configuration
-open Microsoft.Extensions.DependencyInjection
-open Microsoft.Extensions.Hosting
-open Microsoft.OpenApi.Models
-#if (HostingAzureSpringCloudOption)
-open Microsoft.Azure.SpringCloud.Client
-#endif
-#if (CircuitBreakerHystrixOption)
-open Steeltoe.CircuitBreaker.Hystrix
-#endif
-#if (AnyHosting)
-open Steeltoe.Common.Hosting
-#endif
-#if (ConnectorMongoDbOption)
-open Steeltoe.Connector.MongoDb
-#endif
-#if (ConnectorMySqlEfCoreOption)
-open Steeltoe.Connector.MySql.EFCore
-#endif
-#if (ConnectorMySqlOption)
-open Steeltoe.Connector.MySql
-#endif
-#if (ConnectorOAuthOption)
-open Steeltoe.Connector.OAuth
-#endif
-#if (ConnectorPostgreSqlOption)
-open Steeltoe.Connector.PostgreSql
-#endif
-#if (ConnectorPostgreSqlEfCoreOption)
-open Steeltoe.Connector.PostgreSql.EFCore
-#endif
-#if (ConnectorRabbitMqOption)
-open Steeltoe.Connector.RabbitMQ
-#endif
-#if (ConnectorRedisOption)
-open Steeltoe.Connector.Redis
-#endif
-#if (ConnectorSqlServerOption)
-open Steeltoe.Connector.SqlServer
-#endif
-#if (DiscoveryEurekaOption)
-open Steeltoe.Discovery.Client
-#endif
-#if (HostingCloudFoundryOption)
-open Steeltoe.Extensions.Configuration.CloudFoundry
-#endif
-#if (ConfigurationCloudConfigOption)
-open Steeltoe.Extensions.Configuration.ConfigServer
-#endif
-#if (ConfigurationPlaceholderOption)
-open Steeltoe.Extensions.Configuration.Placeholder
-#endif
-#if (ConfigurationRandomValueOption)
-open Steeltoe.Extensions.Configuration.RandomValue
-#endif
-#if (DynamicLogging)
-open Steeltoe.Extensions.Logging
-#endif
-#if (ManagementEndpointsOption)
-open Steeltoe.Management.Endpoint
-#endif
-#if (AnyTracing)
-open Steeltoe.Management.Tracing
-#endif
-#if (AnyMessagingRabbitMq)
-open Steeltoe.Messaging.RabbitMQ.Config
-open Steeltoe.Messaging.RabbitMQ.Extensions
-#endif
-#if (AnyEfCore)
-open Company.WebApplication.FS.Models
-#endif
-#if (MessagingRabbitMqListener)
-open Company.WebApplication.FS.Services
-#endif
-
-module Program =
- let exitCode = 0
-
- []
- let main args =
- let builder = WebApplication.CreateBuilder(args)
-#if (ConfigurationPlaceholderOption)
- .AddPlaceholderResolver()
-#endif
-#if (AnyHosting)
-#if (HostingCloudOption)
- .UseCloudHosting(8080)
-#else
- .UseCloudHosting()
-#endif
-#endif
-#if (HostingCloudFoundryOption)
- .AddCloudFoundryConfiguration()
-#endif
-
-#if (ConfigurationCloudConfigOption)
- builder.Configuration.AddConfigServer() |> ignore
-#endif
-#if (ConfigurationRandomValueOption)
- builder.Configuration.AddRandomValueSource() |> ignore
-#endif
-#if (DynamicLogging)
- builder.Logging.AddDynamicConsole() |> ignore
-#endif
-
-#if (HostingAzureSpringCloudOption)
- builder.WebHost.UseAzureSpringCloudService() |> ignore
-#endif
-
-// This method gets called by the runtime. Use this method to add services to the container.
-#if (AnyMessagingRabbitMq)
- // Add Steeltoe Rabbit services using JSON serialization
- // to use .NET default serialization, pass "false"
- builder.Services.AddRabbitServices(true) |> ignore
- // Add Steeltoe RabbitAdmin services to get queues declared
- builder.Services.AddRabbitAdmin() |> ignore
- // Add a queue to the message container that the rabbit admin will discover and declare at startup
- builder.Services.AddRabbitQueue(new Queue("steeltoe_message_queue")) |> ignore
-#endif
-#if (MessagingRabbitMqClient)
- // Add Steeltoe RabbitTemplate for sending/receiving
- builder.Services.AddRabbitTemplate() |> ignore
-#endif
-#if (MessagingRabbitMqListener)
- // Add singleton that will process incoming messages
- builder.Services.AddSingleton() |> ignore
- // Tell steeltoe about singleton so it can wire up queues with methods to process queues
- builder.Services.AddRabbitListeners() |> ignore
-#endif
-#if (ConnectorOAuthOption)
- builder.Services.AddOAuthServiceOptions(builder.Configuration) |> ignore
-#endif
-#if (HostingCloudFoundryOption)
- builder.Services.ConfigureCloudFoundryOptions(builder.Configuration) |> ignore
-#endif
-#if (DiscoveryEurekaOption)
- builder.Services.AddDiscoveryClient(builder.Configuration) |> ignore
-#endif
-#if (ConnectorMongoDbOption)
- builder.Services.AddMongoClient(builder.Configuration) |> ignore
-#endif
-#if (ConnectorMySqlOption)
- builder.Services.AddMySqlConnection(builder.Configuration) |> ignore
-#endif
-#if (ConnectorMySqlEfCoreOption)
- builder.Services.AddDbContext(fun options -> options.UseMySql(builder.Configuration) |> ignore) |> ignore
-#endif
-#if (ConnectorPostgreSqlOption)
- builder.Services.AddPostgresConnection(builder.Configuration) |> ignore
-#endif
-#if (ConnectorPostgreSqlEfCoreOption)
- builder.Services.AddDbContext(fun options -> options.UseNpgsql(builder.Configuration) |> ignore) |> ignore
-#endif
-#if (ConnectorRabbitMqOption)
- builder.Services.AddRabbitMQConnection(builder.Configuration) |> ignore
-#endif
-#if (ConnectorRedisOption)
- builder.Services.AddDistributedRedisCache(builder.Configuration) |> ignore
-#endif
-#if (ConnectorSqlServerOption)
- builder.Services.AddSqlServerConnection(builder.Configuration) |> ignore
-#endif
-#if (CircuitBreakerHystrixOption)
- builder.Services.AddHystrixCommand("MyCircuitBreakers", builder.Configuration)
- builder.Services.AddHystrixMetricsStream(builder.Configuration)
-#endif
-#if (ManagementEndpointsOption)
- builder.Services.AddAllActuators(builder.Configuration) |> ignore
- builder.Services.ActivateActuatorEndpoints()
-#endif
-#if (AnyTracing)
- builder.Services.AddDistributedTracingAspNetCore() |> ignore
-#endif
-
- // Add framework services.
- builder.Services.AddControllers() |> ignore
- builder.Services.AddEndpointsApiExplorer() |> ignore
- builder.Services.AddSwaggerGen() |> ignore
-
- let app = builder.Build()
-
- if (builder.Environment.IsDevelopment()) then
- app.UseSwagger() |> ignore
- app.UseSwaggerUI() |> ignore
-
- #if (CircuitBreakerHystrixOption)
- app.UseHystrixRequestContext() |> ignore
- #endif
- app.UseHttpsRedirection() |> ignore
- app.UseRouting() |> ignore
-
- app.MapControllers() |> ignore
- app.Run()
- exitCode
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Properties/launchSettings.json b/src/Content/NetCoreTool.Template.WebApi/FSharp/Properties/launchSettings.json
deleted file mode 100644
index 729c265..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Properties/launchSettings.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/launchsettings.json",
- "profiles": {
- "Company.WebApplication.FS": {
- "commandName": "Project",
- "dotnetRunMessages": "true",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "http://localhost:5000",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- }
- }
-}
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/Services/RabbitListenerService.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/Services/RabbitListenerService.fs
deleted file mode 100644
index 19f96f9..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/Services/RabbitListenerService.fs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Company.WebApplication.FS.Services
-#if (MessagingRabbitMqListener)
-
-open Microsoft.Extensions.Logging
-open Steeltoe.Messaging.RabbitMQ.Attributes
-
-type RabbitListenerService (logger : ILogger) =
- let logger = logger
-
- []
- member _.ListenForAMessage(message : string) =
- logger.LogInformation(message)
-#endif
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/WeatherForecast.fs b/src/Content/NetCoreTool.Template.WebApi/FSharp/WeatherForecast.fs
deleted file mode 100644
index 89757ca..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/WeatherForecast.fs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Company.WebApplication.FS
-
-open System
-
-type WeatherForecast =
- { Date: DateTime
- TemperatureC: int
- Summary: string }
-
- member this.TemperatureF =
- 32.0 + (float this.TemperatureC / 0.5556)
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/appsettings.Development.json b/src/Content/NetCoreTool.Template.WebApi/FSharp/appsettings.Development.json
deleted file mode 100644
index 7222406..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/appsettings.Development.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://steeltoe.io/schema/latest/schema.json",
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- }
-}
diff --git a/src/Content/NetCoreTool.Template.WebApi/FSharp/appsettings.json b/src/Content/NetCoreTool.Template.WebApi/FSharp/appsettings.json
deleted file mode 100644
index 92886dd..0000000
--- a/src/Content/NetCoreTool.Template.WebApi/FSharp/appsettings.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "$schema": "https://steeltoe.io/schema/latest/schema.json",
- //#if (ConfigurationPlaceholderOption)
- "ResolvedPlaceholderFromEnvVariables": "${PATH?NotFound}",
- "UnresolvedPlaceholder": "${SomKeyNotFound?NotFound}",
- "ResolvedPlaceholderFromJson": "${Logging:LogLevel:System?${Logging:LogLevel:Default}}",
- //#endif
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "AllowedHosts": "*"
-}
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
deleted file mode 100644
index 5159391..0000000
--- a/src/Directory.Build.props
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
- 3.4.*
- all
-
-
-
diff --git a/src/Steeltoe.NetCoreTool.Templates.csproj b/src/Steeltoe.NetCoreTool.Templates.csproj
index e360a71..b862dc3 100644
--- a/src/Steeltoe.NetCoreTool.Templates.csproj
+++ b/src/Steeltoe.NetCoreTool.Templates.csproj
@@ -1,27 +1,33 @@
-
+ net8.0
Template
0.0.0
Steeltoe.NetCoreTool.Templates
- Steeltoe Net Core Tool Templates
- VMware
- Templates for creating Steeltoe-influenced projects.
+ Steeltoe .NET Project Templates
+ Broadcom
+ Templates for creating .NET projects with Steeltoe components.
dotnet-new;templates;steeltoe
https://steeltoe.io
+ Apache-2.0
+ false
icon.png
https://steeltoe.io/images/transparent.png
true
- net6.0
+ true
true
false
content
+ true
-
+
+
+
+
+
-
diff --git a/test/Directory.Build.props b/test/Directory.Build.props
index 33fdbef..d2e1a91 100644
--- a/test/Directory.Build.props
+++ b/test/Directory.Build.props
@@ -1,10 +1,9 @@
-
6.0.*
- 6.12.*
- 17.8.*
- 2.5.*
+ 7.2.*
+ 2.4.*
+ 17.13.*
+ 2.*
-
diff --git a/test/NetCoreTool.Template.Test.Utilities/Steeltoe.NetCoreTool.Template.Test.Utilities.csproj b/test/NetCoreTool.Template.Test.Utilities/Steeltoe.NetCoreTool.Template.Test.Utilities.csproj
deleted file mode 100644
index f4c5762..0000000
--- a/test/NetCoreTool.Template.Test.Utilities/Steeltoe.NetCoreTool.Template.Test.Utilities.csproj
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- net6.0
- false
- false
- Steeltoe.NetCoreTool.Template.Test.Utilities
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
diff --git a/test/NetCoreTool.Template.WebApi.Test/AllOptionsTest.cs b/test/NetCoreTool.Template.WebApi.Test/AllOptionsTest.cs
new file mode 100644
index 0000000..afa2c5d
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/AllOptionsTest.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using FluentAssertions;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Utilities;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public sealed class AllOptionsTest(ITestOutputHelper logger) : ProjectOptionTest(null, "Author: Broadcom", logger)
+{
+ private static readonly Regex OptionNameRegex = new("( |, )--(?[a-z-]+)\\s", RegexOptions.Compiled);
+ private static string[] _allOptions;
+
+ private async Task DiscoverOptionsAsync()
+ {
+ using var sandbox = new Sandbox(Logger);
+ var command = "dotnet new steeltoe-webapi --help";
+ await sandbox.ExecuteCommandAsync(command);
+ sandbox.CommandExitCode.Should().Be(0, $"listing options should succeed, while output was:{Environment.NewLine}{sandbox.CommandOutput}");
+ var templateOptionsText = sandbox.CommandOutput.Substring(sandbox.CommandOutput.IndexOf("Template options:", StringComparison.Ordinal));
+
+ List options = [];
+ foreach (Match match in OptionNameRegex.Matches(templateOptionsText))
+ {
+ var optionValue = match.Groups["optionName"].Value;
+
+ if (optionValue is not ("steeltoe" or "framework" or "language" or "no-restore"))
+ {
+ options.Add(optionValue);
+ }
+ }
+
+ Logger.WriteLine($"Detected available options: {string.Join(" ", options)}");
+ return options.ToArray();
+ }
+
+ protected override async Task TemplateSandbox(string args = "")
+ {
+ var allOptions = await GetAllOptionsAsync();
+ var argsWithAllOptions = $"{args} {string.Join(' ', allOptions.Select(option => $"--{option}"))}";
+ return await base.TemplateSandbox(argsWithAllOptions);
+ }
+
+ private async Task GetAllOptionsAsync()
+ {
+ return _allOptions ??= await DiscoverOptionsAsync();
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Assertions/FluentExtensions.cs b/test/NetCoreTool.Template.WebApi.Test/Assertions/FluentExtensions.cs
index 93d9321..ef37231 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Assertions/FluentExtensions.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Assertions/FluentExtensions.cs
@@ -1,5 +1,3 @@
-using System;
-using System.Text.RegularExpressions;
using FluentAssertions;
using FluentAssertions.Primitives;
@@ -9,26 +7,20 @@ public static class FluentExtensions
{
public static AndConstraint ContainSnippet(this StringAssertions assertion, string snippet)
{
- assertion.Subject.Should().MatchRegex(RegexForSnippet(snippet));
+ assertion.Subject.Should().Contain(snippet, Exactly.Once());
return new AndConstraint(assertion);
}
- public static AndConstraint NotContainSnippet(this StringAssertions assertion, string snippet)
+ public static AndConstraint ContainRegexSnippet(this StringAssertions assertion, string snippet)
{
- assertion.Subject.Should().NotMatchRegex(RegexForSnippet(snippet));
+ assertion.Subject.Should().MatchRegex(snippet);
return new AndConstraint(assertion);
}
- private static string RegexForSnippet(string snippet)
+ public static AndConstraint NotContainRegexSnippet(this StringAssertions assertion, string snippet)
{
- var regex = snippet
- .Replace("(", @"\(").Replace(")", @"\)")
- .Replace("[", @"\[").Replace("]", @"\]")
- .Replace("|", @"\|")
- .Replace("+", @"\+")
- .Replace("$", @"\$")
- .Replace(".", @"\s*\.\s*");
- return Regex.Replace(regex, @"\s+", @"\s+");
+ assertion.Subject.Should().NotMatchRegex(snippet);
+ return new AndConstraint(assertion);
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ChoiceParameterTest.cs b/test/NetCoreTool.Template.WebApi.Test/ChoiceParameterTest.cs
index d362447..e0e5d65 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ChoiceParameterTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ChoiceParameterTest.cs
@@ -1,18 +1,16 @@
+using System.Threading.Tasks;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public abstract class ChoiceParameterTest : ParameterTest
+ public abstract class ChoiceParameterTest(string option, string description, ITestOutputHelper logger)
+ : ParameterTest(option, description, logger)
{
- protected ChoiceParameterTest(string option, string description, ITestOutputHelper logger) : base(option, description, logger)
- {
- }
-
[Fact]
[Trait("Category", "ProjectGeneration")]
- public async void TestUnsupportedParameterValue()
+ public async Task TestUnsupportedParameterValue()
{
using var sandbox = await TemplateSandbox("UnsupportedValue");
sandbox.CommandOutput.Should().Contain($"'UnsupportedValue' is not a valid value for --{Option}");
diff --git a/test/NetCoreTool.Template.WebApi.Test/CircuitBreakerHystrixOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/CircuitBreakerHystrixOptionTest.cs
index 359dc08..c19f9dc 100644
--- a/test/NetCoreTool.Template.WebApi.Test/CircuitBreakerHystrixOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/CircuitBreakerHystrixOptionTest.cs
@@ -8,42 +8,50 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class CircuitBreakerHystrixOptionTest : ProjectOptionTest
+ public class CircuitBreakerHystrixOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("circuit-breaker-hystrix", "Add support for Netflix Hystrix, a latency and fault tolerance library (Steeltoe 3.x only).", logger)
{
- public CircuitBreakerHystrixOptionTest(ITestOutputHelper logger) : base("circuit-breaker-hystrix",
- "Add support for Netflix Hystrix, a latency and fault tolerance library", logger)
- {
- }
-
[Fact]
[Trait("Category", "ProjectGeneration")]
- public async void TestDefaultNotPolluted()
+ public async Task TestDefaultNotPolluted()
{
using var sandbox = await TemplateSandbox("false");
sandbox.FileExists("HelloHystrixCommand.cs").Should().BeFalse();
- sandbox.FileExists("HelloHystrixCommand.fs").Should().BeFalse();
}
protected override async Task AssertProjectGeneration(ProjectOptions options)
{
await base.AssertProjectGeneration(options);
- Logger.WriteLine($"asserting HelloHystrixCommand");
- var sourceFile = GetSourceFileForLanguage("HelloHystrixCommand", options.Language);
- var source = await Sandbox.GetFileTextAsync(sourceFile);
- source.Should().ContainSnippet("HelloHystrixCommand");
+
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ Logger.WriteLine($"asserting HelloHystrixCommand");
+ var sourceFile = GetSourceFileForLanguage("HelloHystrixCommand", options.Language);
+ var source = await Sandbox.GetFileTextAsync(sourceFile);
+ source.Should().ContainSnippet("class HelloHystrixCommand");
+ }
}
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- packages.Add(("Steeltoe.CircuitBreaker.HystrixCore", "$(SteeltoeVersion)"));
- packages.Add(("Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore", "$(SteeltoeVersion)"));
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.CircuitBreaker.HystrixCore", "$(SteeltoeVersion)"));
+ packages.Add(("Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore", "$(SteeltoeVersion)"));
+ }
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("builder.Services.AddHystrixCommand");
- snippets.Add("builder.Services.AddHystrixMetricsStream");
- snippets.Add("app.UseHystrixRequestContext");
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Steeltoe.CircuitBreaker.Hystrix;");
+ snippets.Add($"using {Sandbox.Name};");
+
+ snippets.Add(@"builder.Services.AddHystrixCommand(""ExampleCircuitBreakers"", builder.Configuration);");
+ snippets.Add("builder.Services.AddHystrixMetricsStream(builder.Configuration);");
+ snippets.Add("app.UseHystrixRequestContext();");
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConfigurationCloudConfigOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConfigurationCloudConfigOptionTest.cs
index 6b65fd1..47a4923 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConfigurationCloudConfigOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConfigurationCloudConfigOptionTest.cs
@@ -4,22 +4,29 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConfigurationCloudConfigOptionTest : ProjectOptionTest
+ public class ConfigurationCloudConfigOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("configuration-cloud-config", "Add a client for Spring Cloud Config Server to configuration.", logger)
{
- public ConfigurationCloudConfigOptionTest(ITestOutputHelper logger) : base("configuration-cloud-config",
- "Add a Spring Cloud Config configuration source", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Steeltoe.Extensions.Configuration.ConfigServerCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.ConfigServerCore" : "Steeltoe.Configuration.ConfigServer";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Extensions.Configuration.ConfigServer");
- snippets.Add("AddConfigServer()");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add("builder.AddConfigServer();");
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.ConfigServer" : "Steeltoe.Configuration.ConfigServer";
}
+
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConfigurationEncryptionOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConfigurationEncryptionOptionTest.cs
new file mode 100644
index 0000000..30977f1
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/ConfigurationEncryptionOptionTest.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class ConfigurationEncryptionOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("configuration-encryption", "Add decryption of encrypted settings in configuration (Steeltoe 4.0 or higher).", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ if (options.SteeltoeVersion != SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.Configuration.Encryption", "$(SteeltoeVersion)"));
+ }
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ if (options.SteeltoeVersion != SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Steeltoe.Configuration.Encryption;");
+
+ snippets.Add("builder.Configuration.AddDecryption();");
+ }
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConfigurationPlaceholderOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConfigurationPlaceholderOptionTest.cs
index a941e3b..494a90e 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConfigurationPlaceholderOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConfigurationPlaceholderOptionTest.cs
@@ -6,22 +6,33 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConfigurationPlaceholderOptionTest : ProjectOptionTest
+ public class ConfigurationPlaceholderOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("configuration-placeholder", "Add placeholder substitution to configuration.", logger)
{
- public ConfigurationPlaceholderOptionTest(ITestOutputHelper logger) : base("configuration-placeholder",
- "Add a placeholder configuration source", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Steeltoe.Extensions.Configuration.PlaceholderCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.PlaceholderCore" : "Steeltoe.Configuration.Placeholder";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Extensions.Configuration.Placeholder");
- snippets.Add(".AddPlaceholderResolver()");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.Placeholder" : "Steeltoe.Configuration.Placeholder";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "builder.AddPlaceholderResolver();" : "builder.Configuration.AddPlaceholderResolver();";
}
protected override void AssertAppSettingsJsonHook(List> assertions)
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConfigurationRandomValueOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConfigurationRandomValueOptionTest.cs
index 8277c71..37f7393 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConfigurationRandomValueOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConfigurationRandomValueOptionTest.cs
@@ -4,22 +4,28 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConfigurationRandomValueOptionTest : ProjectOptionTest
+ public class ConfigurationRandomValueOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("configuration-random-value", "Add random value generation to configuration.", logger)
{
- public ConfigurationRandomValueOptionTest(ITestOutputHelper logger) : base("configuration-random-value",
- "Add a random value configuration source", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Steeltoe.Extensions.Configuration.RandomValueBase", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.RandomValueBase" : "Steeltoe.Configuration.RandomValue";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Extensions.Configuration.RandomValue");
- snippets.Add("builder.Configuration.AddRandomValueSource()");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add("builder.Configuration.AddRandomValueSource();");
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.RandomValue" : "Steeltoe.Configuration.RandomValue";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConfigurationSpringBootOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConfigurationSpringBootOptionTest.cs
new file mode 100644
index 0000000..167e0f4
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/ConfigurationSpringBootOptionTest.cs
@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class ConfigurationSpringBootOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("configuration-spring-boot", "Add support for reading Spring Boot-style keys from configuration.", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.SpringBootCore" : "Steeltoe.Configuration.SpringBoot";
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Configuration.SpringBoot" : "Steeltoe.Configuration.SpringBoot";
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.Configuration.AddSpringBootEnv();";
+ yield return "builder.Configuration.AddSpringBootCmd(builder.Configuration);";
+ }
+ else
+ {
+ yield return "builder.Configuration.AddSpringBootFromEnvironmentVariable();";
+ yield return "builder.Configuration.AddSpringBootFromCommandLine(args);";
+ }
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorCosmosDbOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorCosmosDbOptionTest.cs
new file mode 100644
index 0000000..47142a0
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorCosmosDbOptionTest.cs
@@ -0,0 +1,53 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class ConnectorCosmosDbOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-cosmosdb", "Add a connector for CosmosDB databases.", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add(("Microsoft.Azure.Cosmos", "3.47.*"));
+ packages.Add(("Newtonsoft.Json", "13.0.*"));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.CosmosDb" : "Steeltoe.Connectors.CosmosDb";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: CosmosDb:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:CosmosDb:Default:ConnectionString";
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "var manager = new ConnectionStringManager(builder.Configuration);";
+ yield return "var cosmosInfo = manager.Get();";
+ }
+ else
+ {
+ yield return "builder.AddCosmosDb();";
+ }
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorMongoDbOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorMongoDbOptionTest.cs
index 9c159c7..11116cf 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorMongoDbOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorMongoDbOptionTest.cs
@@ -4,24 +4,44 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorMongoDbOptionTest : ProjectOptionTest
+ public class ConnectorMongoDbOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-mongodb", "Add a connector for MongoDB databases.", logger)
{
- public ConnectorMongoDbOptionTest(ITestOutputHelper logger) : base("connector-mongodb",
- "Add a connector for MongoDB databases",
- logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add(("MongoDB.Driver", "3.2.*"));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("MongoDB.Driver", "2.19.*"));
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.MongoDb");
- snippets.Add("builder.Services.AddMongoClient");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.MongoDb" : "Steeltoe.Connectors.MongoDb";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: MongoDb:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:MongoDb:Default:ConnectionString";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddMongoClient(builder.Configuration);"
+ : "builder.AddMongoDb();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlEfCoreOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlEfCoreOptionTest.cs
index 3574c40..5e93699 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlEfCoreOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlEfCoreOptionTest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
@@ -7,43 +8,76 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorMySqlEfCoreOptionTest : ProjectOptionTest
+ public class ConnectorMySqlEfCoreOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-mysql-efcore", "Add a connector for MySQL databases using Entity Framework Core.", logger)
{
- public ConnectorMySqlEfCoreOptionTest(ITestOutputHelper logger) : base("connector-mysql-efcore",
- "Add a connector for MySQL databases using Entity Framework Core", logger)
- {
- }
-
[Fact]
[Trait("Category", "ProjectGeneration")]
- public async void TestDefaultNotPolluted()
+ public async Task TestDefaultNotPolluted()
{
using var sandbox = await TemplateSandbox("false");
- sandbox.FileExists("Models/ErrorViewModel.cs").Should().BeFalse();
- sandbox.FileExists("Models/SampleContext.cs").Should().BeFalse();
- sandbox.FileExists("Models/ErrorViewModel.fs").Should().BeFalse();
- sandbox.FileExists("Models/SampleContext.fs").Should().BeFalse();
+ sandbox.FileExists("AppDbContext.cs").Should().BeFalse();
}
protected override async Task AssertProjectGeneration(ProjectOptions options)
{
await base.AssertProjectGeneration(options);
- Logger.WriteLine("asserting Models/SampleContext");
- Sandbox.FileExists(GetSourceFileForLanguage("Models/SampleContext", options.Language)).Should().BeTrue();
- Sandbox.FileExists(GetSourceFileForLanguage("Models/ErrorViewModel", options.Language)).Should().BeTrue();
+
+ Logger.WriteLine("asserting Models");
+ Sandbox.FileExists(GetSourceFileForLanguage("AppDbContext", options.Language)).Should().BeTrue();
}
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- packages.Add(("Microsoft.EntityFrameworkCore", "6.0.*"));
- packages.Add(("Steeltoe.Connector.EFCore", "$(SteeltoeVersion)"));
+ packages.Add(("Microsoft.EntityFrameworkCore", GetPackageVersionForFramework(options.Framework)));
+ packages.Add(("MySql.EntityFrameworkCore", GetPackageVersionForFramework(options.Framework)));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.EFCore" : "Steeltoe.Connectors.EntityFrameworkCore";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.MySql.EFCore");
- snippets.Add($"{Sandbox.Name}.Models");
- snippets.Add(".UseMySql");
+ snippets.Add($"using {Sandbox.Name};");
+ snippets.AddRange(GetNamespaceImports(options.SteeltoeVersion));
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static IEnumerable GetNamespaceImports(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "using Steeltoe.Connector.MySql.EFCore;";
+ }
+ else
+ {
+ yield return "using Steeltoe.Connectors.MySql;";
+ yield return "using Steeltoe.Connectors.EntityFrameworkCore.MySql;";
+ }
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: MySql:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:MySql:Default:ConnectionString";
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.Services.AddDbContext(options => options.UseMySql(builder.Configuration));";
+ }
+ else
+ {
+ yield return "builder.AddMySql();";
+ yield return "builder.Services.AddDbContext((serviceProvider, options) => options.UseMySql(serviceProvider));";
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlOptionTest.cs
index 8cebe29..7105536 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorMySqlOptionTest.cs
@@ -4,23 +4,50 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorMySqlOptionTest : ProjectOptionTest
+ public class ConnectorMySqlOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-mysql", "Add a connector for MySQL databases using ADO.NET.", logger)
{
- public ConnectorMySqlOptionTest(ITestOutputHelper logger) : base("connector-mysql",
- "Add a connector for MySQL databases", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ var mySqlVersion = options.Framework switch
+ {
+ Framework.Net60 => "9.1.*",
+ _ => "9.2.*"
+ };
+
+ packages.Add(("MySql.Data", mySqlVersion));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("MySql.Data", "8.0.*"));
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.MySql");
- snippets.Add("builder.Services.AddMySqlConnection");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.MySql" : "Steeltoe.Connectors.MySql";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: MySql:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:MySql:Default:ConnectionString";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddMySqlConnection(builder.Configuration);"
+ : "builder.AddMySql();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorOAuthOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorOAuthOptionTest.cs
index abd0b62..b0506a2 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorOAuthOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorOAuthOptionTest.cs
@@ -4,24 +4,24 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorOAuthOptionTest : ProjectOptionTest
+ public class ConnectorOAuthOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-oauth", "Add a connector for OAuth2 security on Cloud Foundry (Steeltoe 3.x only).", logger)
{
- public ConnectorOAuthOptionTest(ITestOutputHelper logger) : base("connector-oauth",
- "Add a connector for OAuth security",
- logger)
- {
- }
-
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
- packages.Add(("Microsoft.AspNetCore.Authentication.AzureAD.UI", "3.1.*"));
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ }
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.OAuth");
- snippets.Add("builder.Services.AddOAuthServiceOptions");
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Steeltoe.Connector.OAuth;");
+ snippets.Add("builder.Services.AddOAuthServiceOptions(builder.Configuration);");
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlEfCoreOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlEfCoreOptionTest.cs
index 8f7919f..18b1a76 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlEfCoreOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlEfCoreOptionTest.cs
@@ -1,4 +1,6 @@
+using System;
using System.Collections.Generic;
+using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Steeltoe.NetCoreTool.Template.WebApi.Test.Assertions;
@@ -8,41 +10,76 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorPostgreSqlEfCoreOptionTest : ProjectOptionTest
+ public class ConnectorPostgreSqlEfCoreOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-postgresql-efcore", "Add a connector for PostgreSQL databases using Entity Framework Core.", logger)
{
- public ConnectorPostgreSqlEfCoreOptionTest(ITestOutputHelper logger) : base("connector-postgresql-efcore",
- "Add a connector for PostgreSQL databases using Entity Framework Core", logger)
- {
- }
-
[Fact]
[Trait("Category", "ProjectGeneration")]
- public async void TestDefaultNotPolluted()
+ public async Task TestDefaultNotPolluted()
{
using var sandbox = await TemplateSandbox("false");
- sandbox.FileExists("Models/ErrorViewModel.cs").Should().BeFalse();
- sandbox.FileExists("Models/SampleContext.cs").Should().BeFalse();
+ sandbox.FileExists("AppDbContext.cs").Should().BeFalse();
}
protected override async Task AssertProjectGeneration(ProjectOptions options)
{
await base.AssertProjectGeneration(options);
- Logger.WriteLine("asserting Models/SampleContext");
- Sandbox.FileExists(GetSourceFileForLanguage("Models/SampleContext", options.Language)).Should().BeTrue();
- Sandbox.FileExists(GetSourceFileForLanguage("Models/ErrorViewModel", options.Language)).Should().BeTrue();
+
+ Logger.WriteLine("asserting Models");
+ Sandbox.FileExists(GetSourceFileForLanguage("AppDbContext", options.Language)).Should().BeTrue();
}
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- packages.Add(("Microsoft.EntityFrameworkCore", "6.0.*"));
- packages.Add(("Steeltoe.Connector.EFCore", "$(SteeltoeVersion)"));
+ packages.Add(("Microsoft.EntityFrameworkCore", GetPackageVersionForFramework(options.Framework)));
+ packages.Add(("Npgsql.EntityFrameworkCore.PostgreSQL", GetPackageVersionForFramework(options.Framework)));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.EFCore" : "Steeltoe.Connectors.EntityFrameworkCore";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.PostgreSql.EFCore");
- snippets.Add($"{Sandbox.Name}.Models");
- snippets.Add("options.UseNpgsql");
+ snippets.Add($"using {Sandbox.Name};");
+ snippets.AddRange(GetNamespaceImports(options.SteeltoeVersion));
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static IEnumerable GetNamespaceImports(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "using Steeltoe.Connector.PostgreSql.EFCore;";
+ }
+ else
+ {
+ yield return "using Steeltoe.Connectors.PostgreSql;";
+ yield return "using Steeltoe.Connectors.EntityFrameworkCore.PostgreSql;";
+ }
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: Postgres:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:PostgreSql:Default:ConnectionString";
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.Services.AddDbContext(options => options.UseNpgsql(builder.Configuration));";
+ }
+ else
+ {
+ yield return "builder.AddPostgreSql();";
+ yield return "builder.Services.AddDbContext((serviceProvider, options) => options.UseNpgsql(serviceProvider));";
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlOptionTest.cs
index e388525..106115c 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorPostgreSqlOptionTest.cs
@@ -1,27 +1,48 @@
+using System;
using System.Collections.Generic;
using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
using Xunit.Abstractions;
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorPostgreSqlOptionTest : ProjectOptionTest
+ public class ConnectorPostgreSqlOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-postgresql", "Add a connector for PostgreSQL databases using ADO.NET.", logger)
{
- public ConnectorPostgreSqlOptionTest(ITestOutputHelper logger) : base("connector-postgresql",
- "Add a connector for PostgreSQL databases",
- logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add(("Npgsql", GetPackageVersionForFramework(options.Framework)));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Npgsql", "6.0.*"));
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.PostgreSql");
- snippets.Add("builder.Services.AddPostgresConnection");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.PostgreSql" : "Steeltoe.Connectors.PostgreSql";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: Postgres:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:PostgreSql:Default:ConnectionString";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddPostgresConnection(builder.Configuration);"
+ : "builder.AddPostgreSql();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorRabbitMqOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorRabbitMqOptionTest.cs
index d86e58f..7b217e2 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorRabbitMqOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorRabbitMqOptionTest.cs
@@ -4,23 +4,50 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorRabbitMqOptionTest : ProjectOptionTest
+ public class ConnectorRabbitMqOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-rabbitmq", "Add a connector for RabbitMQ message brokers.", logger)
{
- public ConnectorRabbitMqOptionTest(ITestOutputHelper logger) : base("connector-rabbitmq",
- "Add a connector for RabbitMQ message brokers", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ var rabbitMqVersion = options.SteeltoeVersion switch
+ {
+ SteeltoeVersion.Steeltoe32 => "5.2.*",
+ _ => "7.1.*"
+ };
+
+ packages.Add(("RabbitMQ.Client", rabbitMqVersion));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("RabbitMQ.Client", "6.4.*"));
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.RabbitMQ");
- snippets.Add("builder.Services.AddRabbitMQConnection");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.RabbitMQ" : "Steeltoe.Connectors.RabbitMQ";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: RabbitMq:Client:Url"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:RabbitMQ:Default:ConnectionString";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddRabbitMQConnection(builder.Configuration);"
+ : "builder.AddRabbitMQ();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorRedisOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorRedisOptionTest.cs
index 4f47983..3f2852b 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorRedisOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorRedisOptionTest.cs
@@ -4,23 +4,44 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorRedisOptionTest : ProjectOptionTest
+ public class ConnectorRedisOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-redis", "Add a connector for Redis data stores.", logger)
{
- public ConnectorRedisOptionTest(ITestOutputHelper logger) : base("connector-redis",
- "Add a connector for Redis data stores", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add(("Microsoft.Extensions.Caching.StackExchangeRedis", GetPackageVersionForFramework(options.Framework)));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Microsoft.Extensions.Caching.StackExchangeRedis", "6.0.*"));
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.Redis");
- snippets.Add("builder.Services.AddDistributedRedisCache");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.Redis" : "Steeltoe.Connectors.Redis";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: Redis:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:Redis:Default:ConnectionString";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddDistributedRedisCache(builder.Configuration);"
+ : "builder.AddRedis();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerEfCoreOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerEfCoreOptionTest.cs
new file mode 100644
index 0000000..58487ad
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerEfCoreOptionTest.cs
@@ -0,0 +1,82 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+using FluentAssertions;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class ConnectorSqlServerEfCoreOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-sqlserver-efcore", "Add a connector for Microsoft SQL Server databases using Entity Framework Core.", logger)
+{
+ [Fact]
+ [Trait("Category", "ProjectGeneration")]
+ public async Task TestDefaultNotPolluted()
+ {
+ using var sandbox = await TemplateSandbox("false");
+ sandbox.FileExists("AppDbContext.cs").Should().BeFalse();
+ }
+
+ protected override async Task AssertProjectGeneration(ProjectOptions options)
+ {
+ await base.AssertProjectGeneration(options);
+
+ Logger.WriteLine("asserting Models");
+ Sandbox.FileExists(GetSourceFileForLanguage("AppDbContext", options.Language)).Should().BeTrue();
+ }
+
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add(("Microsoft.EntityFrameworkCore", GetPackageVersionForFramework(options.Framework)));
+ packages.Add(("Microsoft.EntityFrameworkCore.SqlServer", GetPackageVersionForFramework(options.Framework)));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.EFCore" : "Steeltoe.Connectors.EntityFrameworkCore";
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {Sandbox.Name};");
+ snippets.AddRange(GetNamespaceImports(options.SteeltoeVersion));
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static IEnumerable GetNamespaceImports(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "using Steeltoe.Connector.SqlServer.EFCore;";
+ }
+ else
+ {
+ yield return "using Steeltoe.Connectors.SqlServer;";
+ yield return "using Steeltoe.Connectors.EntityFrameworkCore.SqlServer;";
+ }
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: SqlServer:Credentials:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:SqlServer:Default:ConnectionString";
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration));";
+ }
+ else
+ {
+ yield return "builder.AddSqlServer();";
+ yield return "builder.Services.AddDbContext((serviceProvider, options) => options.UseSqlServer(serviceProvider));";
+ }
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerOptionTest.cs
index f198e90..3053971 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ConnectorSqlServerOptionTest.cs
@@ -4,24 +4,50 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ConnectorSqlServerOptionTest : ProjectOptionTest
+ public class ConnectorSqlServerOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("connector-sqlserver", "Add a connector for Microsoft SQL Server databases using ADO.NET.", logger)
{
- public ConnectorSqlServerOptionTest(ITestOutputHelper logger) : base("connector-sqlserver",
- "Add a connector for Microsoft SQL Server databases",
- logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ var sqlClientVersion = options.Framework switch
+ {
+ Framework.Net60 => "5.2.*",
+ _ => "6.0.*"
+ };
+
+ packages.Add(("Microsoft.Data.SqlClient", sqlClientVersion));
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("System.Data.SqlClient", "4.8.*"));
- packages.Add(("Steeltoe.Connector.ConnectorCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.ConnectorCore" : "Steeltoe.Connectors";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Connector.SqlServer");
- snippets.Add("builder.Services.AddSqlServerConnection");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Connector.SqlServer" : "Steeltoe.Connectors.SqlServer";
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: SqlServer:Credentials:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:SqlServer:Default:ConnectionString";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddSqlServerConnection(builder.Configuration);"
+ : "builder.AddSqlServer();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/DataProtectionRedisOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/DataProtectionRedisOptionTest.cs
new file mode 100644
index 0000000..e46dcac
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/DataProtectionRedisOptionTest.cs
@@ -0,0 +1,72 @@
+using System.Collections.Generic;
+using System.Linq;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class DataProtectionRedisOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("data-protection-redis", "Configure the ASP.NET data protection system to persist keys in a Redis database.", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.AddRange(GetPackageNames(options.SteeltoeVersion).Select(packageName => (packageName, "$(SteeltoeVersion)")));
+ }
+
+ private static IEnumerable GetPackageNames(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "Steeltoe.Connector.ConnectorCore";
+ yield return "Steeltoe.Security.DataProtection.RedisCore";
+ }
+ else
+ {
+ yield return "Steeltoe.Security.DataProtection.Redis";
+ }
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.AddRange(GetNamespaceImports(options.SteeltoeVersion));
+ snippets.Add(GetSetupComment(options.SteeltoeVersion));
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static IEnumerable GetNamespaceImports(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "using Microsoft.AspNetCore.DataProtection;";
+ yield return "using Steeltoe.Connector.Redis;";
+ yield return "using Steeltoe.Security.DataProtection;";
+ }
+ else
+ {
+ yield return "using Microsoft.AspNetCore.DataProtection;";
+ yield return "using Steeltoe.Connectors.Redis;";
+ yield return "using Steeltoe.Security.DataProtection.Redis;";
+ }
+ }
+
+ private static string GetSetupComment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "// TODO: Add your connection string at configuration key: Redis:Client:ConnectionString"
+ : "// TODO: Add your connection string at configuration key: Steeltoe:Client:Redis:Default:ConnectionString";
+ }
+
+ private IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.Services.AddRedisConnectionMultiplexer(builder.Configuration);";
+ }
+ else
+ {
+ yield return "builder.AddRedis();";
+ }
+
+ yield return $@"builder.Services.AddDataProtection().PersistKeysToRedis().SetApplicationName(""{Sandbox.Name}"");";
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/DefaultsTest.cs b/test/NetCoreTool.Template.WebApi.Test/DefaultsTest.cs
index 8b6065c..528c076 100644
--- a/test/NetCoreTool.Template.WebApi.Test/DefaultsTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/DefaultsTest.cs
@@ -7,51 +7,62 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class DefaultsTest : ProjectOptionTest
+ public class DefaultsTest(ITestOutputHelper logger)
+ : ProjectOptionTest(null, "Steeltoe ASP.NET Core Web API (C#)", logger)
{
- public DefaultsTest(ITestOutputHelper logger) : base(null, "Steeltoe Web API (C#) Author: VMware", logger)
- {
- }
-
protected override async Task AssertProjectGeneration(ProjectOptions options)
{
await base.AssertProjectGeneration(options);
- if (options.Language == Language.CSharp)
- {
- Sandbox.FileExists("app.config").Should().BeTrue();
- }
+
+ Sandbox.FileExists("app.config").Should().BeTrue();
}
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- if (options.Language == Language.CSharp)
+ if (options.Framework == Framework.Net60)
{
- packages.Add(("Swashbuckle.AspNetCore", "6.4.*"));
+ packages.Add(("Swashbuckle.AspNetCore", "6.5.0"));
+ }
+ else if (options.Framework == Framework.Net80)
+ {
+ packages.Add(("Microsoft.AspNetCore.OpenApi", "8.0.*"));
+ packages.Add(("Swashbuckle.AspNetCore", "6.6.2"));
+ }
+ else if (options.Framework == Framework.Net90)
+ {
+ packages.Add(("Microsoft.AspNetCore.OpenApi", "9.0.*"));
}
}
protected override void AssertProjectPropertiesHook(ProjectOptions options,
Dictionary properties)
{
- switch (options.SteeltoeVersion)
+ AssertSteeltoeVersion(options.SteeltoeVersion);
+
+ properties["TargetFramework"] = GetFramework(options.Framework);
+ }
+
+ private static string GetFramework(Framework framework)
+ {
+ return framework switch
{
- case SteeltoeVersion.Steeltoe32:
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(options.SteeltoeVersion),
- options.SteeltoeVersion.ToString());
- }
+ Framework.Net60 => "net6.0",
+ Framework.Net80 => "net8.0",
+ Framework.Net90 => "net9.0",
+ _ => throw new ArgumentOutOfRangeException(nameof(framework), framework.ToString())
+ };
+ }
- switch (options.Framework)
+ private static void AssertSteeltoeVersion(SteeltoeVersion steeltoeVersion)
+ {
+ switch (steeltoeVersion)
{
- case Framework.Net60:
- properties["TargetFramework"] = "net6.0";
- break;
- case Framework.Net80:
- properties["TargetFramework"] = "net8.0";
+ case SteeltoeVersion.Steeltoe32:
+ case SteeltoeVersion.Steeltoe40:
break;
default:
- throw new ArgumentOutOfRangeException(nameof(options.Framework), options.Framework.ToString());
+ throw new ArgumentOutOfRangeException(nameof(steeltoeVersion),
+ steeltoeVersion.ToString());
}
}
@@ -62,7 +73,18 @@ protected override void AssertAppSettingsJsonHook(List> assertions)
@@ -72,7 +94,13 @@ protected override void AssertDevelopmentAppSettingsJsonHook(List> assertions)
@@ -82,7 +110,44 @@ protected override void AssertLaunchSettingsHook(List snippets)
+ {
+ if (options.Framework is Framework.Net60 or Framework.Net80)
+ {
+ snippets.Add("// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle");
+ snippets.Add("builder.Services.AddEndpointsApiExplorer();");
+ snippets.Add("builder.Services.AddSwaggerGen();");
+ }
+ else
+ {
+ snippets.Add("// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi");
+ snippets.Add("builder.Services.AddOpenApi();");
+ }
+
+ snippets.Add("var app = builder.Build();");
+ snippets.Add("app.UseHttpsRedirection();");
+ snippets.Add("app.MapGet(\"/weatherforecast\", () =>");
+ snippets.Add("app.Run();");
+ snippets.Add("internal record WeatherForecast(");
+
+ base.AssertProgramSnippetsHook(options, snippets);
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/DescriptionParameterTest.cs b/test/NetCoreTool.Template.WebApi.Test/DescriptionParameterTest.cs
index a721bc8..44afbac 100644
--- a/test/NetCoreTool.Template.WebApi.Test/DescriptionParameterTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/DescriptionParameterTest.cs
@@ -9,7 +9,7 @@ namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
public class DescriptionParameterTest : ParameterTest
{
- public DescriptionParameterTest(ITestOutputHelper logger) : base("description", "Add a project description",
+ public DescriptionParameterTest(ITestOutputHelper logger) : base("description", "Add a project description.",
logger)
{
Values.Add("dummy");
diff --git a/test/NetCoreTool.Template.WebApi.Test/DiscoveryConsulOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/DiscoveryConsulOptionTest.cs
new file mode 100644
index 0000000..71fd162
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/DiscoveryConsulOptionTest.cs
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class DiscoveryConsulOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("discovery-consul", "Add a service discovery client for HashiCorp Consul.", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add(("Steeltoe.Discovery.Consul", "$(SteeltoeVersion)"));
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Discovery.Client" : "Steeltoe.Discovery.Consul";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddDiscoveryClient(builder.Configuration);"
+ : "builder.Services.AddConsulDiscoveryClient();";
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/DiscoveryEurekaOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/DiscoveryEurekaOptionTest.cs
index 99e858f..397b3c1 100644
--- a/test/NetCoreTool.Template.WebApi.Test/DiscoveryEurekaOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/DiscoveryEurekaOptionTest.cs
@@ -4,13 +4,9 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class DiscoveryEurekaOptionTest : ProjectOptionTest
+ public class DiscoveryEurekaOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("discovery-eureka", "Add a service discovery client for Netflix Eureka.", logger)
{
- public DiscoveryEurekaOptionTest(ITestOutputHelper logger) : base("discovery-eureka",
- "Add access to Eureka, a REST-based service for locating services", logger)
- {
- }
-
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
packages.Add(("Steeltoe.Discovery.Eureka", "$(SteeltoeVersion)"));
@@ -18,7 +14,20 @@ protected override void AssertPackageReferencesHook(ProjectOptions options, List
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("builder.Services.AddDiscoveryClient");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Discovery.Client" : "Steeltoe.Discovery.Eureka";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32
+ ? "builder.Services.AddDiscoveryClient(builder.Configuration);"
+ : "builder.Services.AddEurekaDiscoveryClient();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/DistributedTracingOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/DistributedTracingOptionTest.cs
index 7c69d96..cec6a03 100644
--- a/test/NetCoreTool.Template.WebApi.Test/DistributedTracingOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/DistributedTracingOptionTest.cs
@@ -4,22 +4,36 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class DistributedTracingOptionTest : ProjectOptionTest
+ public class DistributedTracingOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("distributed-tracing", "Add distributed tracing support.", logger)
{
- public DistributedTracingOptionTest(ITestOutputHelper logger) : base("distributed-tracing",
- "Add distributed tracing support", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Steeltoe.Management.TracingCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Management.TracingCore" : "Steeltoe.Management.Tracing";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Management.Tracing");
- snippets.Add("builder.Services.AddDistributedTracingAspNetCore");
+ snippets.Add("using Steeltoe.Management.Tracing;");
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.Services.AddDistributedTracingAspNetCore();";
+ yield return "builder.Services.AddDistributedTracing();";
+ }
+ else
+ {
+ yield return "builder.Services.AddTracingLogProcessor();";
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/DockerfileOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/DockerfileOptionTest.cs
index a107fc4..3df4787 100644
--- a/test/NetCoreTool.Template.WebApi.Test/DockerfileOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/DockerfileOptionTest.cs
@@ -3,34 +3,47 @@
using FluentAssertions;
using Steeltoe.NetCoreTool.Template.WebApi.Test.Assertions;
using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit;
using Xunit.Abstractions;
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class DockerfileOptionTest : ProjectOptionTest
+ public class DockerfileOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("dockerfile", "Add a Dockerfile", logger)
{
- public DockerfileOptionTest(ITestOutputHelper logger) : base("dockerfile", "Add a Dockerfile", logger)
+ [Fact]
+ [Trait("Category", "ProjectGeneration")]
+ public async Task TestDefaultNotPolluted()
{
+ using var sandbox = await TemplateSandbox("false");
+ sandbox.FileExists("Dockerfile").Should().BeFalse();
}
protected override async Task AssertProjectGeneration(ProjectOptions options)
{
await base.AssertProjectGeneration(options);
+
Logger.WriteLine("asserting Dockerfile");
var dockerfile = await Sandbox.GetFileTextAsync("Dockerfile");
- var tag = options.Framework switch
- {
- Framework.Net60 => "6.0-alpine",
- Framework.Net80 => "8.0-alpine",
- _ => throw new ArgumentOutOfRangeException(nameof(options.Framework), options.Framework.ToString())
- };
+ var tag = GetTag(options.Framework);
dockerfile.Should().ContainSnippet($"FROM mcr.microsoft.com/dotnet/aspnet:{tag} AS base");
dockerfile.Should().ContainSnippet($"FROM mcr.microsoft.com/dotnet/sdk:{tag} AS build");
var projectFile = GetProjectFileForLanguage(Sandbox.Name, options.Language);
dockerfile.Should().ContainSnippet($"COPY [\"{projectFile}\", \".\"]");
- dockerfile.Should().ContainSnippet($"RUN dotnet build \"{projectFile}\"");
- dockerfile.Should().ContainSnippet($"RUN dotnet publish \"{projectFile}\"");
+ dockerfile.Should().ContainSnippet($"RUN dotnet build \"./{projectFile}\"");
+ dockerfile.Should().ContainSnippet($"RUN dotnet publish \"./{projectFile}\"");
dockerfile.Should().ContainSnippet($"ENTRYPOINT [\"dotnet\", \"{Sandbox.Name}.dll\"");
}
+
+ private static string GetTag(Framework framework)
+ {
+ return framework switch
+ {
+ Framework.Net60 => "6.0",
+ Framework.Net80 => "8.0",
+ Framework.Net90 => "9.0",
+ _ => throw new ArgumentOutOfRangeException(nameof(framework), framework.ToString())
+ };
+ }
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/FrameworkParameterTest.cs b/test/NetCoreTool.Template.WebApi.Test/FrameworkParameterTest.cs
index 4f02f1c..e9361e3 100644
--- a/test/NetCoreTool.Template.WebApi.Test/FrameworkParameterTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/FrameworkParameterTest.cs
@@ -4,9 +4,11 @@ namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
public class FrameworkParameterTest : ChoiceParameterTest
{
- public FrameworkParameterTest(ITestOutputHelper logger) : base("framework", "Set the target framework for the project", logger)
+ public FrameworkParameterTest(ITestOutputHelper logger) : base("framework", "The target framework for the project.", logger)
{
Values.Add("net6.0");
+ Values.Add("net8.0");
+ Values.Add("net9.0");
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/HostingAzureSpringCloudOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/HostingAzureSpringCloudOptionTest.cs
index ee2251e..03de01e 100644
--- a/test/NetCoreTool.Template.WebApi.Test/HostingAzureSpringCloudOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/HostingAzureSpringCloudOptionTest.cs
@@ -4,27 +4,24 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class HostingAzureSpringCloudOptionTest : ProjectOptionTest
+ public class HostingAzureSpringCloudOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("hosting-azure-spring-cloud", "Add hosting support for running on Microsoft Azure Spring Cloud (Steeltoe 3.x only).", logger)
{
- public HostingAzureSpringCloudOptionTest(ITestOutputHelper logger) : base("hosting-azure-spring-cloud",
- "Add hosting support for Microsoft Azure Spring Cloud", logger)
- {
- }
-
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- switch (options.SteeltoeVersion)
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
{
- default:
- packages.Add(("Microsoft.Azure.SpringCloud.Client", "2.0.0-preview.3"));
- break;
+ packages.Add(("Microsoft.Azure.SpringCloud.Client", "2.0.0-preview.3"));
}
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Microsoft.Azure.SpringCloud.Client");
- snippets.Add(".UseAzureSpringCloudService");
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Microsoft.Azure.SpringCloud.Client;");
+ snippets.Add("builder.WebHost.UseAzureSpringCloudService();");
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/HostingCloudFoundryOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/HostingCloudFoundryOptionTest.cs
index 3d3fba5..66fd746 100644
--- a/test/NetCoreTool.Template.WebApi.Test/HostingCloudFoundryOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/HostingCloudFoundryOptionTest.cs
@@ -4,27 +4,55 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class HostingCloudFoundryOptionTest : ProjectOptionTest
+ public class HostingCloudFoundryOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("hosting-cloud-foundry", "Add hosting support for running on Cloud Foundry.", logger)
{
- public HostingCloudFoundryOptionTest(ITestOutputHelper logger) : base("hosting-cloud-foundry",
- "Add hosting support for Cloud Foundry", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.Extensions.Configuration.CloudFoundryCore", "$(SteeltoeVersion)"));
+ packages.Add(("Steeltoe.Common.Hosting", "$(SteeltoeVersion)"));
+ packages.Add(("Steeltoe.Connector.CloudFoundry", "$(SteeltoeVersion)"));
+ }
+ else
+ {
+ packages.Add(("Steeltoe.Configuration.CloudFoundry", "$(SteeltoeVersion)"));
+ }
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- packages.Add(("Steeltoe.Common.Hosting", "$(SteeltoeVersion)"));
- packages.Add(("Steeltoe.Extensions.Configuration.CloudFoundryCore", "$(SteeltoeVersion)"));
+ snippets.AddRange(GetNamespaceImports(options.SteeltoeVersion));
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
}
- protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ private static IEnumerable GetNamespaceImports(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "using Steeltoe.Common.Hosting;";
+ yield return "using Steeltoe.Extensions.Configuration.CloudFoundry;";
+ }
+ else
+ {
+ yield return "using Steeltoe.Configuration.CloudFoundry;";
+ }
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
{
- snippets.Add("Steeltoe.Common.Hosting");
- snippets.Add("Steeltoe.Extensions.Configuration.CloudFoundry");
- snippets.Add("Steeltoe.Extensions.Configuration.CloudFoundry");
- snippets.Add(".UseCloudHosting().AddCloudFoundryConfiguration()");
- snippets.Add("builder.Services.ConfigureCloudFoundryOptions");
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return "builder.UseCloudHosting();";
+ yield return "builder.AddCloudFoundryConfiguration();";
+ yield return "builder.Services.ConfigureCloudFoundryOptions(builder.Configuration);";
+ }
+ else
+ {
+ yield return "builder.AddCloudFoundryConfiguration();";
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/HostingCloudOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/HostingCloudOptionTest.cs
index 40e0891..8354f69 100644
--- a/test/NetCoreTool.Template.WebApi.Test/HostingCloudOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/HostingCloudOptionTest.cs
@@ -4,23 +4,25 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class HostingCloudOptionTest : ProjectOptionTest
+ public class HostingCloudOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("hosting-cloud", "Add support for listening on the port specified by the hosting environment (Steeltoe 3.x only).", logger)
{
- public HostingCloudOptionTest(ITestOutputHelper logger) : base("hosting-cloud",
- "Add hosting support for clouds", logger)
- {
- }
-
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- packages.Add(("Steeltoe.Common.Hosting", "$(SteeltoeVersion)"));
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.Common.Hosting", "$(SteeltoeVersion)"));
+ }
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Common.Hosting");
- snippets.Add(".UseCloudHosting(");
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Steeltoe.Common.Hosting;");
+ snippets.Add("builder.UseCloudHosting();");
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicConsoleOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicConsoleOptionTest.cs
new file mode 100644
index 0000000..f4c1ae1
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicConsoleOptionTest.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test
+{
+ public class LoggingDynamicConsoleOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("logging-dynamic-console", "Enable dynamically changing minimum levels at runtime using the .NET console logger.", logger)
+ {
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Logging.DynamicLogger" : "Steeltoe.Logging.DynamicConsole";
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)}");
+ snippets.Add("builder.Logging.AddDynamicConsole();");
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Logging" : "Steeltoe.Logging.DynamicConsole";
+ }
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicLoggerOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicLoggerOptionTest.cs
deleted file mode 100644
index 3e1ccb7..0000000
--- a/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicLoggerOptionTest.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System.Collections.Generic;
-using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
-using Xunit.Abstractions;
-
-namespace Steeltoe.NetCoreTool.Template.WebApi.Test
-{
- public class LoggingDynamicLoggerOptionTest : ProjectOptionTest
- {
- public LoggingDynamicLoggerOptionTest(ITestOutputHelper logger) : base("logging-dynamic-logger",
- "Add a dynamic logger",
- logger)
- {
- }
-
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
- {
- packages.Add(("Steeltoe.Extensions.Logging.DynamicLogger", "$(SteeltoeVersion)"));
- }
-
- protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
- {
- snippets.Add("Steeltoe.Extensions.Logging");
- snippets.Add(".Logging.AddDynamicConsole()");
- }
- }
-}
diff --git a/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicSerilogOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicSerilogOptionTest.cs
new file mode 100644
index 0000000..6e22656
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/LoggingDynamicSerilogOptionTest.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class LoggingDynamicSerilogOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("logging-dynamic-serilog", "Enable dynamically changing minimum levels at runtime using Serlog.", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Logging.DynamicSerilogCore" : "Steeltoe.Logging.DynamicSerilog";
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)}");
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Extensions.Logging.DynamicSerilog" : "Steeltoe.Logging.DynamicSerilog";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "builder.AddDynamicSerilog();" : "builder.Logging.AddDynamicSerilog();";
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ManagementEndpointsOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ManagementEndpointsOptionTest.cs
index 7a61f73..a628134 100644
--- a/test/NetCoreTool.Template.WebApi.Test/ManagementEndpointsOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/ManagementEndpointsOptionTest.cs
@@ -4,24 +4,33 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class ManagementEndpointsOptionTest : ProjectOptionTest
+ public class ManagementEndpointsOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("management-endpoints", "Add management endpoints, providing info about versions, configuration, mapped routes and HTTP traffic, heap/thread dumps, health checks and changing log levels.", logger)
{
- public ManagementEndpointsOptionTest(ITestOutputHelper logger) : base("management-endpoints",
- "Add application management endpoints, such as health and metrics", logger)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
{
- packages.Add(("Steeltoe.Management.EndpointCore", "$(SteeltoeVersion)"));
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Management.EndpointCore" : "Steeltoe.Management.Endpoint";
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Management.Endpoint");
- snippets.Add("builder.Services.AddAllActuators(");
- snippets.Add("builder.Services.ActivateActuatorEndpoints()");
- snippets.Add(".AddDynamicConsole(");
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.Add(GetSetupCodeFragment(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Management.Endpoint" : "Steeltoe.Management.Endpoint.Actuators.All";
+ }
+
+ private static string GetSetupCodeFragment(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "builder.AddAllActuators();" : "builder.Services.AddAllActuators();";
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/ManagementTasksOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/ManagementTasksOptionTest.cs
new file mode 100644
index 0000000..a906538
--- /dev/null
+++ b/test/NetCoreTool.Template.WebApi.Test/ManagementTasksOptionTest.cs
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit.Abstractions;
+
+namespace Steeltoe.NetCoreTool.Template.WebApi.Test;
+
+public class ManagementTasksOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("management-tasks", "Add task execution, based on command-line arguments.", logger)
+{
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ {
+ packages.Add((GetPackageName(options.SteeltoeVersion), "$(SteeltoeVersion)"));
+ }
+
+ private static string GetPackageName(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Management.TaskCore" : "Steeltoe.Management.Tasks";
+ }
+
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ {
+ snippets.Add($"using {GetNamespaceImport(options.SteeltoeVersion)};");
+ snippets.AddRange(GetSetupCodeFragments(options.SteeltoeVersion));
+ }
+
+ private static string GetNamespaceImport(SteeltoeVersion steeltoeVersion)
+ {
+ return steeltoeVersion == SteeltoeVersion.Steeltoe32 ? "Steeltoe.Management.TaskCore" : "Steeltoe.Management.Tasks";
+ }
+
+ private static IEnumerable GetSetupCodeFragments(SteeltoeVersion steeltoeVersion)
+ {
+ if (steeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ yield return @"builder.Services.AddTask(""run-me"", _ =>";
+ yield return "// Run this app with command-line argument: runtask=run-me";
+ yield return @"Console.WriteLine(""Hello from application task."");";
+ yield return "app.RunWithTasks();";
+ }
+ else
+ {
+ yield return @"builder.Services.AddTask(""run-me"", (_, _) =>";
+ yield return "// Run this app with command-line argument: runtask=run-me";
+ yield return @"Console.WriteLine(""Hello from application task."");";
+ yield return "await app.RunWithTasksAsync(CancellationToken.None);";
+ }
+ }
+}
diff --git a/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqClientOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqClientOptionTest.cs
index e00d4e3..663c806 100644
--- a/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqClientOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqClientOptionTest.cs
@@ -6,34 +6,31 @@
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class MessagingRabbitMqClientOptionTest : ProjectOptionTest
+ public class MessagingRabbitMqClientOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("messaging-rabbitmq-client", "Add a RabbitMQ client service for sending and receiving messages (Steeltoe 3.x only).", logger)
{
- public MessagingRabbitMqClientOptionTest(ITestOutputHelper logger) : base("messaging-rabbitmq-client",
- "Add a RabbitMQ client controller for sending and receiving messages", logger)
- {
- }
-
protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- packages.Add(("Steeltoe.Messaging.RabbitMQ", "$(SteeltoeVersion)"));
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.Messaging.RabbitMQ", "$(SteeltoeVersion)"));
+ }
}
protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- snippets.Add("Steeltoe.Messaging.RabbitMQ.Config");
- snippets.Add("Steeltoe.Messaging.RabbitMQ.Extensions");
- snippets.Add("builder.Services.AddRabbitServices(true)");
- snippets.Add("builder.Services.AddRabbitAdmin()");
- snippets.Add("builder.Services.AddRabbitQueue(");
- snippets.Add("builder.Services.AddRabbitTemplate()");
- }
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Steeltoe.Messaging.RabbitMQ.Config;");
+ snippets.Add("using Steeltoe.Messaging.RabbitMQ.Extensions;");
+ snippets.Add("using Steeltoe.Messaging.RabbitMQ.Core;");
- protected override async Task AssertProjectGeneration(ProjectOptions options)
- {
- await base.AssertProjectGeneration(options);
- Logger.WriteLine("asserting Controllers/RabbitMessageController");
- Sandbox.FileExists(GetSourceFileForLanguage("Controllers/RabbitMessageController", options.Language))
- .Should().BeTrue();
+ snippets.Add("builder.Services.AddRabbitServices(true);");
+ snippets.Add("builder.Services.AddRabbitAdmin();");
+ snippets.Add(@"builder.Services.AddRabbitQueue(new Queue(""steeltoe_message_queue""));");
+ snippets.Add("builder.Services.AddRabbitTemplate();");
+ snippets.Add(@"app.MapGet(""/sendtoqueue"", ([FromServices] RabbitTemplate rabbitTemplate, [FromServices] RabbitAdmin rabbitAdmin) =>");
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqListenerOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqListenerOptionTest.cs
index 1ed34b0..d1f8da3 100644
--- a/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqListenerOptionTest.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqListenerOptionTest.cs
@@ -1,40 +1,58 @@
using System.Collections.Generic;
+using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
+using Xunit;
using Xunit.Abstractions;
namespace Steeltoe.NetCoreTool.Template.WebApi.Test
{
- public class MessagingRabbitMqListenerOptionTest : ProjectOptionTest
+ public class MessagingRabbitMqListenerOptionTest(ITestOutputHelper logger)
+ : ProjectOptionTest("messaging-rabbitmq-listener", "Add a RabbitMQ listener service for processing messages (Steeltoe 3.x only).", logger)
{
- public MessagingRabbitMqListenerOptionTest(ITestOutputHelper logger) : base("messaging-rabbitmq-listener",
- "Add a RabbitMQ listener service for processing messages", logger)
+ [Fact]
+ [Trait("Category", "ProjectGeneration")]
+ public async Task TestDefaultNotPolluted()
{
+ using var sandbox = await TemplateSandbox("false");
+ sandbox.FileExists("RabbitListenerService.cs").Should().BeFalse();
}
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
+ protected override async Task AssertProjectGeneration(ProjectOptions options)
{
- packages.Add(("Steeltoe.Messaging.RabbitMQ", "$(SteeltoeVersion)"));
+ await base.AssertProjectGeneration(options);
+
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ await base.AssertProjectGeneration(options);
+ Logger.WriteLine("asserting Services");
+ Sandbox.FileExists(GetSourceFileForLanguage("RabbitListenerService", options.Language)).Should().BeTrue();
+ }
}
- protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
+ protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
{
- snippets.Add("Steeltoe.Messaging.RabbitMQ.Config");
- snippets.Add("Steeltoe.Messaging.RabbitMQ.Extensions");
-
- snippets.Add("builder.Services.AddRabbitServices(true)");
- snippets.Add("builder.Services.AddRabbitAdmin()");
- snippets.Add("builder.Services.AddRabbitQueue(");
- snippets.Add("builder.Services.AddSingleton()");
- snippets.Add("builder.Services.AddRabbitListeners()");
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ packages.Add(("Steeltoe.Messaging.RabbitMQ", "$(SteeltoeVersion)"));
+ }
}
- protected override async Task AssertProjectGeneration(ProjectOptions options)
+ protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
{
- await base.AssertProjectGeneration(options);
- Logger.WriteLine("asserting RabbitListenerService");
- Sandbox.FileExists(GetSourceFileForLanguage("Services/RabbitListenerService", options.Language)).Should().BeTrue();
+ if (options.SteeltoeVersion == SteeltoeVersion.Steeltoe32)
+ {
+ snippets.Add("using Steeltoe.Messaging.RabbitMQ.Config;");
+ snippets.Add("using Steeltoe.Messaging.RabbitMQ.Extensions;");
+ snippets.Add($"using {Sandbox.Name};");
+
+ snippets.Add("builder.Services.AddRabbitServices(true);");
+ snippets.Add("builder.Services.AddRabbitAdmin();");
+ snippets.Add(@"builder.Services.AddRabbitQueue(new Queue(""steeltoe_message_queue""));");
+ snippets.Add("builder.Services.AddSingleton();");
+ snippets.Add("builder.Services.AddRabbitListeners();");
+ }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqOptionTest.cs b/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqOptionTest.cs
deleted file mode 100644
index 79f03e8..0000000
--- a/test/NetCoreTool.Template.WebApi.Test/MessagingRabbitMqOptionTest.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using FluentAssertions;
-using Steeltoe.NetCoreTool.Template.WebApi.Test.Models;
-using Xunit.Abstractions;
-
-namespace Steeltoe.NetCoreTool.Template.WebApi.Test
-{
- public class MessagingRabbitMqOptionTest : ProjectOptionTest
- {
- public MessagingRabbitMqOptionTest(ITestOutputHelper logger) : base("messaging-rabbitmq",
- "Add both RabbitMQ client and listener services", logger)
- {
- }
-
- protected override void AssertPackageReferencesHook(ProjectOptions options, List<(string, string)> packages)
- {
- packages.Add(("Steeltoe.Messaging.RabbitMQ", "$(SteeltoeVersion)"));
- }
-
- protected override void AssertProgramSnippetsHook(ProjectOptions options, List snippets)
- {
- snippets.Add("Steeltoe.Messaging.RabbitMQ.Config");
- snippets.Add("Steeltoe.Messaging.RabbitMQ.Extensions");
-
- snippets.Add("builder.Services.AddRabbitServices(true)");
- snippets.Add("builder.Services.AddRabbitAdmin()");
- snippets.Add("builder.Services.AddRabbitQueue(");
- snippets.Add("builder.Services.AddSingleton()");
- snippets.Add("builder.Services.AddRabbitListeners()");
- snippets.Add("builder.Services.AddRabbitTemplate()");
- }
-
- protected override async Task AssertProjectGeneration(ProjectOptions options)
- {
- await base.AssertProjectGeneration(options);
- Logger.WriteLine("asserting Services/RabbitListenerService");
- Sandbox.FileExists(GetSourceFileForLanguage("Services/RabbitListenerService", options.Language)).Should().BeTrue();
- Logger.WriteLine("asserting Controllers/RabbitMessageController");
- Sandbox.FileExists(GetSourceFileForLanguage("Controllers/RabbitMessageController", options.Language))
- .Should().BeTrue();
- }
- }
-}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/AppSettings.cs b/test/NetCoreTool.Template.WebApi.Test/Models/AppSettings.cs
index 5cd5ef4..f2202d0 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/AppSettings.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/AppSettings.cs
@@ -7,27 +7,10 @@ public class AppSettings
[JsonPropertyName("$schema")]
public string Schema { get; set; }
- public SpringSettings Spring { get; set; }
-
public string ResolvedPlaceholderFromEnvVariables { get; set; }
public string UnresolvedPlaceholder { get; set; }
public string ResolvedPlaceholderFromJson { get; set; }
}
-
- public class SpringSettings
- {
- public CloudSettings Cloud { get; set; }
- }
-
- public class CloudSettings
- {
- public StreamSettings Stream { get; set; }
- }
-
- public class StreamSettings
- {
- public string Binder { get; set; }
- }
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/Framework.cs b/test/NetCoreTool.Template.WebApi.Test/Models/Framework.cs
index 766311f..6d816bd 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/Framework.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/Framework.cs
@@ -3,6 +3,7 @@ namespace Steeltoe.NetCoreTool.Template.WebApi.Test.Models
public enum Framework
{
Net60,
- Net80
+ Net80,
+ Net90
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/Language.cs b/test/NetCoreTool.Template.WebApi.Test/Models/Language.cs
index 37196ce..312f755 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/Language.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/Language.cs
@@ -2,7 +2,6 @@ namespace Steeltoe.NetCoreTool.Template.WebApi.Test.Models
{
public enum Language
{
- CSharp,
- FSharp,
+ CSharp
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/LaunchSettings.cs b/test/NetCoreTool.Template.WebApi.Test/Models/LaunchSettings.cs
index 59bb8ae..f6419b5 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/LaunchSettings.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/LaunchSettings.cs
@@ -8,7 +8,9 @@ public class LaunchSettings
public class Profile
{
+ public bool LaunchBrowser { get; set; }
public string LaunchUrl { get; set; }
+ public string ApplicationUrl { get; set; }
}
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/ProjectOptions.cs b/test/NetCoreTool.Template.WebApi.Test/Models/ProjectOptions.cs
index b452ecb..2db2178 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/ProjectOptions.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/ProjectOptions.cs
@@ -10,6 +10,6 @@ public class ProjectOptions
public Language Language { get; set; }
- public List Dependencies { get; set; } = new List();
+ public List Dependencies { get; set; } = [];
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/SteeltoeVersion.cs b/test/NetCoreTool.Template.WebApi.Test/Models/SteeltoeVersion.cs
index 4efd61a..4198ce1 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/SteeltoeVersion.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/SteeltoeVersion.cs
@@ -3,5 +3,6 @@ namespace Steeltoe.NetCoreTool.Template.WebApi.Test.Models
public enum SteeltoeVersion
{
Steeltoe32,
+ Steeltoe40
}
}
diff --git a/test/NetCoreTool.Template.WebApi.Test/Models/TemplateOptions.cs b/test/NetCoreTool.Template.WebApi.Test/Models/TemplateOptions.cs
index 9fbe019..5579950 100644
--- a/test/NetCoreTool.Template.WebApi.Test/Models/TemplateOptions.cs
+++ b/test/NetCoreTool.Template.WebApi.Test/Models/TemplateOptions.cs
@@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
-using System.Linq;
namespace Steeltoe.NetCoreTool.Template.WebApi.Test.Models
{
@@ -12,10 +11,11 @@ public IEnumerator