Our .NET support makes it easy for users to hit failures that it'd be nice if were able to handle better.
One common situation happens when a new version of .NET is released. .NET 8 was recently released for example, but our templates are still written to target .NET 6. When I run pulumi new and pulumi up with .NET 6 and 8 installed, things go fine, because I have .NET 6. But when I run those commands with only .NET 8, new succeeds, but up fails:
➜ dotnet --list-sdks
8.0.302 [/usr/local/share/dotnet/sdk]
➜ dotnet --list-runtimes
Microsoft.AspNetCore.App 8.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
➜ pulumi new csharp --yes
...
Your new project is ready to go! ✨
To perform an initial deployment, run `pulumi up`
➜ pulumi up
...
Diagnostics:
pulumi:pulumi:Stack (tmp.EDWma9Ydg2-dev):
You must install or update .NET to run this application.
App: /private/var/folders/cw/39tll6xs0hsdj1hvh85m0gn00000gn/T/tmp.EDWma9Ydg2/bin/Debug/net6.0/tmp.EDWma9Ydg2
Architecture: arm64
Framework: 'Microsoft.NETCore.App', version '6.0.0' (arm64)
.NET location: /usr/local/share/dotnet
The following frameworks were found:
8.0.6 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=arm64&rid=osx-arm64&os=osx.14
error: an unhandled error occurred: Program exited with non-zero exit code: 150
This is understandable because I don't have .NET 6 installed, and the .NET project file specifies <TargetFramework>net6.0</TargetFramework> explicitly. However when I update the C# project template to support both .NET 6 and 8 (using <TargetFrameworks>net6.0;net8.0</TargetFrameworks>), I get a different error on pulumi up:
Diagnostics:
pulumi:pulumi:Stack (tmp.EDWma9Ydg2-dev):
Unable to run your project
Your project targets multiple frameworks. Specify which framework to run using '--framework'.
error: an unhandled error occurred: Program exited with non-zero exit code: 1
To prevent users from hitting this error when a new version .NET is released, and to allow us to test against all of the frameworks we purportedly support (which will ~always be multiple), we should consider running Pulumi in a way lets us determine whether any of the user's installed frameworks satisfy the TargetFramework(s) requirement, and if so, target that framework.
Our .NET support makes it easy for users to hit failures that it'd be nice if were able to handle better.
One common situation happens when a new version of .NET is released. .NET 8 was recently released for example, but our templates are still written to target .NET 6. When I run
pulumi new
andpulumi up
with .NET 6 and 8 installed, things go fine, because I have .NET 6. But when I run those commands with only .NET 8,new
succeeds, butup
fails:This is understandable because I don't have .NET 6 installed, and the .NET project file specifies
<TargetFramework>net6.0</TargetFramework>
explicitly. However when I update the C# project template to support both .NET 6 and 8 (using<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
), I get a different error onpulumi up
:To prevent users from hitting this error when a new version .NET is released, and to allow us to test against all of the frameworks we purportedly support (which will ~always be multiple), we should consider running Pulumi in a way lets us determine whether any of the user's installed frameworks satisfy the
TargetFramework(s)
requirement, and if so, target that framework.See the conversation here for additional context/discussion.