Ich möchte Logik zwischen ihnen zwischen ihnen teilen, indem ich meinen C# -Code in Javascript zusammenfasst, damit ich es in meinen Node.js -Server . Problem
Ich verwende H5 (die Gabel von Bridge.net) , und während ich meinen C# -Codus erfolgreich umgetragen habe, enthält die Ausgabe eine gesamte Website -Setup mit Index.html und mehrfach zusätzliche Skripte, die ich nicht benötigt. />
Projekt -Setup
Projektstruktur
Hier ist die Struktur meines Projekts:
Code: Select all
MyH5Project/
├── dist/ # Output directory after build
├── src/ # Source code directory
│ ├── Program.cs # Main C# program
│ ├── MySharedLogic.cs # The class I want to share
├── MyH5Project.csproj # Project configuration
├── h5.json # H5 configuration
├── Program.cs # Entry point (for testing)
< /code>
[b] C# Code (Code (Program.cs
Code: Select all
using System;
namespace MyH5Project
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
< /code>
[b] H5 -Konfiguration (Konfiguration (h5.json
Code: Select all
{
"output": "dist",
"generateTypeScript": true,
"filename": "MySharedLogic.js"
}
< /code>
[b] Projektdatei (Projektdatei (MyH5Project.csproj
Code: Select all
netstandard2.1
7.2
Nach dem Erstellen mit H5 enthält mein Dist/ Ordner:
Code: Select all
dist/
├── h5.js
├── h5.meta.js
├── h5.meta.min.js
├── h5.min.js
├── index.html
├── MySharedLogic.d.ts
├── MySharedLogic.js
├── MySharedLogic.meta.js
├── MySharedLogic.meta.min.js
├── MySharedLogic.min.js
Code: Select all
/**
* @compiler H5 24.11.53871+ca5625efbf0742e20cab0bf5f9f52554d70bc0f3
*/
H5.assemblyVersion("MyH5Project","1.0.0.0");
H5.assembly("MyH5Project", function ($asm, globals) {
"use strict";
H5.define("MyH5Project.Program", {
main: function Main (args) {
System.Console.WriteLine("Hello World!");
}
});
});