I'm about to bump this tool to the latest clojure-clr version but it allows anyone to just use clojure-clr together with a .csproj project and dotnet run , dotnet test , dotnet build , dotnet publish works. (early days, here be dragons, but works for my projects)
https://github.com/Dangercoder/Clojure.MSBuild/tree/master/examples/minimal-api
I found this part interesting, where you can freely just mix C# and cljr https://github.com/Dangercoder/Clojure.MSBuild/tree/master/examples/csharp-interop/src and it just works seamlessly.
@jarvinenemil Thanks for this library. I was able to get things to work in my toy project as I try to learn .NET. Could you help me understand how MSBuild knows to call Clojure.MSBuild to generate the ClojureEntry.g.cs file? Also ClojureEntry.g.cs is treated as a script with an implicit Main method and so no StartupObject tag is required in the .csproj file I guess?
The .csproj is very small
Hi. I'm a noob to ClojureCLR and .NET. I have a toy project at https://github.com/xfthhxk/try-clojure-clr and I can run the code with bb run:main. I have been stuck on a couple of things.
1. How to AOT properly? When I run compile, the DLLs are placed in the project root instead of *compile-path* which is bound to "classes".
2. Also how do I make DLLs/executables that will run on Linux and Windows?
Would appreciate any help with this. Also is there a ClojureCLR guide for JVM Clojure people?
I just pushed alpha7.
Let me know if it solves the *compile-path* problem for you.
super! I'll try it out later today. thank-you!
Yes the compilation output is now going to the *compile-path* directory. Thanks @dmiller
Although now I'm not sure how to run the output. Seeing this
dotnet ./assemblies/foo.core.cljr.dll
You must install or update .NET to run this application.
App: /home/user/projects/xfthhxk/try-clojure-clr/assemblies/foo.core.cljr.dll
Architecture: x64
Framework: '', version '11.0.0' (x64)
.NET location: /nix/store/31bcbr9x95rxrjyzm4k4w152hnjfvbgf-dotnet-sdk-11.0.100-preview.2.26159.112/share/dotnet/
The following frameworks were found:
11.0.0-preview.2.26159.112 at [/nix/store/31bcbr9x95rxrjyzm4k4w152hnjfvbgf-dotnet-sdk-11.0.100-preview.2.26159.112/share/dotnet/shared/Microsoft.NETCore.App]
Learn more:
To install missing framework, download:
My runtime config
cat assemblies/foo.core.cljr.runtimeconfig.json
{
"runtimeOptions": {
"frameworks": [
{
"name": "",
"version": "11.0.0"
}
],
"rollForward": "LatestMajor"
}
}
Same thing if I target assemblies/foo.core.exeok finally got things to work! documented on the readme https://github.com/xfthhxk/try-clojure-clr
The DLLs created by AOT compilation are not standalone executables.
They must be loaded into a running ClojureCLR. If they are on the CLOJURE_LOAD_PATH, they can be discovered by require
It is possible to create an actual executable using gen-class with`main` .
major source of my troubles were getting the preview framework to be picked up along with the dearth of knowledge of framework/runtime. Good to know about the load path. Thanks very much for your help!
It is super fun to use Clojure on .NET. I feel right at home in the REPL. Thank you!
If you are into IDEs, NREPL is available, allowing you to plug into VSCode via Calva. (This probably should be written up also.)
This is a bug regarding *compile-path* introduced when AOT-compilation was re-established with .NET 9.0. I'll get a fix out (new alpha) by tomorrow.
You are correct that AOT-compiled code is bytecode and will work on any platform running dotnet.
There is no guide to ClojureCLR for ClojureJVM people. Attempt at humor: Do so few ClojureJVM people try ClojurCLR because there is not guide, or is there no guide because so few try? More seriously, if you would care to share what you would find / would have found useful, I'd love to know. Feel free to DM if you are so inclined.
Thanks @dmiller ! I'll be happy to put together what I learn into some sort of documentation. I have mostly worked in JVM shops so never dabbled with ClojureCLR though I was aware it's an option if I ever had to do anything .NET related. It looks like work is going to give me the opportunity. Will need to provide some Blazor components to another team to embed in a Blazor based app. Lots to learn in the new ecosystem especially the dotnet tool and understanding .csproj files. One big gotcha that had me stuck for hours was that if something is built against an older SDK, it won't automatically work with a new SDK unless if the env variable DOTNET_ROLL_FORWARD=LatestMajor is set.
I've never had to use that env var. Happy to talk Blazor anytime. I've spent a lot of time building prototypes in Blazor over the last year (but not using Clojure due to constraints, but happy to contemplate it). You might also be interested in the work by @jarvinenemil on integrating ClojureCLR into MSBuild builds. https://github.com/Dangercoder/Clojure.MSBuild .
awesome. thank-you for the link and I may take you up on Blazor
I guess the DLLs are bytecode so should work as long as the dotnet runtime is present?
Yup I've been using nrepl from spacemacs flavored emacs. It's working well.