Build from Source
Instructions for building MathScript from source code.
Prerequisites
- .NET SDK 9.0 or later
- Git
- A C# compatible IDE (Visual Studio, Visual Studio Code, or JetBrains Rider) or any code editor with command line tools
Cloning the Repository
Clone the MathScript repository:
git clone https://github.com/MathScript-Lang/MathScript
cd MathScript
Building
With the dotnet CLI
Navigate to the project's folder and build:
dotnet build
You may need to build twice for your first build to generate and use BuildInfo.cs.
To create a release build:
dotnet build -c Release
With Visual Studio
- Open Visual Studio
- Select "Open a project or solution"
- Navigate to and open
MathScript.slnx - Build the solution with
Ctrl +Shift +B or via Build > Build Solution
With Visual Studio Code
- Open the MathScript folder in Visual Studio Code
- Install the C# extensions if not already installed
- Run the build task:
- Press
Ctrl +Shift +B - Or use the terminal:
dotnet build
- Press
Running
After building, you can run MathScript in two ways:
Interactive REPL Mode
Run without arguments to start an interactive shell:
dotnet run
Type your MathScript code and press Enter to execute it. Type exit or press
Execute or Compile a Program
Execute a .mscr file directly:
dotnet run -- hello.mscr
Compile a .mscr file to an executable:
dotnet run -- -o output hello.mscr
And generally:
dotnet run -- [arguments]
You can also use the built executable directly from the build output directory:
./bin/Debug/net9.0/mathscript hello.mscr
./bin/Debug/net9.0/mathscript -o output hello.mscr
For release builds:
./bin/Release/net9.0/mathscript hello.mscr
Troubleshooting
Build fails with missing dependencies
- Ensure .NET SDK 9.0+ is installed:
dotnet --version - Restore NuGet packages:
dotnet restore
BuildInfo.cs not found on first build
- This is a known issue with the build system checking for the
BuildInfoclass before the file generation task runs. - Simply build again and it will succeed, as the file will already exist.