Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sentry CLI for MSBuild #6183

Merged
merged 4 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/platform-includes/configuration/config-intro/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ use __ = SentrySdk.Init(fun o ->

// app code here
```

<PlatformContent includePath="getting-started-confignote" />
2 changes: 2 additions & 0 deletions src/platform-includes/getting-started-config/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ use __ = SentrySdk.Init (fun o ->

// App code goes here - Disposing will flush events out
```

<PlatformContent includePath="getting-started-confignote" />
7 changes: 7 additions & 0 deletions src/platform-includes/getting-started-confignote/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Note>

After you have configured Sentry in your code, you can also configure the
[MSBuild setup](/platforms/dotnet/configuration/msbuild/) for your project. While this step is optional,
it can greatly improves your Sentry experience.

</Note>
19 changes: 14 additions & 5 deletions src/platforms/common/data-management/debug-files/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,21 @@ system libraries to provide fully symbolicated crash reports. You can either
[upload](./upload/) your files to Sentry or put them on a compatible
[Symbol Server](./symbol-servers/) to be downloaded by Sentry when needed.

Debug information files can be managed on the _Debug Files_ section in _Project
Settings_. This page lists all uploaded files and allows to configure symbol
servers for automatic downloads.
## Managing Debug Information Files

ProGuard files can be managed on the _ProGuard_ section in _Project
Settings_. This page lists all uploaded files.
After they have been uploaded, debug information files can be viewed and managed
from the _Debug Files_ section in the associated project's settings page. That page
lists all uploaded debug files, and also allows you to configure symbol servers
for automatic downloads.

From the [Project Details](/product/projects/project-details/) page, click into settings,
then click on _Debug Files_ in the page navigation.

<Note>

ProGuard files are listed separately, in the _ProGuard_ section of the project settings page.

</Note>

## Learn More

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@ around the location of stack frames. Certain SDKs can resolve this source
context automatically, such as the Python SDK, because they have access to
unobfuscated source code at runtime.

To get source context for native applications, source code needs to be uploaded
alongside the debug information files. The recommended way to do this is by
using `sentry-cli`. See [Creating Source Bundles](/product/cli/dif/#creating-source-bundles) for more information.

Source bundles show up as regular debug files on the _Debug Files_ settings
page. They are designated as "source bundle" and feature a `sources` tag. To
match them with crash reports, they carry the same debug file as the respective
debug information file they have been created from.
By contrast, to get source context for compiled applications, the source code
needs to be uploaded alongside the debug information files.
The recommended way to do this is by using `sentry-cli`.
See [Creating Source Bundles](/product/cli/dif/#creating-source-bundles) for more information.

<PlatformSection supported={["dotnet"]} notSupported={["unity"]}>

<Note>

For .NET projects, you can [configure MSBuild](../../../configuration/msbuild/) to
call `sentry-cli` automatically. Enable the `SentryUploadSources` property to
create and upload source bundles automatically while uploading symbols.

</Note>

</PlatformSection>

After they've been uploaded you can review and manage source bundles the same as
any other debug information file. See [Managing Debug Information Files](../#managing-debug-information-files).
Source bundles will be tagged with `sources`, and will carry the same filename as the
respective debug information file they were created from.
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
---
title: CLI Integration
description: "Configure your project to use the features provided by the Sentry CLI integration."
title: MSBuild Setup
description: "Configure MSBuild properties in your .NET project to automatically use the Sentry CLI."
sidebar_order: 10
redirect_from:
- /platforms/dotnet/configuration/cli-integration/
---

The [Sentry CLI](/product/cli) provides many useful features. For .NET, we can use it to upload [debug information files](/product/cli/dif) to Sentry,
such as .NET `PDB` symbol files. This allows Sentry to show a more complete stack trace, including filenames and line numbers.
The [Sentry CLI](/product/cli) has many useful features that can improve your Sentry experience.
For .NET, you can use it to upload [debug information files](/product/cli/dif), such as .NET `PDB` symbol files.
This allows Sentry to show a more complete stack trace, including file names and line numbers.
You can also use it to upload *source code*, which enables Sentry to display [source context](../../data-management/debug-files/source-context/)
when viewing stack traces.

In the future, we may incorporate additional features of the Sentry CLI into the Sentry .NET SDK.
While you can always run `sentry-cli` from the command line manually, we've made it easier by including it in the `Sentry`
NuGet package, and providing properties to enable it from your build.

## Authentication

For this integration to work, you must authenticate to Sentry on the machine that is performing your release builds.
For this feature to work, you must authenticate to Sentry on the machine that is performing your release builds.

<Alert level="info" title="Important">

Expand Down Expand Up @@ -162,7 +168,7 @@ for more complex builds.

### Additonal MSBuild Properties

There are a few extra properties available to control the usage of the Sentry CLI integration:
There are a few additional properties available to control the Sentry CLI:

<ConfigKey name="SentryUploadSymbols">

Expand All @@ -171,10 +177,39 @@ or `false` otherwise.

</ConfigKey>

<ConfigKey name="SentryUploadSources">

Controls whether source code files are uploaded to Sentry during the build. Defaults to `false`.
Set `true` to opt-in to enable [source context](../../data-management/debug-files/source-context/) when viewing stack traces.

<Note>

If you are already embedding source code in your symbol files using [`EmbedAllSources`](https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embedallsources),
you do not need to upload them to Sentry separately. In other words, use *either* `SentryUploadSources` or `EmbedAllSources`, not both.

</Note>

</ConfigKey>

<ConfigKey name="SentryIncludeIntermediateOutputPath">

When uploading symbols, the `bin` folder of each project is always searched for debug information files.
Set this option to `true` to also search the `obj` folder. Defaults to `false`.

<Note>

For some application types, such as those that use AOT compilation, this will collect significantly more
files than you may expect. Typically, these files are not needed for symbolication, but can add additional
information for *native* crashes.

</Note>

</ConfigKey>

<ConfigKey name="UseSentryCLI">

Controls whether the Sentry CLI integration is enabled. `true` by default.
Set to `false` to disable the Sentry CLI integration completely, ignoring all other properties.
Controls whether the Sentry CLI is enabled in your build. `true` by default.
Set to `false` to disable the Sentry CLI completely, ignoring all other properties.

</ConfigKey>

Expand Down
10 changes: 5 additions & 5 deletions src/platforms/dotnet/common/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ The following message may appear in your build output:

The message currently appears as information only, though we may change it to a warning in the future.
This means that you are building in `Release` configuration, and you have not fully configured
the [Sentry CLI integration](../configuration/cli-integration). You can handle this in one of the following ways:
[MSBuild for Sentry CLI](../configuration/msbuild/). You can handle this in one of the following ways:

- You can enable the Sentry CLI integration by providing configuration details, as described in [the documentation here](../configuration/cli-integration).
- You can enable the Sentry CLI in your build by providing configuration details, as described in [the documentation here](../configuration/msbuild/).

- You can prevent the message from being generated by setting the property `<UseSentryCLI>false</UseSentryCLI>` in your .NET project file,
or with `/p:UseSentryCLI=false` on the command line to `dotnet build` or `msbuild`. The Sentry CLI integration will be disabled.
or with `/p:UseSentryCLI=false` on the command line to `dotnet build` or `msbuild`. Sentry CLI will be disabled.

- You can do nothing, and just ignore the message. The Sentry CLI integration will be disabled.
- You can do nothing, and just ignore the message. Sentry CLI will be disabled.

Keep in mind that if the Sentry CLI integration is disabled, then debug information files such as PDB symbols
Keep in mind that if the Sentry CLI is disabled, then debug information files such as PDB symbols
will not be sent to Sentry. If Sentry cannot locate symbols, then it cannot perform symbolication of stack traces.
This means that for some types of projects (depending on configuration), you may not see filenames and line numbers
to help you locate the source of an exception.
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/aspnet/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class MvcApplication : HttpApplication
}
```

<PlatformContent includePath="getting-started-confignote" />

### Capturing the affected user

When opting-in to [SendDefaultPii](#senddefaultpii), the SDK will automatically read the user from the request by inspecting `HttpContext.User`. Default claim values like `NameIdentifier` for the _Id_ will be used.
Expand Down
5 changes: 3 additions & 2 deletions src/platforms/dotnet/guides/aspnetcore/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ open Microsoft.AspNetCore.Hosting
let main args =
let builder = WebApplication.CreateBuilder(args)
builder.WebHost.UseSentry() // you'll need to include Microsoft.AspNetCore.Hosting.

let app = builder.Build()
app.UseSentryTracing()

Expand Down Expand Up @@ -239,6 +239,8 @@ member this.ConfigureServices(services: IServiceCollection) =
services.AddScoped<ISentryEventExceptionProcessor, MyExceptionProcessor>() |> ignore
```

<PlatformContent includePath="getting-started-confignote" />

## Options and Initialization

As previously mentioned, this package is a wrapper around [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) and [Sentry](/platforms/dotnet/). Please refer to the documentation of these packages to get the options that are defined at those levels.
Expand Down Expand Up @@ -303,4 +305,3 @@ Sentry.init({
```

The [AspNetCore.Mvc sample](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Mvc) uses this approach.

2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/aws-lambda/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu
}
```

<PlatformContent includePath="getting-started-confignote" />

Check out the [Sentry ASP.NET Core](/platforms/dotnet/guides/aspnetcore/) documentation for the complete set of options.

## Samples
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/google-cloud-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public class UserFactoryStartup : FunctionsStartup
}
```

<PlatformContent includePath="getting-started-confignote" />

## Options & Initialization

As previously mentioned, this package is a wrapper around [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/), [Sentry.AspNetCore](/platforms/dotnet/guides/aspnetcore/) and [Sentry](/platforms/dotnet/). Please refer to the documentation of these packages to get the options that are defined at those levels.
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/maui/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public static MauiApp CreateMauiApp()
}
```

<PlatformContent includePath="getting-started-confignote" />

## Options

As previously mentioned, this package is a wrapper around [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) and [Sentry](/platforms/dotnet/). Please refer to the documentation of these packages to get the options that are defined at those levels.
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/uwp/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ sealed partial class App : Application
}
}
```

<PlatformContent includePath="getting-started-confignote" />
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/winforms/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Sentry's .NET SDK works with WinForms applications through the [Sentry NuGet pac

After adding the NuGet package, the SDK should be initialized in the program's main entry point, before launching any forms or performing signifanct work. The options for initialization vary by language.

<PlatformContent includePath="getting-started-confignote" />

### C# Initialization

A C# Windows Forms application will have a `Program.cs` file. You should initialize Sentry in this file.
Expand Down
4 changes: 3 additions & 1 deletion src/platforms/dotnet/guides/wpf/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class App : Application
{
public App()
{
SentrySdk.Init(o =>
SentrySdk.Init(o =>
{
// Tells which project in Sentry to send events to:
o.Dsn = "___PUBLIC_DSN___";
Expand Down Expand Up @@ -55,3 +55,5 @@ public partial class App : Application
}
}
```

<PlatformContent includePath="getting-started-confignote" />
2 changes: 2 additions & 0 deletions src/platforms/dotnet/guides/xamarin/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ After you’ve completed setting up a project in Sentry, Sentry will give you a

<PlatformContent includePath="getting-started-config" />

<PlatformContent includePath="getting-started-confignote" />

## Verify

Great! Now that you’ve completed setting up the SDK, maybe you want to quickly test out how Sentry works. Start by capturing an exception:
Expand Down