Skip to content

Conversation

Flash0ver
Copy link
Member

@Flash0ver Flash0ver commented Jul 28, 2025

Summary

The Sentry .NET SDK uses a global.json file to pin a specific version of the .NET SDK and .NET Workloads to ensure reproducible builds.
When pushing the Sentry NuGet packages and Symbol packages, we can use any version of the .NET SDK,
as long as we ensure that the actual dotnet build, dotnet test, and creating the packages via dotnet pack run with the pinned version of the .NET SDK.

In a previous PR, see #601,
we applied spawnOptions to the invocation of dotnet nuget push via spawnProcess,
with which we set the Working Directory outside of the sentry-dotnet repository,
so that the global.json does not get picked up / enforced.

However,
we forgot to apply the same spawnOptions to the other invocations of dotnet commands.

This manifests in failure when invoking dotnet --version:

...
[info] [[target/nuget]] .NET Version:
Error:  Process "dotnet" errored with code 145
...
dotnet: 8.0.412 [/usr/share/dotnet/sdk]
dotnet: 9.0.303 [/usr/share/dotnet/sdk]
...
dotnet: Requested SDK version: 9.0.301
dotnet: global.json file: global.json
...
Publish using Craft
[info] [[target/nuget]] .NET Version:
Error:  Process "dotnet" errored with code 145

STDOUT: dotnet: 8.0.412 [/usr/share/dotnet/sdk]
dotnet: 9.0.303 [/usr/share/dotnet/sdk]
dotnet: 


STDERR:dotnet: The command could not be loaded, possibly because:
dotnet:   * You intended to execute a .NET application:
dotnet:       The application '--version' does not exist.
dotnet:   * You intended to execute a .NET SDK command:
dotnet:       A compatible .NET SDK was not found.
dotnet: 
dotnet: Requested SDK version: 9.0.301
dotnet: global.json file: /github/workspace/__repo__/global.json
dotnet: 
dotnet: Installed SDKs:
dotnet: 
dotnet: Install the [9.0.301] .NET SDK or update [/github/workspace/__repo__/global.json] to match an installed SDK.
dotnet: 
dotnet: Learn about SDK resolution:
dotnet: https://aka.ms/dotnet/sdk-not-found
dotnet: 

  
  STDOUT: dotnet: 8.0.412 [/usr/share/dotnet/sdk]
  dotnet: 9.0.303 [/usr/share/dotnet/sdk]
  dotnet:
  
  
  STDERR:dotnet: The command could not be loaded, possibly because:
  dotnet:   * You intended to execute a .NET application:
  dotnet:       The application '--version' does not exist.
  dotnet:   * You intended to execute a .NET SDK command:
  dotnet:       A compatible .NET SDK was not found.
  dotnet:
  dotnet: Requested SDK version: 9.0.301
  dotnet: global.json file: global.json
  dotnet:
  dotnet: Installed SDKs:
  dotnet:
  dotnet: Install the [9.0.301] .NET SDK or update [global.json] to match an installed SDK.
  dotnet:
  dotnet: Learn about SDK resolution:
  dotnet: https://aka.ms/dotnet/sdk-not-found
  dotnet:
  
  at Bqe (/usr/local/bin/craft:357:15452)
  at p (/usr/local/bin/craft:361:467)
  at ChildProcess.<anonymous> (/usr/local/bin/craft:361:761)
  at ChildProcess.emit (node:events:518:28)
  at ChildProcess.emit (node:domain:489:12)
  at ChildProcess._handle.onexit (node:internal/child_process:293:12)

Changes

Applying the previously added spawnOptions to the invocations of all dotnet commands,
not just dotnet nuget push.

See also

@Flash0ver Flash0ver self-assigned this Jul 28, 2025
@Flash0ver Flash0ver added the bug Something isn't working label Jul 28, 2025
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks Stefan.

* Spawn options to run outside the repository folder to avoid global.json constraints
* (we don't need specific dotnet/workload versions just to upload to nuget)
*/
const SPAWN_OPTIONS = { cwd: '/' };
Copy link
Member Author

Choose a reason for hiding this comment

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

question: Is this the right way to do it?

Alternative:
As private readonly field on class NugetTarget.

Copy link
Contributor

@asottile-sentry asottile-sentry left a comment

Choose a reason for hiding this comment

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

@bruno-garcia
Copy link
Member

Thanks @asottile-sentry

@bruno-garcia bruno-garcia merged commit 8d788a8 into master Jul 28, 2025
13 checks passed
@bruno-garcia bruno-garcia deleted the fix/any-dotnet-version branch July 28, 2025 20:11
BYK pushed a commit that referenced this pull request Oct 1, 2025
* fix: apply spawnOptions to other dotnet commands

* ref: more precise name and comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants