Feat/net6.0 upgrade (#1558)

* +semver: major upgrading from net5.0 to net6.0

* packages upgraded

* removed global.json for ocelot sf sample

* update build image

* test new build

* remove make

* fix tests

* make test fail like in CI

* tests passing locally

* updated docs


Co-authored-by: TGP <thomasgardham-pallister@Thomass-MacBook-Pro-2.local>
This commit is contained in:
Tom Pallister
2022-01-20 09:04:04 +00:00
committed by GitHub
parent 3dcc6b6d14
commit e5ee57bf24
46 changed files with 255 additions and 753 deletions

View File

@ -1,10 +1,10 @@
Building
========
* The best way to build Ocelot is using the Dockerfile.build file which can be found in the docker folder in Ocelot root. Use the following command `docker build -f ./docker/Dockerfile.build .`.
* You can also just run `dotnet tool restore && dotnet cake` locally!. Output will got to the `./artifacts` directory.
* You'll can run the `./build.ps1` or `./build.sh` script depending on your OS. This will compile, run unit and acceptance tests and build the output packages locally. Output will got to the `./artifacts` directory.
* The best way to replicate the CI process is to build Ocelot locally is using the Dockerfile.build file which can be found in the docker folder in Ocelot root. Use the following command `docker build --platform linux/amd64 -f ./docker/Dockerfile.build .` for example. You will need to change the platform flag depending on your platform.
* There is a Makefile to make it easier to call the various targers in `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 VS2019 with the latest .NET Core SDK.
* Alternatively you can build the project in VS2022 with the latest .NET 6.0 SDK.

View File

@ -1,24 +1,7 @@
Tests
=====
The tests should all just run and work apart from the integration tests which need the following
environmental variables setting. This is a manual step at the moment.
``OCELOT_USERNAME=admin``
``OCELOT_HASH=kE/mxd1hO9h9Sl2VhGhwJUd9xZEv4NP6qXoN39nIqM4=``
``OCELOT_SALT=zzWITpnDximUNKYLiUam/w==``
On windows you can use..
``SETX OCELOT_USERNAME admin``
On mac..
``export OCELOT_USERNAME=admin``
I need to work out a nicer way of doing this in the future.
The tests should all just run and work as part of the build process. You can of course also run them in visual studio.

View File

@ -12,7 +12,8 @@ Thanks for taking a look at the Ocelot documentation. Please use the left hand n
introduction/gettingstarted
introduction/contributing
introduction/notsupported
introduction/gotchas
.. toctree::
:maxdepth: 2
:hidden:

View File

@ -1,14 +1,14 @@
Getting Started
===============
Ocelot is designed to work with .NET Core only and is currently on netcoreapp3.1.
Ocelot is designed to work with ASP.NET and is currently on net6.0.
.NET Core 3.1
^^^^^^^^^^^^^
.NET 6.0
^^^^^^^^
**Install NuGet package**
Install Ocelot and it's dependencies using nuget. You will need to create a netcoreapp3.1 project and bring the package into it. Then follow the Startup below and :doc:`../features/configuration` sections
Install Ocelot and it's dependencies using nuget. You will need to create a net6.0 project and bring the package into it. Then follow the Startup below and :doc:`../features/configuration` sections
to get up and running.
``Install-Package Ocelot``
@ -103,87 +103,4 @@ Then in your Program.cs you will want to have the following. The main things to
.Run();
}
}
}
**Note:** When using ASP.NET Core 2.2 and you want to use In-Process hosting, replace **.UseIISIntegration()** with **.UseIIS()**, otherwise you'll get startup errors.
.NET Core 1.0
^^^^^^^^^^^^^
**Install NuGet package**
Install Ocelot and it's dependecies using nuget. You will need to create a netcoreapp1.0+ projct and bring the package into it. Then follow the Startup below and :doc:`../features/configuration` sections to get up and running. Please note you will need to choose one of the Ocelot packages from the NuGet feed.
All versions can be found `here <https://www.nuget.org/packages/Ocelot/>`_.
**Configuration**
The following is a very basic ocelot.json. It won't do anything but should get Ocelot starting.
.. code-block:: json
{
"Routes": [],
"GlobalConfiguration": {}
}
**Program**
Then in your Program.cs you will want to have the following.
.. code-block:: csharp
public class Program
{
public static void Main(string[] args)
{
IWebHostBuilder builder = new WebHostBuilder();
builder.ConfigureServices(s => {
});
builder.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>();
var host = builder.Build();
host.Run();
}
}
**Startup**
An example startup using a json file for configuration can be seen below.
.. code-block:: csharp
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot(Configuration);
}
public void Configure(IApplicationBuilder app)
{
app.UseOcelot().Wait();
}
}
This is pretty much all you need to get going.
}

View File

@ -0,0 +1,4 @@
Gotchas
=============
**Note:** When using ASP.NET Core 2.2 and you want to use In-Process hosting, replace **.UseIISIntegration()** with **.UseIIS()**, otherwise you'll get startup errors.