docs(dotnet): Document MSBuild Sentry CLI usage when building with Docker#17589
docs(dotnet): Document MSBuild Sentry CLI usage when building with Docker#17589jamescrosswell wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
2af00b4 to
76d7457
Compare
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>
fead07e to
033b6c3
Compare
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>
|
|
||
| ```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 |
There was a problem hiding this comment.
note: technically, --no-build also implicitly sets the --no-restore flag, but I personally also prefer explicitness
| 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 |
There was a problem hiding this comment.
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
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:
SENTRY_AUTH_TOKENsecurely as adocker build --build-arg, promote it to anENVvar in the build stage, and why bothARGandENVare required.dotnet publishstage with-p:UseSentryCLI=falseto 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?
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST