Resolution
After upgrading an Octopus Tentacle, the target machine may lose access to the .NET SDK or dotnet-script tools. This causes deployment steps that rely on script execution or NuGet package restoration to fail. To resolve this, verify the .NET SDK installation on the target machine and reinstall or repair it if missing. Restart the Tentacle service after making environment changes.
Symptom
Deployments or script steps fail with errors similar to:
Verbose | dotnet-script was not found, executing the bundled version
Error | Unable to restore packages from '\...\<.net version>\script.csproj'
Error | The command could not be loaded, possibly because:
Error | * You intended to execute a .NET application:
Error | The application 'tool' does not exist.
Error | * You intended to execute a .NET SDK command:
Error | No .NET SDKs were found.
Scope: when this is the right article
This article applies when:
- Deployments fail immediately after upgrading the Octopus Tentacle on a target machine.
- Tasks involving script execution, PowerShell scripts calling
dotnet, or NuGet package restoration fail. - The
dotnetcommand is not recognized by the target environment.
Cause
The Tentacle upgrade process can sometimes overwrite or clear environment variables, or the target machine may lack the required .NET SDK version needed by Calamari and dotnet-script. When the Tentacle service runs under a restricted context (e.g., NT AUTHORITY\SYSTEM), it may not inherit updated PATH variables or SDK installations until the service is restarted or the SDK is explicitly installed/repaired on the host OS.
Diagnosis and fix
-
Verify the environment: Log into the target machine and run the following commands to check the
.NETinstallation and NuGet configuration:
dotnet --info
dotnet --list-runtimes
dotnet --list-sdks
where.exe dotnet
echo $env:PATH
dotnet nuget list source
-
Install or repair the .NET SDK: If
dotnet --infofails or shows missing SDKs, install the required .NET SDK directly on the target machine. Ensure the version matches what your deployment scripts require. - Restart the Tentacle service: After installing or modifying the SDK, restart the Octopus Tentacle service to ensure it picks up the updated environment variables.
-
Re-run the deployment: Attempt the failed deployment again. If the issue persists, verify that the deployment is executing under the correct user context (typically
NT AUTHORITY\SYSTEMif the Tentacle service runs as such). This will be written to the task log and look similar to:
Verbose | CurrentUser: NT AUTHORITY\SYSTEM
Verify
Confirm that dotnet --info returns successfully on the target machine and that deployments complete without package restoration errors. You can also run a test script in a Run a Script step, or use the Script Console to ensure dotnet-script is recognized.