At first verify that .NET Core SDK is installed by running
$ dotnet
If you see dotnet: command not found
, then follow the steps described in https://www.microsoft.com/net/core to install it.
-
Add the dotnet apt-get feed
$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list' $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893 $ sudo apt-get update
-
Install the .NET Core SDK
$ sudo apt-get install dotnet-dev-1.0.4
-
Initialize a new console app
$ dotnet new console -o ConsoleApp && cd ConsoleApp
-
Run your app and verify that it prints "Hello World!"
$ dotnet restore && dotnet run
-
Add the
Sharpbrake.Client
dependency inConsoleApp.csproj
$ cat ConsoleApp.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp1.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Sharpbrake.Client" Version="4.0.1" /> </ItemGroup> </Project>
-
Integrate
Sharpbrake.Client
with your app$ cat Program.cs
using System; using Sharpbrake.Client; namespace ConsoleApp { class Program { public static void Main(string[] args) { var airbrake = new AirbrakeNotifier(new AirbrakeConfig { ProjectId = "113743", ProjectKey = "81bbff95d52f8856c770bb39e827f3f6" }); try { throw new Exception("Oops!"); } catch (Exception ex) { var notice = airbrake.BuildNotice(ex); var response = airbrake.NotifyAsync(notice).Result; Console.WriteLine("Status: {0}, Id: {1}, Url: {2}", response.Status, response.Id, response.Url); } } } }
-
Run the app
$ dotnet restore && dotnet run
The app should print a URL to your exception in the Airbrake dashboard.