From f92c2040d8cce57c00c58b57af842d6171f6b167 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 13 Oct 2024 18:39:39 -0400 Subject: [PATCH] update mocha-dotnet-new; this actually works --- mocha-dotnet-new | 61 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/mocha-dotnet-new b/mocha-dotnet-new index a5501c3..4bcfcee 100755 --- a/mocha-dotnet-new +++ b/mocha-dotnet-new @@ -4,6 +4,63 @@ # creates a new DotNet project and adds all the references needed to use # Mocha from within .NET +MOCHA_DOTNET_LIBRARIES_PATH=/usr/lib/mocha/dotnet +MOCHA_MOCHA_LIBRARIES_PATH=/home/beckermj/Documents/Projects/mochapowered/mocha-dotnet/mocha-common/mocha-common/output + dotnet new console -dotnet add reference /usr/lib/mocha/dotnet/Mocha.Core.dll -dotnet add reference /usr/lib/mocha/dotnet/MBS.Core.dll +# dotnet add reference /usr/lib/mocha/dotnet/Mocha.Core.dll +# dotnet add reference /usr/lib/mocha/dotnet/MBS.Core.dll + +# link a reference to mocha system libraries +ln -s $MOCHA_MOCHA_LIBRARIES_PATH system + +# since we cannot 'dotnet add reference', do it manually - it still works +FILE=*.csproj + +ROOT_NAMESPACE=MochaTest1 + +echo """ + + + + Exe + net8.0 + $ROOT_NAMESPACE + enable + enable + + + + $MOCHA_DOTNET_LIBRARIES_PATH/MBS.Core.dll + + + $MOCHA_DOTNET_LIBRARIES_PATH/Mocha.Core.dll + + + $MOCHA_DOTNET_LIBRARIES_PATH/Mocha.Plugins.Libraries.McxMini.dll + + + + + + +""" > $FILE + +FILE=Program.cs + +echo """ +// See https://get.mochapowered.com/mocha-dotnet-new for more information + +Mocha.Core.OmsImplementations.EmbeddedMiniOms oms = new Mocha.Core.OmsImplementations.EmbeddedMiniOms(); +oms.SystemLibraryResourceName = null; // \"mocha_test.resources.net.alcetech.Mocha.System.mcl\"; + +oms.Initialize(); + +Mocha.Core.LibraryHandle lh = oms.LoadLibrary(\"system/net.alcetech.Mocha.System.mcl\"); +oms.AddLibraryReference(lh); + +Mocha.Core.InstanceHandle ih = oms.GetInstance(Mocha.Core.KnownInstanceGuids.Classes.Class); + +Console.WriteLine(\"Hello, World! The \`Class\` GID is {0}\", oms.GetGlobalIdentifier(ih)); +""" > $FILE +