Skip to main content

Installation

SolarSharp is distributed as a NuGet package and can be easily added to any .NET project. This guide covers installation for various project types and package managers.

NuGet Package

The main SolarSharp package is:

SolarSharp.Interpreter

The core SolarSharp interpreter library

Installation Methods

Choose your preferred package manager:
The .NET CLI is the recommended way to add packages in modern .NET projects:
dotnet add package SolarSharp.Interpreter
To install a specific version:
dotnet add package SolarSharp.Interpreter --version 2.0.0

Platform Requirements

SolarSharp supports multiple .NET target frameworks:

.NET Standard 2.0

Compatible with .NET Framework 4.6.1+

.NET Standard 2.1

Optimized for modern .NET features

.NET 9.0+

Latest .NET runtime support

Compatible Platforms

SolarSharp works on a wide range of platforms:
  • .NET Core 2.0+ and .NET 5.0+
  • .NET Framework 4.6.1+
  • Unity3D (including IL2CPP)
  • Xamarin.iOS and Xamarin.Android
  • Mono
  • UWP (Universal Windows Platform)
  • Ahead-of-time (AOT) compilation platforms like iOS
No external dependencies are required. SolarSharp is self-contained and includes everything needed to run Lua scripts.

Dependencies

SolarSharp has minimal dependencies that are automatically installed:
  • Microsoft.CodeAnalysis.CSharp (4.14.0) - For dynamic code generation
  • System.Runtime.CompilerServices.Unsafe (6.0.0) - For performance optimizations
  • Microsoft.Bcl.HashCode (6.0.0) - For consistent hashing across platforms
  • Microsoft.Bcl.Memory (9.0.7) - For memory management utilities
For .NET Standard 2.0 and 2.1 targets:
  • Microsoft.CSharp (4.7.0) - For dynamic language runtime support

Unity3D Installation

For Unity projects, you have several options:
1

Option 1: Unity Package Manager (Recommended)

Add the following to your manifest.json in the Packages folder:
{
  "dependencies": {
    "com.solarsharp.interpreter": "2.0.0"
  }
}
2

Option 2: Download DLL

  1. Download the latest release from NuGet
  2. Extract the .nupkg file (rename to .zip if needed)
  3. Copy the DLL from lib/netstandard2.0/ to your Unity Assets/Plugins folder
3

Option 3: NuGet for Unity

If you have NuGetForUnity installed:
  1. Open the NuGet window (Window > NuGet Package Manager)
  2. Search for “SolarSharp.Interpreter”
  3. Click Install
When using IL2CPP in Unity, ensure you configure the link.xml file to prevent code stripping. See the Unity-specific documentation for details.

Verify Installation

After installation, verify that SolarSharp is working correctly:
using System;
using SolarSharp.Interpreter;
using SolarSharp.Interpreter.DataTypes;

class Program
{
    static void Main()
    {
        // Create a simple script
        LuaValue result = Script.RunString("return 'SolarSharp ' .. '2.0.0'");
        
        Console.WriteLine(result.String);
        // Output: SolarSharp 2.0.0
        
        Console.WriteLine("Installation successful!");
    }
}
If this code compiles and runs without errors, SolarSharp is installed correctly.

Troubleshooting

Ensure you have an internet connection and that your NuGet sources are configured correctly:
dotnet nuget list source
The nuget.org source should be present. If not, add it:
dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
Make sure you have the correct using directive:
using SolarSharp.Interpreter;
using SolarSharp.Interpreter.DataTypes;
And verify the package is properly restored:
dotnet restore
If you encounter errors in Unity:
  1. Ensure you’re using a compatible Unity version (.NET Standard 2.0+)
  2. Check that the DLL is placed in the correct folder (Assets/Plugins)
  3. Verify the DLL’s import settings in the Unity Inspector
  4. For IL2CPP, ensure you have a proper link.xml configuration
If you have version conflicts with dependencies, you can force a specific version in your .csproj:
<ItemGroup>
  <PackageReference Include="SolarSharp.Interpreter" Version="2.0.0" />
  <PackageReference Include="Microsoft.Bcl.Memory" Version="9.0.7" />
</ItemGroup>

Upgrading from MoonSharp

If you’re migrating from MoonSharp to SolarSharp:
1

Remove MoonSharp

Uninstall the MoonSharp package:
dotnet remove package MoonSharp
2

Install SolarSharp

Add the SolarSharp package:
dotnet add package SolarSharp.Interpreter
3

Update Namespaces

Replace MoonSharp namespaces with SolarSharp:
// Old
using MoonSharp.Interpreter;

// New
using SolarSharp.Interpreter;
4

Test Your Code

Most MoonSharp code should work without changes, but test thoroughly to ensure compatibility.
SolarSharp maintains API compatibility with MoonSharp for most common use cases, making migration straightforward.

Next Steps

Now that you have SolarSharp installed:

Quickstart Guide

Run your first Lua script in under 5 minutes

Core Concepts

Learn the fundamentals of SolarSharp

API Reference

Explore the complete API documentation

Examples

Browse practical code examples

Getting Help

If you encounter any issues during installation:
SolarSharp version 2.0.0.0 supports Lua 5.2. Check the version constant in the Script class for the exact versions.

Build docs developers (and LLMs) love