Skip to content

How to target specific SDK version when using dotnet or CodeDom engines? #423

@nxn308

Description

@nxn308

I am currently using C#-script as a part of infrastructure and would like to tightly control what version of the .NET SDK is used to compile scripts. The C#-script version I am using runs under the .NET 8 runtime, and thus I expected it to always use the .NET 8 SDK to compile scripts. This, however, is not the case. If the .NET 9 SDK is installed, then that SDK is used instead.

This is a problem because some scripts can be compiled using the .NET 8 SDK but not with the .NET 9 SDK, so I want a very specific version to be used.

I cannot seem to find a way to do this. To my understanding, .NET usually lets you specify an SDK version using global.json next to your project. I also noticed that C#-script creates an entire VS solution and .csproj file in a temp directory to compile these scripts.

Is there ANY way to set the SDK version to use on the command line? Perhaps something that would create a global.json file in that temp directory where the script gets compiled?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions