0

I am trying to create a premake5.lua file for a Visual-Studio C# MonoGame project. I want to be able to make premake use the MonoGame project-template, instead of me having to manually dig through all the stuff that template creates for me and then putting that into premake. Currently I have the following premake5.lua file, which produces a project that compiles but has exceptions when running it...


workspace "TilemapEditor"
    architecture "x86"
    startproject "TilemapEditor"

    configurations
    {
        "Debug",
        "Release",
        "Distribution"
    }

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

project "TilemapEditor"
    location "TilemapEditor"
    kind "WindowedApp"
    language "C#"
    links {"MonoGame.Framework", "System", "System.Windows.Forms", "System.Xml"}

    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

    files { "%{prj.name}/src/**.cs", "Properties/AssemblyInfo.cs" }

    defines { "WINDOWS" }
    dotnetframework ("4.5")

    filter "configurations:Debug"
        symbols "On"

    filter "configurations:Release"
        symbols "Off"

I haven't found any function in the premake wiki that can do this.

Moritz Schäfer
  • 189
  • 1
  • 7

1 Answers1

1

No, not really. Premake is writing the full project from scratch, and not "filling in the blanks" from an existing project. Your best bet will be to diff the projects generated from Premake and the MonoGame template and tweak the settings in your Premake script to match. Once you've done that, it is pretty easy to create a function you can reuse to apply the same settings to different projects. Maybe something like:

function monoGameSettings()
   -- put your MonoGame baseline settings here
   filter {}  -- finish with this to close any opened filter blocks
end

-- use it like...
project 'MyProject'
    monoGameSettings()
J. Perkins
  • 4,156
  • 2
  • 34
  • 48
  • Would this function just use lua to fill in the blanks or also premake functionality? I kinda dont know where to start looking for how to write this function. – Moritz Schäfer Aug 13 '20 at 20:34
  • Perhaps start by identifying the differences between the MonoGame and Premake generated projects. Then use the [Premake docs](https://github.com/premake/premake-core/wiki) to try to get your script to generate a MonoGame compatible project. Then open an issue on premake-core if you need help from there. – J. Perkins Aug 14 '20 at 16:57