Skip to content

Commit

Permalink
.NET8 Release artifacts (#1792)
Browse files Browse the repository at this point in the history
* Update .gitignore

* Update README.md

* Update docs as .NET SDK agnostic. With .NET 8

* ...and gotchas

* Update release notes

* Update build.cake
  • Loading branch information
raman-m committed Nov 20, 2023
1 parent 24b507e commit 7d93623
Show file tree
Hide file tree
Showing 17 changed files with 288 additions and 100 deletions.
230 changes: 197 additions & 33 deletions .gitignore

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Tom Pallister
Copyright (c) 2023 Tom Pallister, Ocelot Core team at ThreeMammals, and GitHub Ocelot community.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ A quick list of Ocelot's capabilities, for more information see the [Documentati

## Install

Ocelot is designed to work with ASP.NET Core and it targets `net7.0` framework.
Ocelot is designed to work with ASP.NET Core and it targets `net6.0`, `net7.0` and `net8.0` frameworks. [^4]

Install [Ocelot package](https://www.nuget.org/packages/Ocelot) and its dependencies using NuGet Package Manager:
```powershell
Install-Package Ocelot
Expand Down Expand Up @@ -78,7 +79,7 @@ We can also give advice on the easiest way to do things :octocat:
Finally, we mark all existing issues as [![label: help wanted][~helpwanted]](https://github.com/ThreeMammals/Ocelot/labels/help%20wanted)
[![label: small effort][~smalleffort]](https://github.com/ThreeMammals/Ocelot/labels/small%20effort)
[![label: medium effort][~mediumeffort]](https://github.com/ThreeMammals/Ocelot/labels/medium%20effort)
[![label: large effort][~largeeffort]](https://github.com/ThreeMammals/Ocelot/labels/large%20effort) [^4].
[![label: large effort][~largeeffort]](https://github.com/ThreeMammals/Ocelot/labels/large%20effort). [^5]
<br/>If you want to contribute for the first time, we suggest looking at a [![label: help wanted][~helpwanted]](https://github.com/ThreeMammals/Ocelot/labels/help%20wanted)
[![label: small effort][~smalleffort]](https://github.com/ThreeMammals/Ocelot/labels/small%20effort)
[![label: good first issue][~goodfirstissue]](https://github.com/ThreeMammals/Ocelot/labels/good%20first%20issue) :octocat:
Expand All @@ -93,4 +94,5 @@ Finally, we mark all existing issues as [![label: help wanted][~helpwanted]](htt
[^1]: Ocelot doesn’t directly support [GraphQL](https://graphql.org/). Developers can easily integrate the [GraphQL for .NET](/graphql-dotnet/graphql-dotnet) library.
[^2]: Ocelot does support [Consul](https://www.consul.io/), [Netflix Eureka](https://www.nuget.org/packages/Steeltoe.Discovery.Eureka), [Service Fabric](https://azure.microsoft.com/en-us/products/service-fabric/) service discovery providers, and special modes like [Dynamic Routing](/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst#dynamic-routing) and [Custom Providers](/ThreeMammals/Ocelot/blob/main/docs/features/servicediscovery.rst#custom-providers).
[^3]: Retry policies only via [Polly](/App-vNext/Polly) library.
[^4]: See all [labels](https://github.com/ThreeMammals/Ocelot/issues/labels) of the repository.
[^4]: Starting with [v21.0](https://github.com/ThreeMammals/Ocelot/releases/tag/21.0.0), the solution's code base supports [Multitargeting](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-multitargeting-overview) as SDK-style projects. It should be easier for teams to move between (migrate to) .NET 6, 7 and 8 frameworks. Also, new features will be available for all .NET SDKs which we support via multitargeting. Find out more here: [Target frameworks in SDK-style projects](https://learn.microsoft.com/en-us/dotnet/standard/frameworks)
[^5]: See all [labels](https://github.com/ThreeMammals/Ocelot/issues/labels) of the repository.
19 changes: 17 additions & 2 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
## Documentation release {0} for [Polish Apple](https://www.google.com/search?q=Polish+Apple), v{1}
Special thanks to @ggnaegi!
## Upgrade to .NET 8 (version {0}) aka [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) release
> Read article: [Announcing .NET 8](https://devblogs.microsoft.com/dotnet/announcing-dotnet-8/) by Gaurav Seth, on November 14th, 2023
### About
We are pleased to announce to you that we can now offer the support of [.NET 8](https://dotnet.microsoft.com/en-us/download).
But that is not all, in this release, we are adopting support of several versions of the .NET framework through [multitargeting](https://learn.microsoft.com/en-us/dotnet/standard/frameworks).
The Ocelot distribution is now compatible with .NET **6**, **7** and **8**. :tada:

In the future, we will try to ensure the support of the [.NET SDKs](https://dotnet.microsoft.com/en-us/download/dotnet) that are still actively maintained by the .NET team and community.
Current .NET versions in support are the following: [6, 7, 8](https://dotnet.microsoft.com/en-us/download/dotnet).

### Technical info
As an ASP.NET Core app, now Ocelot targets `net6.0`, `net7.0` and `net8.0` frameworks.

Starting with **v{0}**, the solution's code base supports [Multitargeting](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-multitargeting-overview) as SDK-style projects.
It should be easier for teams to move between (migrate to) .NET 6, 7 and 8 frameworks. Also, new features will be available for all .NET SDKs which we support via multitargeting.
Find out more here: [Target frameworks in SDK-style projects](https://learn.microsoft.com/en-us/dotnet/standard/frameworks)
75 changes: 42 additions & 33 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#tool "dotnet:?package=coveralls.net&version=4.0.1"
#addin nuget:?package=Newtonsoft.Json
#addin nuget:?package=System.Text.Encodings.Web&version=4.7.1
#tool "nuget:?package=ReportGenerator&version=5.1.19"
#tool "nuget:?package=ReportGenerator&version=5.2.0"
#addin Cake.Coveralls&version=1.1.0

#r "Spectre.Console"
Expand Down Expand Up @@ -42,8 +42,9 @@ var benchmarkTestAssemblies = @"./test/Ocelot.Benchmarks";

// packaging
var packagesDir = artifactsDir + Directory("Packages");
var releaseNotesFile = packagesDir + File("ReleaseNotes.md");
var artifactsFile = packagesDir + File("artifacts.txt");
var releaseNotesFile = packagesDir + File("ReleaseNotes.md");
var releaseNotes = new List<string>();

// stable releases
var tagsUrl = "https://api.github.com/repos/ThreeMammals/ocelot/releases/tags/";
Expand Down Expand Up @@ -85,8 +86,8 @@ Task("Release")
.IsDependentOn("Build")
.IsDependentOn("CreateReleaseNotes")
.IsDependentOn("CreateArtifacts")
.IsDependentOn("PublishGitHubRelease");
// .IsDependentOn("PublishToNuget");
.IsDependentOn("PublishGitHubRelease")
.IsDependentOn("PublishToNuget");

Task("Compile")
.IsDependentOn("Clean")
Expand Down Expand Up @@ -135,7 +136,7 @@ Task("Version")
Task("CreateReleaseNotes")
.IsDependentOn("Version")
.Does(() =>
{
{
Information($"Generating release notes at {releaseNotesFile}");

// local helper function
Expand All @@ -158,7 +159,7 @@ Task("CreateReleaseNotes")
var releaseVersion = versioning.NuGetVersion;
// Read main header from Git file, substitute version in header, and add content further...
var releaseHeader = string.Format(System.IO.File.ReadAllText("./ReleaseNotes.md"), releaseVersion, lastRelease);
var releaseNotes = new List<string> { releaseHeader };
releaseNotes = new List<string> { releaseHeader };

var shortlogSummary = GitHelper($"shortlog --no-merges --numbered --summary {lastRelease}..HEAD");
var re = new Regex(@"^[\s\t]*(?'commits'\d+)[\s\t]+(?'author'.*)$");
Expand Down Expand Up @@ -296,27 +297,36 @@ Task("CreateReleaseNotes")
}
}
} // END of Top 3
//releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:");
//releaseNotes.AddRange(topContributors);
//releaseNotes.Add("");
releaseNotes.Add("### Honoring :medal_sports: aka Top Contributors :clap:");
releaseNotes.AddRange(topContributors);
releaseNotes.Add("");
releaseNotes.Add("### Starring :star: aka Release Influencers :bowtie:");
releaseNotes.AddRange(starring);
releaseNotes.Add("");
releaseNotes.Add($"### Features in Release {releaseVersion}");
var commitsHistory = GitHelper($"log --no-merges --date=format:\"%A, %B %d at %H:%M\" --pretty=format:\"<sub>%h by **%aN** on %ad &rarr;</sub>%n%s\" {lastRelease}..HEAD");
releaseNotes.AddRange(commitsHistory);

EnsureDirectoryExists(packagesDir);
System.IO.File.WriteAllLines(releaseNotesFile, releaseNotes);
WriteReleaseNotes();
});

private void WriteReleaseNotes()
{
Information($"RUNNING {nameof(WriteReleaseNotes)} ...");

if (string.IsNullOrEmpty(System.IO.File.ReadAllText(releaseNotesFile)))
{
System.IO.File.WriteAllText(releaseNotesFile, "No commits since last release");
}
EnsureDirectoryExists(packagesDir);
System.IO.File.WriteAllLines(releaseNotesFile, releaseNotes);

var content = System.IO.File.ReadAllText(releaseNotesFile);
if (string.IsNullOrEmpty(content))
{
System.IO.File.WriteAllText(releaseNotesFile, "No commits since last release");
}

Information($"Release notes are >>>\n{content}<<<");
Information($"EXITED {nameof(WriteReleaseNotes)}");
}

Information("Release notes are >>>" + Environment.NewLine + System.IO.File.ReadAllText(releaseNotesFile) + "<<<");
});

Task("RunUnitTests")
.IsDependentOn("Compile")
.Does(() =>
Expand Down Expand Up @@ -407,25 +417,24 @@ Task("CreateArtifacts")
.IsDependentOn("Compile")
.Does(() =>
{
EnsureDirectoryExists(packagesDir);
WriteReleaseNotes();
System.IO.File.AppendAllLines(artifactsFile, new[] { "ReleaseNotes.md" });
CopyFiles("./ReleaseNotes.md", packagesDir);
// CopyFiles("./src/**/Release/Ocelot.*.nupkg", packagesDir);
// var projectFiles = GetFiles("./src/**/Release/Ocelot.*.nupkg");
// foreach(var projectFile in projectFiles)
// {
// System.IO.File.AppendAllLines(
// artifactsFile,
// new[] { projectFile.GetFilename().FullPath }
// );
// }
CopyFiles("./src/**/Release/Ocelot.*.nupkg", packagesDir);
var projectFiles = GetFiles("./src/**/Release/Ocelot.*.nupkg");
foreach(var projectFile in projectFiles)
{
System.IO.File.AppendAllLines(
artifactsFile,
new[] { projectFile.GetFilename().FullPath }
);
}
var artifacts = System.IO.File.ReadAllLines(artifactsFile)
.Distinct();
foreach(var artifact in artifacts)
Information($"Listing all {nameof(artifacts)}...");
foreach (var artifact in artifacts)
{
var codePackage = packagesDir + File(artifact);
if (FileExists(codePackage))
Expand Down
2 changes: 1 addition & 1 deletion docs/building/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Building
* There is a `Makefile <https://github.com/ThreeMammals/Ocelot/blob/main/docs/Makefile>`_ to make it easier to call the various targets in `build.cake <https://github.com/ThreeMammals/Ocelot/blob/main/build.cake>`_.
The scripts are called with **.sh** but can be easily changed to **.ps1** if you are using Windows.

* Alternatively you can build the project in VS2022 with the latest `.NET 7.0 <https://dotnet.microsoft.com/en-us/download/dotnet/7.0>`_ SDK.
* Alternatively you can build the project in VS2022 with the latest `.NET 8.0 <https://dotnet.microsoft.com/en-us/download/dotnet/8.0>`_ SDK.
2 changes: 1 addition & 1 deletion docs/building/releaseprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Ocelot uses the following process to accept work into the NuGet packages.
1. User creates an issue or picks up an `existing issue <https://github.com/ThreeMammals/Ocelot/issues>`_ in GitHub.
An issue can be created by converting `discussion <https://github.com/ThreeMammals/Ocelot/discussions>`_ topics if necessary and agreed upon.

2. User creates a fork and branches from this (unless a member of core team, they can just create a branch on the head repo) e.g. ``feature/xxx``, ``bug/xxx`` etc.
2. User creates `a fork <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_ and branches from this (unless a member of core team, they can just create a branch on the head repo) e.g. ``feature/xxx``, ``bug/xxx`` etc.
It doesn't really matter what the "xxx" is. It might make sense to use the issue number and maybe a short description.

3. When the contributor is happy with their work they can create a pull request against **develop** in GitHub with their changes.
Expand Down
6 changes: 2 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

project = 'Ocelot'
copyright = ' 2023 ThreeMammals Ocelot team'
author = 'Tom Pallister, Ocelot Core team at ThreeMammals and Ocelot GitHub community'
release = '20.0.0'
author = 'Tom Pallister, Ocelot Core team at ThreeMammals'
release = '21.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -19,8 +19,6 @@
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

Expand Down
2 changes: 1 addition & 1 deletion docs/features/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ to you:
Ocelot will now use the environment specific configuration and fall back to **ocelot.json** if there isn't one.

You also need to set the corresponding environment variable which is ``ASPNETCORE_ENVIRONMENT``.
More info on this can be found in the ASP.NET Core docs: `Use multiple environments in ASP.NET Core <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-7.0>`_.
More info on this can be found in the ASP.NET Core docs: `Use multiple environments in ASP.NET Core <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments>`_.

Merging Configuration Files
---------------------------
Expand Down
8 changes: 4 additions & 4 deletions docs/features/dependencyinjection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ It gives you full control on design and buiding of Ocelot pipeline, but be caref
Warning! Most of services from minimal part of the pipeline should be reused, but only a few of services could be removed.

Warning!! The method above is called after adding required services of ASP.NET MVC pipeline building by
`AddMvcCore <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.mvccoreservicecollectionextensions.addmvccore?view=aspnetcore-7.0>`_ method
`AddMvcCore <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.mvccoreservicecollectionextensions.addmvccore>`_ method
over the ``Services`` property in upper calling context. These services are absolute minimum core services for ASP.NET MVC pipeline.
They must be added to DI container always, and they are added implicitly before calling of the method by caller in upper context.
So, ``AddMvcCore`` creates an ``IMvcCoreBuilder`` object with its assignment to the ``MvcCoreBuilder`` property.
Expand All @@ -124,13 +124,13 @@ The Problem
^^^^^^^^^^^

The default `AddOcelot <#the-addocelot-method>`_ method adds
`Newtonsoft JSON <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.newtonsoftjsonmvccorebuilderextensions.addnewtonsoftjson?view=aspnetcore-7.0>`_ services
`Newtonsoft JSON <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.newtonsoftjsonmvccorebuilderextensions.addnewtonsoftjson>`_ services
by the ``AddNewtonsoftJson`` extension method in default builder (the `AddDefaultAspNetServices <#the-adddefaultaspnetservices-method>`_ method).
The ``AddNewtonsoftJson`` method calling was introduced in old .NET and Ocelot releases which was necessary when Microsoft did not launch the ``System.Text.Json`` library,
but now it affects normal use, so we have an intention to solve the problem.

Modern `JSON services <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.mvccoremvccorebuilderextensions.addjsonoptions?view=aspnetcore-7.0>`_
out of `the box <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.mvccoremvccorebuilderextensions?view=aspnetcore-7.0>`_
Modern `JSON services <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.mvccoremvccorebuilderextensions.addjsonoptions>`_
out of `the box <https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.mvccoremvccorebuilderextensions>`_
will help to configure JSON settings by the ``JsonSerializerOptions`` property for JSON formatters during (de)serialization.

Solution
Expand Down
6 changes: 3 additions & 3 deletions docs/features/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Logging
=======

Ocelot uses the standard logging interfaces ``ILoggerFactory`` and ``ILogger<T>`` at the moment.
This is encapsulated in ``IOcelotLogger`` and ``IOcelotLoggerFactory`` with an implementation for the standard `ASP.NET Core logging <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-7.0>`_ stuff at the moment.
This is encapsulated in ``IOcelotLogger`` and ``IOcelotLoggerFactory`` with an implementation for the standard `ASP.NET Core logging <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/>`_ stuff at the moment.
This is because Ocelot adds some extra info to the logs such as **request ID** if it is configured.

There is a global `error handler middleware <https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20ExceptionHandlerMiddleware&type=code>`_ that should catch any exceptions thrown and log them as errors.
Expand All @@ -16,8 +16,8 @@ Nicely onto the next feature.
Warning
-------

If you are logging to `Console <https://learn.microsoft.com/en-us/dotnet/api/system.console?view=net-7.0>`_, you will get terrible performance.
The team has had so many issues about performance issues with Ocelot and it is always logging level **Debug**, logging to `Console <https://learn.microsoft.com/en-us/dotnet/api/system.console?view=net-7.0>`_.
If you are logging to `Console <https://learn.microsoft.com/en-us/dotnet/api/system.console>`_, you will get terrible performance.
The team has had so many issues about performance issues with Ocelot and it is always logging level **Debug**, logging to `Console <https://learn.microsoft.com/en-us/dotnet/api/system.console>`_.

* **Warning!** Make sure you are logging to something proper in production environment!
* Use **Error** and **Critical** levels in production environment!
Expand Down
2 changes: 1 addition & 1 deletion docs/features/middlewareinjection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ So, the next called middlewares **will not** affect Ocelot configuration.
ASP.NET Core Middlewares and Ocelot Pipeline Builder
----------------------------------------------------

Ocelot pipeline is a part of entire `ASP.NET Core Middlewares <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-7.0>`_ conveyor aka app pipeline.
Ocelot pipeline is a part of entire `ASP.NET Core Middlewares <https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/>`_ conveyor aka app pipeline.
The `BuildOcelotPipeline <https://github.com/search?q=repo%3AThreeMammals%2FOcelot+BuildOcelotPipeline+path%3A%2F%5Esrc%5C%2FOcelot%5C%2FMiddleware%5C%2F%2F&type=code>`_ method encapsulates Ocelot pipeline.
The last middleware in the ``BuildOcelotPipeline`` method is ``HttpRequesterMiddleware`` that calls the next middleware, if added to the pipeline.

Expand Down
Loading

0 comments on commit 7d93623

Please sign in to comment.