Dotnet tool | Core library | Website | Try it online!
This dotnet tool/CLI is a "front-end" that implements a "core" library CSharpToJavaScript translator, converter, transpiler, transcompiler, compiler, source-to-source compiler, you name it. CLI inspired (a little) by Meson, but it should behave like the dotnet cli and tsc cli.
dotnet tool install --global TiLied.CSTOJS_CLIcstojs-cli setup "Output"cstojs-cli translatedotnet tool update --global TiLied.CSTOJS_CLIdotnet tool uninstall --global TiLied.CSTOJS_CLI- Dotnet 10 required.
- To install dotnet tool globally run:
dotnet tool install --global TiLied.CSTOJS_CLI-
- To install locally, follow this tutorial
-
- For linux update PATH, see documentation
- Make a new directory "Test". Inside that directory, run:
cstojs-cli setup "Output"-
- The command executes:
-
-
- dotnet new console -f net10.0
-
-
-
- dotnet add package CSharpToJavaScript
-
-
-
- Creating "Output" folder
-
-
-
- Creating "cstojs_options.xml"
-
-
- Structure will be:
- obj
- Output
- cstojs_options.xml
- Program.cs
- Test.csproj-
- "Output" folder is where the translated JS files will be.
-
- "cstojs_options.xml" is project options, see below for an example.
- To translate "Program.cs", run:
cstojs-cli translate-
- The "Output" folder will contain a translated "Program.js" file.
- To add a new CS file, add
<File Source="./Test.cs" />to "cstojs_options.xml" and run "cstojs-cli translate" again. - To update, run:
dotnet tool update --global TiLied.CSTOJS_CLI- To delete, run:
dotnet tool uninstall --global TiLied.CSTOJS_CLI<ProjectOptions>
<!-- This is specifying an output folder for a js files. This example is "Output". -->
<Output Folder="Output" />
<!-- This is a default options which will be applied for every file that follows. -->
<DefaultOptions>
<!-- This is a "NormalizeWhitespace" option. See all available options at https://github.com/TiLied/CSharpToJavaScript/blob/master/CSharpToJavaScript/CSTOJSOptions.cs -->
<Option NormalizeWhitespace="true" />
</DefaultOptions>
<!-- This is a file that will be translated to js. -->
<File Source="./Program.cs" />
<!-- This is a file that will be translated to js with overridden options. -->
<File Source="./Test.cs">
<!-- This is a "Debug" option applying to only this file. -->
<Option Debug="true" />
</File>
</ProjectOptions>Run subcommands with -h to get more information.
init <folder> Create a barebone 'cstojs_options.xml', without running the dotnet commands.
setup <folder> Setup cstojs project.
translate Translate specified files in the 'cstojs_options.xml'.
watch Watches specified files in the 'cstojs_options.xml' with an interval and translates them. Note: The
'cstojs_options.xml' file is not being monitored, so any changes require the command to be restarted.
- Core library: https://github.com/TiLied/CSharpToJavaScript
- Tests: https://github.com/TiLied/CSTOJS_Tests
- Library for generating various stuff: https://github.com/TiLied/CSTOJS_GenLib
- Website/documentation: https://github.com/TiLied/CSTOJS_Pages
- Blazor WebAssembly app: https://github.com/TiLied/CSTOJS_BWA