premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

Build .NET projects with gmake

Open MrRobinOfficial opened this issue 3 months ago • 2 comments

What's your question? I’m working on a game engine that includes both C++ and C# projects managed with Premake. On Linux, I use gmake instead of vs2022. C++ projects build fine with gmake and GCC, but I cannot get C# projects to build.

Premake generates Makefiles that reference the csc compiler directly. On my Ubuntu WSL setup, I’m not sure if this is expected behavior, or whether the recommended approach nowadays is to use dotnet build instead of invoking Roslyn (csc) directly.

If csc is the correct tool, am I missing something in my setup? I have dotnet available in my environment path, but csc is only accessible via:

dotnet $DOTNET_ROOT/sdk/9.0.305/Roslyn/bincore/csc.dll

Creating a bash alias for csc doesn’t seem to work with the generated Makefiles.

Anything else we should know?

  • Is there a supported way to build .NET projects with Premake + gmake?
  • Or is the typical workflow to split managed/native projects, using vs2022 for managed and gmake for native builds?
  • Error I get when trying to build:
make[1]: csc: Not a directory
  • Code snippet from the makefile:
ifeq ($(config),debug)
  CSC = csc
  RESGEN = resgen

// ...

$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS) $(RESPONSE) | $(TARGETDIR)
	$(PRELINKCMDS)
	$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) @$(RESPONSE) $(patsubst %,/resource:%,$(EMBEDFILES))
	$(POSTBUILDCMDS)
  • Dotnet.lua file: https://github.com/premake/premake-core/blob/master/src/tools/dotnet.lua

Any solutions, tips, or recommended practices would be very helpful.

MrRobinOfficial avatar Sep 22 '25 18:09 MrRobinOfficial

I confirm that with https://github.com/Jarod42/premake-sample-projects/actions/runs/17925329736 I might have miss some setup though.

Jarod42 avatar Sep 22 '25 18:09 Jarod42

From what I remember Premake C# support for gmake was implemented back in Mono days.

So the implementation needs to be updated to invoke dotnet build as you suggested.

tritao avatar Oct 16 '25 12:10 tritao