Skip to content

Commit 02117bb

Browse files
Improve .NET MSBuild advice (#6425)
1 parent 846c267 commit 02117bb

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

src/platforms/dotnet/common/configuration/msbuild.mdx

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,44 @@ If _both_ MSBuild properties and environment variables are provided, the MSBuild
7676

7777
### Setting MSBuild Properties
7878

79-
MSBuild properties can be set in any MSBuild project file, such as those that are created by Visual Studio or the `dotnet` CLI
80-
(`YourProject.csproj`, `YourProject.vbproj`, `Directory.Build.props`, etc.).
79+
Sentry's MSBuild properties can be set in any MSBuild project file, such as those that are created by Visual Studio
80+
or the `dotnet` CLI (`YourProject.csproj`, `YourProject.vbproj`, `Directory.Build.props`, etc.).
81+
We recommend using a dedicated property group, so that you can control when these features are used.
8182

82-
You can add Sentry's MSBuild properties to any property group. For example:
83+
In the following example, `Condition="'$(Configuration)' == 'Release'"` ensures that these features are enabled
84+
only for release builds. This is the usual recommendation, because sending data to Sentry during debug builds
85+
can slow down your development workflow.
86+
87+
Alternatively, you could control this using any MSBuild property or environment variable you like. For example,
88+
if you only want these features enabled in a GitHub Actions CI workflow, you could use `Condition="'$(GITHUB_ACTIONS)' == 'true'"`.
8389

8490
```xml
85-
<PropertyGroup>
91+
<!-- We recommend only using these features for release builds. -->
92+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
93+
94+
<!-- Configure Sentry org and project -->
8695
<SentryOrg>___ORG_SLUG___</SentryOrg>
8796
<SentryProject>___PROJECT_SLUG___</SentryProject>
97+
98+
<!--
99+
Each of the below features are opt-in.
100+
Enable the features you wish to use.
101+
-->
102+
103+
<!-- Sends symbols to Sentry, enabling symbolication of stack traces. -->
104+
<SentryUploadSymbols>true</SentryUploadSymbols>
105+
106+
<!-- Sends sources to Sentry, enabling display of source context. -->
88107
<SentryUploadSources>true</SentryUploadSources>
108+
89109
</PropertyGroup>
110+
90111
```
91112

92113
Alternatively, they could be passed as parameters when building your project. For example:
93114

94115
```shell
95-
dotnet build YourProject.csproj -c Release -p:SentryOrg=___ORG_SLUG___ -p:SentryProject=___PROJECT_SLUG___ -p:SentryUploadSources=true
116+
dotnet build YourProject.csproj -c Release -p:SentryOrg=___ORG_SLUG___ -p:SentryProject=___PROJECT_SLUG___ -p:SentryUploadSymbols=true -p:SentryUploadSources=true
96117
```
97118

98119
<Alert title="Tip">
@@ -131,16 +152,20 @@ There are a few additional properties available to control the Sentry CLI:
131152

132153
<ConfigKey name="SentryUploadSymbols">
133154

134-
Controls uploading symbols to Sentry during the build. Defaults to `true` for builds in release configuration,
135-
or `false` otherwise.
155+
Controls uploading symbols to Sentry during the build. Defaults to `false` (disabled).
156+
157+
Set this property to `true` to opt-in to sending symbols to Sentry as [debug information files](../../data-management/debug-files/),
158+
which are used to perform symbolication of stack traces. This will allow you to view file names and line numbers within
159+
a stack trace, instead of just a function name.
136160

137161
</ConfigKey>
138162

139163
<ConfigKey name="SentryUploadSources">
140164

141-
Controls whether source code files are uploaded to Sentry during the build. Defaults to `false`.
165+
Controls whether source code files are uploaded to Sentry during the build. Defaults to `false` (disabled).
142166

143-
Set this property to `true` to opt-in to enable [source context](../../data-management/debug-files/source-context/) when viewing stack traces.
167+
Set this property to `true` to opt-in to sending source code to Sentry.
168+
This enables the display of [source context](../../data-management/debug-files/source-context/) when viewing stack traces.
144169

145170
<Note>
146171

@@ -153,8 +178,9 @@ you do not need to upload them to Sentry separately. In other words, use *eithe
153178

154179
<ConfigKey name="UseSentryCLI">
155180

156-
Controls whether the Sentry CLI is enabled in your build. `true` by default.
157-
Set to `false` to disable the Sentry CLI completely, ignoring all other properties.
181+
Controls whether the Sentry CLI is enabled in your build.
182+
Defaults to `true` if any of the individual features are enabled.
183+
Set to `false` to disable the Sentry CLI completely, ignoring the settings of each feature.
158184

159185
</ConfigKey>
160186

0 commit comments

Comments
 (0)