Run a .net6 project with combined sdk

I have a .net6 project, and running it with .net 6 sdk works fine:

nix-shell -p dotnet-sdk_6 --run "dotnet run"

Running it with combining .net6 and .net8 sdks builds correctly, but at run gives the following error:

❯ nix-shell -p 'with pkgs.dotnetCorePackages; combinePackages [sdk_6_0  sdk_8_0]' --run "dotnet run"
Unhandled exception: System.ComponentModel.Win32Exception (2): An error  occurred trying to start process  '/home/dpd-/prj/Test/bin/Debug/net6.0/Test'
with working directory  '/home/dpd-/prj/Test'. No such file or  directory
at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo  startInfo, String resolvedFilename, String[] argv, String[] envp, String  cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[]  groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd,  Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at Microsoft.DotNet.Cli.Utils.Command.Execute(Action`1  processStarted)
at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
at  System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult  parseResult)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan  startupTime, ITelemetry telemetryClient)

Running a .net8 project with combined sdks works fine.

A way to force using the .net6 sdk is to write into global.json (note major and not latestMajor):

  "sdk": {
    "version": "6.0.0",
    "rollForward": "major"

But I cannot do this in shared projects and moreover this prevents:

  • having mixed sdk projects in the same solution
  • use c# 12 in .net6 projects

❯ nix-shell -p 'with pkgs.dotnetCorePackages; combinePackages [sdk_6_0  sdk_8_0]' --run "dotnet sdk check"
Version      Status                     
6.0.417      Patch 6.0.418 is available.
8.0.100      Patch 8.0.101 is available.

Try out the newest .NET SDK features with .NET 8.0.101.

.NET Runtimes:
Name                          Version      Status                    
Microsoft.AspNetCore.App      6.0.25       Patch 6.0.26 is available.
Microsoft.NETCore.App         6.0.25       Patch 6.0.26 is available.
Microsoft.AspNetCore.App      8.0.0        Patch 8.0.1 is available. 
Microsoft.NETCore.App         8.0.0        Patch 8.0.1 is available. 

The latest versions of .NET can be installed from For more information about .NET lifecycles, see

❯ nix-shell -p 'with pkgs.dotnetCorePackages; combinePackages [sdk_6_0  sdk_8_0]' --run "dotnet --info"
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.6c33ef20
Runtime Environment:
 OS Name:     nixos
 OS Version:  23.11
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /nix/store/z9z1d5lz5gf84h252q6m541jizyygi35-dotnet-sdk-8.0.100/sdk/8.0.100/
.NET workloads installed:
 Workload version: 8.0.100-manifests.6c33ef20
There are no installed workloads to display.

  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71
.NET SDKs installed:
  6.0.417 [/nix/store/2935l4sngzxccv59lrb2fnbp33wjpqja-dotnet-core-combined/sdk]
  8.0.100 [/nix/store/2935l4sngzxccv59lrb2fnbp33wjpqja-dotnet-core-combined/sdk]
.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.25 [/nix/store/2935l4sngzxccv59lrb2fnbp33wjpqja-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [/nix/store/2935l4sngzxccv59lrb2fnbp33wjpqja-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.25 [/nix/store/2935l4sngzxccv59lrb2fnbp33wjpqja-dotnet-core-combined/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [/nix/store/2935l4sngzxccv59lrb2fnbp33wjpqja-dotnet-core-combined/shared/Microsoft.NETCore.App]
Other architectures found:
Environment variables:
  DOTNET_ROOT       [/nix/store/px7xz91qvrvs95grisn92h484rrk1f5x-dotnet-core-combined]
global.json file:
  Not found
Learn more:
Download .NET: