Getting started with Haxe for C#
haxelib install hxcs
project/ ├── src/ │ └── Main.hx │ ├── bin/ │ └── cs/ │ └── build.hxml2. Add the following code into the
src/Main.hx file:class Main { static function main() { Sys.println("Haxe is great!"); } }3. Add the following build configuration into the
build.hxml file:-cp src -main Main -cs bin/csThe configuration above specifies that your source code is stored in
src/, that your main Haxe file is src/Main.hx, and that you want Haxe to output the C# source code into bin/cs/. After code generation, Haxe will automatically detect the installed C#/Mono compiler and use it to compile your project into bin/cs/bin/.
1. If you want to use Visual Studio to compile and debug your project, you can disable the automatic compilation and simply use Haxe to generate the .cs files.
To do this, add -D no-compilation -D real-position to the end of your .hxml file.
2. Build your Haxe project by running haxe build.hxml in a console in your project directory.
3. Install Visual Studio Community Edition.
4. Open the bin/cs/Main.csproj C# project in Visual Studio. If you are prompted about the .NET Framework version being unsupported, select the option to "Change the target to .NET Framework...".
5. Open the .cs file that corresponds to the .hx file that you want to debug, for example Main.cs for the Main class.
6. Add breakpoints into your C# code as you wish and Start Debugging your project (press F5).
7. Visual Studio should compile the project and enter debugging mode, allowing you to easily fix problems in your Haxe code.
1. Install the latest .NET Framework Dev Pack and the .NET Framework Runtime.
3. Build your Haxe project by running haxe build.hxml in a console in your project directory.
1. Install the latest Mono Compiler
2. Build your Haxe project by running haxe build.hxml in a console in your project directory.
1. Install the latest .NET Core SDK and the .NET Core Runtime.
2. If on Windows, add the environment variable MSBuildSDKsPath with the value of your SDK directory path (typically C:\Program Files\dotnet\ or C:\Program Files (x86)\dotnet\).
3. If on Windows, update the environment variable PATH with the same value.
4. Add the following into your .hxml file:
--net-std ./netstd -D net-ver=47 -D net-target=net
5. Add the following files into the net-std directory, that must be created in your project directory:
mscorlib.dll System.Core.dll System.dll
6. Build your Haxe project by running haxe build.hxml in a console in your project directory.
7. Compile and run your app with the dotnet or dotnet.exe CLI.
Browse the Haxe API website for the core Haxe APIs that you can use in your project.
You can use C#-specific APIs in addition to the core Haxe APIs.
Browse the haxelib website for community-developed libraries that you can add to your project.
You can install haxelib libraries globally by running haxelib install <library>.
You can specify that your project uses a haxelib by adding -lib <library> to your .hxml file.
Refer to this guide to add third-party DLLs and assemblies.
If you use VS Code, the Haxe extension will find these dependencies and enable IntelliSense (code completion) for their classes and objects.
If you need help with anything, visit the vibrant Haxe community and simply ask for help with the details of your project. We have a helpful and active community and you should get your answers quickly!