【问题标题】:Is there a way to make Premake use Visual-Studio Project templates?有没有办法让 Premake 使用 Visual-Studio 项目模板?
【发布时间】:2020-08-07 07:44:23
【问题描述】:

我正在尝试为 Visual-Studio C# MonoGame 项目创建 premake5.lua 文件。我希望能够使用 MonoGame 项目模板制作 premake,而不是我必须手动挖掘模板为我创建的所有内容,然后将其放入 premake。 目前我有以下premake5.lua文件,它生成的项目可以编译但运行时出现异常...


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"

我在 premake wiki 中没有找到任何可以做到这一点的函数。

【问题讨论】:

    标签: visual-studio-2019 monogame project-template premake


    【解决方案1】:

    不,不是真的。 Premake 是从头开始编写完整的项目,而不是从现有项目中“填补空白”。你最好的办法是区分从 Premake 和 MonoGame 模板生成的项目,并调整 Premake 脚本中的设置以匹配。完成后,很容易创建一个可以重复使用的函数,以将相同的设置应用于不同的项目。可能是这样的:

    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()
    

    【讨论】:

    • 这个函数是只使用lua来填补空白还是预制功能?我有点不知道从哪里开始寻找如何编写这个函数。
    • 也许从识别 MonoGame 和 Premake 生成的项目之间的差异开始。然后使用Premake docs 尝试让您的脚本生成一个与MonoGame 兼容的项目。如果您需要帮助,请在 premake-core 上打开一个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 2023-02-03
    • 2018-01-23
    • 1970-01-01
    相关资源
    最近更新 更多