The Cs2Cpp repo contains the complete source code implementation for Cs2Cpp. It includes CoreLib, and many other components. It is cross-platform.
Want to chat with other members of the Cs2Cpp community?
Some of the best ways to contribute are to try things out, file bugs, and join in design conversations.
Cs2Cpp is licensed under the MIT license.
Prerequisite: CMake 2.8+, .NET 4.6.2+, GCC 5.0+ or Microsoft Visual C++ 2017 Community Edition
- Build Project
cd Il2Native
MSBuild Il2Native.sln /p:Configuration=Release /p:Platform="Any CPU"
or open Il2Native.sln in Visual Studio 2017 and compile it
- Build CoreLib (aka mscorlib)
cd CoreLib
MSBuild CoreLib.csproj /p:Configuration=Release /p:Platform="AnyCPU"
- Create a temporary folder to build projects/files
cd ..\..
mkdir playground
cd playground
- Generating CoreLib C++ project
..\Il2Native\Il2Native\bin\Release\Cs2Cpp.exe /release ..\Il2Native\CoreLib\CoreLib.csproj
- Compile it
cd CoreLib
build_prerequisite_vs2017_release.bat
build_vs2017_release.bat
Now you have compiled CoreLib (mscorelib)
- Compile HelloWorld.cs
cd ..
create file HelloWorld.cs
using System;
class X {
public static int Main (string [] args)
{
Console.WriteLine ("Hello, World!");
return 0;
}
}
..\Il2Native\Il2Native\bin\Release\Cs2Cpp.exe /release HelloWorld.cs /corelib:..\Il2Native\CoreLib\bin\Release\CoreLib.dll
cd HelloWorld
build_vs2017_release.bat
Now you have HelloWorld.exe
- Build Core Lib
Cs2Cpp.exe /release <path_to_git>\coreclr\src\mscorlib\System.Private.CoreLib.csproj
- Build any Library project, for example System.Private.Uri
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Private.Uri\src\System.Private.Uri.csproj /corelib:System.Private.CoreLib.dll /p:Configuration=netstandard2.0-Windows_NT-Release
- Compile it
First Core library
cd System_Private_CoreLib
build_prerequisite_vs2017_release.bat
build_vs2017_release.bat
Then your targeted library
cd System_Private_Uri
build_vs2017_release.bat
- Generating source code for each reference
Cs2Cpp.exe /release <path_to_git>\coreclr\src\mscorlib\System.Private.CoreLib.csproj
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Collections\src\System.Collections.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Diagnostics.Contracts\src\System.Diagnostics.Contracts.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Diagnostics.Tools\src\System.Diagnostics.Tools.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Resources.ResourceManager\src\System.Resources.ResourceManager.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj /p:Configuration=netstandard2.0-Windows_NT-Release /corelib:System.Private.CoreLib.dll
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Runtime.InteropServices\src\System.Runtime.InteropServices.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Text.Encoding.Extensions\src\System.Text.Encoding.Extensions.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Threading\src\System.Threading.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Threading.Tasks\src\System.Threading.Tasks.csproj /p:Configuration=netstandard2.0-Windows_NT-Release
Cs2Cpp.exe /release <path_to_git>\corefx\src\System.Console\src\System.Console.csproj /p:Configuration=netstandard2.0-Windows_NT-Release /corelib:System.Private.CoreLib.dll
- Generate source code for "Hello World" executable
Cs2Cpp.exe /release helloworld.cs /ref:System.Console /corelib:System.Private.CoreLib
- Compile all projects one by one calling
cd <System.*>
build_vs2017_release.bat
- Prepare CoreRT to build, run
init-tools.cmd
build.cmd
This should generate 'AsmOffsets.cs'. Ensure it is placed into folder <path_to_git>\corert\bin\obj\Native\Windows_NT.x64.Release\Runtime\Full\
- Build Core Lib
Cs2Cpp.exe /release <path_to_git>\corert\src\System.Private.CoreLib\src\System.Private.CoreLib.csproj /p:Platform=x64
- Compile it
cd System_Private_CoreLib
build_prerequisite_vs2017_release.bat
build_vs2017_release.bat