The Half-Life Unified SDK uses dotnet-script to run scripts written in C#. These scripts form part of the SDK toolchain and handle tasks such as asset processing and content pipeline automation. This page covers how to install the .NET SDK and dotnet-script, how to run scripts from the command line, and how to configure Visual Studio Code for a full editing and debugging experience — including the PowerShell scripts also used by the SDK.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/twhl-community/halflife-unified-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Install the .NET SDK
Before installing dotnet-script you need the .NET SDK. .NET 6.0 or newer is required to run dotnet-script and the packages used by the SDK’s existing scripts. Follow the official installation instructions for your platform from the .NET download page. For SDK-specific guidance see the Setting up the .NET SDK page in this documentation.Open a new terminal or command prompt after installation completes. The
dotnet executable is added to your PATH during installation, but any terminal that was already open will not have the updated PATH and will report dotnet as not found.Install dotnet-script
With the .NET SDK in place, install dotnet-script as a global tool. The full installation instructions are available in the dotnet-script repository. The essential command is:Running scripts from the command line
To run a C# script with dotnet-script, open a terminal and use the following command:Passing command-line parameters
Append parameters directly after the script filename:-- to separate the script’s arguments from dotnet-script’s arguments:
Command-line scripts in the SDK
Command-line scripts in the SDK work like standard .NET tools. See the .NET Tools page for more information on how they are structured and invoked.Setting up Visual Studio Code
Visual Studio Code can be used to edit, run, and debug both the C# scripts used by dotnet-script and the PowerShell scripts included in the SDK. The sections below cover each setup.C# scripts with dotnet-script
Install the C# extension
Install the C# extension for VS Code from the Extensions marketplace.
Configure the extension to use the latest .NET version
To ensure the extension correctly understands the syntax used in SDK scripts, configure OmniSharp to use the latest .NET build. Instructions for this setting are available in the omnisharp-vscode repository.
Generate a launch.json file
When editing scripts in VS Code it is recommended to use a
launch.json file. dotnet-script can scaffold one for you with the init command — see the dotnet-script scaffolding documentation for details.On Windows, the generated This path will break on other machines or after updating dotnet-script. Replace the hardcoded path with the global tool location using environment variables. Use the globaltool.launch.json.template from the dotnet-script repository as a starting point.
launch.json currently references an absolute path to the dotnet-script DLL, for example:PowerShell scripts with VS Code
The SDK also includes PowerShell scripts. Follow these steps to configure VS Code for editing and debugging them.Install Visual Studio Code
If you have not done so already, download and install Visual Studio Code from https://code.visualstudio.com/.
Install the PowerShell extension
Install the PowerShell extension for VS Code. This adds syntax highlighting, IntelliSense, and debugging support for
.ps1 files.Configure the PowerShell extension settings
Open VS Code and navigate to File → Preferences → Settings. In the Settings panel, go to Extensions → PowerShell Configuration and apply the following two settings:
- Debugging: Create Temporary Integrated Console — Enable this setting. It makes VS Code create a fresh PowerShell instance every time you run a script, which prevents state from previous executions from affecting the current run.
- Cwd — Set this to
${fileDirname}. This sets the working directory for each script to the folder that contains the script file itself. The SDK’s PowerShell scripts rely on their location relative to the mod directory, so this setting is essential for them to work correctly.
Open the scripts directory
In VS Code, go to File → Open Folder… and open the
scripts directory inside your mod directory. All of the SDK’s PowerShell scripts will be available in the Explorer panel for editing.Create a launch configuration
Open the Run and Debug tab from the left-hand activity bar. Click create a launch.json file and select Launch Current File from the drop-down. VS Code will create a Add an
launch.json file that looks like this:args key to pass -Verbose to every script run, which enables additional output useful for debugging:Run scripts
With a PowerShell script open, switch to the Run and Debug tab and click the green triangle next to PowerShell: Launch Current File, or press F5. The script will execute in a new integrated terminal with verbose output enabled.For more information on running and debugging PowerShell scripts in VS Code, consult the official VS Code documentation and Microsoft’s PowerShell documentation.