Skip to content

docs(dotnet): Document MSBuild Sentry CLI usage when building with Docker#17589

Open
jamescrosswell wants to merge 7 commits into
masterfrom
msbuild-docker-2420
Open

docs(dotnet): Document MSBuild Sentry CLI usage when building with Docker#17589
jamescrosswell wants to merge 7 commits into
masterfrom
msbuild-docker-2420

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented May 4, 2026

Copy link
Copy Markdown
Collaborator

DESCRIBE YOUR PR

Adds a new "Building with Docker" section to the .NET MSBuild setup page, addressing the two Docker-specific gotchas documented in getsentry/sentry-dotnet#2420:

  • Auth token — how to pass SENTRY_AUTH_TOKEN securely as a docker build --build-arg, promote it to an ENV var in the build stage, and why both ARG and ENV are required.
  • Multi-stage Dockerfiles — how to disable Sentry CLI in the dotnet publish stage with -p:UseSentryCLI=false to avoid failures when project source isn't present in the publish context.

Also adds a brief pointer to this new section from the existing CI/CD authentication bullet, so users reading about server builds are directed to the Docker guidance.

A complete multi-stage Dockerfile example (ASP.NET Core 8.0) is included.

Fixes getsentry/sentry-dotnet#2420

IS YOUR CHANGE URGENT?

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

@vercel

vercel Bot commented May 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment Jul 9, 2026 1:07pm
sentry-docs Ready Ready Preview, Comment Jul 9, 2026 1:07pm

Request Review

@codeowner-assignment codeowner-assignment Bot requested a review from a team May 4, 2026 03:39
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
Document the two Docker-specific gotchas when using Sentry CLI via
MSBuild: passing SENTRY_AUTH_TOKEN as a build arg and promoting it
to an ENV var, and using -p:UseSentryCLI=false in the publish stage
of a multi-stage Dockerfile to avoid errors when project source is
not present.

Includes a complete multi-stage Dockerfile example for ASP.NET Core.

Refs getsentry/sentry-dotnet#2420
Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
jamescrosswell and others added 2 commits July 9, 2026 11:06
Correct the explanation for why Sentry CLI must not re-run during the
publish stage: the token is scoped to the build stage's RUN, so a
publish-triggered rebuild would fail rather than double-upload.

Switch the publish step to --no-build --no-restore so it reuses the
build stage's output instead of recompiling, and drop the custom
-o /app/build so publish can locate that output. Bump the example
images to .NET 10 (current LTS).

Co-Authored-By: Claude <noreply@anthropic.com>
@jamescrosswell jamescrosswell requested a review from Flash0ver July 8, 2026 23:17

@Flash0ver Flash0ver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤘


```dockerfile
RUN dotnet publish "MyWebApp.csproj" -c Release -o /app/publish -p:UseAppHost=false -p:UseSentryCLI=false
RUN dotnet publish "MyWebApp.csproj" -c Release -o /app/publish --no-build --no-restore -p:UseAppHost=false -p:UseSentryCLI=false

@Flash0ver Flash0ver Jul 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: technically, --no-build also implicitly sets the --no-restore flag, but I personally also prefer explicitness

Comment thread docs/platforms/dotnet/common/configuration/msbuild.mdx Outdated
@codeowner-assignment codeowner-assignment Bot requested a review from a team July 9, 2026 12:58
In your Dockerfile, add a [syntax directive](https://docs.docker.com/reference/dockerfile/#syntax) at the top, then mount the secret for the `RUN` instruction that performs the build:

```dockerfile
# syntax=docker/dockerfile:1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The documentation overstates that # syntax=docker/dockerfile:1 "ensures" support for the env= option. This is not guaranteed for users with stale, cached Docker frontend images.
Severity: LOW

Suggested Fix

To improve accuracy, pin the Dockerfile syntax to a specific version that supports the env= feature, such as # syntax=docker/dockerfile:1.10. Alternatively, rephrase the documentation to clarify that docker/dockerfile:1 points to the latest stable version 1 syntax and that modern Docker installations are required for the env= feature to be available.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: docs/platforms/dotnet/common/configuration/msbuild.mdx#L283

Potential issue: The documentation states that using the `# syntax=docker/dockerfile:1`
directive "ensures" the Docker frontend supports the `env=` option for secrets. However,
`docker/dockerfile:1` is a floating tag. A user with a stale, cached version of this
image from before v1.10 (which introduced `env=`) could experience a build failure.
While this scenario is unlikely in practice, as most users will pull a recent version of
the image, the documentation's claim is technically inaccurate and could be misleading
in rare edge cases.

Also affects:

  • docs/platforms/dotnet/common/configuration/msbuild.mdx:312~312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document Sentry CLI MSBuild parameters when building in a docker container

2 participants