首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当前解决方案包含使用Premake5与C#的不正确配置映射。

当前解决方案包含使用Premake5与C#的不正确配置映射。
EN

Stack Overflow用户
提问于 2022-04-23 23:14:19
回答 1查看 606关注 0票数 1

我正在尝试开发一个引擎,我正在C#中寻找一个GUI库,以便为我的引擎构建编辑器。我找到了Avalonia,但是我在设置整个环境时遇到了一些问题。

我使用Premake5作为构建工具,混合、C++、C#,但我认为这里的问题不是语言混合。

生成visual studio解决方案文件时会收到此错误。不好意思,我需要这样发布它,因为当我按下“”时,错误就消失了,并退出Configuration窗口,编译工作如出一辙,非常奇怪。

下面是我的代码:这是我运行的premake5脚本:

代码语言:javascript
运行
复制
include "Dependencies.lua"

workspace "LeafEngine"
    startproject "LeafEditor"

    configurations { "Debug", "Release" }
    platforms { "x64" }
    flags { "MultiProcessorCompile" }
    
    outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.platform}"

group "Dependencies"
    include "Leaf/vendor/glfw"
    include "Leaf/vendor/imgui"
group ""

include "Leaf"
include "LeafEditor"
include "LeafGame"

叶是我的C++引擎,LeafGame只是一个C++测试。叶编辑器是C#项目,如下所示:

代码语言:javascript
运行
复制
project "LeafEditor"
    kind "WindowedApp"
    language "C#"
    clr "On"

    targetdir   ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
    objdir      ("%{wks.location}/bin-obj/" .. outputdir .. "/%{prj.name}")

    dotnetframework "net6.0"

    nuget { "Avalonia:0.10.13", "Avalonia.Desktop:0.10.13",
            "Avalonia.Diagnostics:0.10.13", "Avalonia.ReactiveUI:0.10.13",
            "XamlNameReferenceGenerator:1.3.4"
          }

    files
    {
        "src/**.cs",
        "src/**.xaml",
        "src/**.xaml.cs",
    }

    links
    {
        "Microsoft.CodeAnalysis.CSharp.NetAnalyzers",
        "Microsoft.CodeAnalysis.NetAnalyzers",
        "System.Text.Json.SourceGeneration",
        "Microsoft.NETCore.APP",
    }

filter "system:Windows"
    defines "LF_WINDOWS"
    
filter "system:Unix"
    defines "LF_LINUX"

filter "configurations:Debug"
    defines "LF_DEBUG"
    runtime "Debug"
    symbols "on"

filter "configurations:Release"
    defines "LF_RELEASE"
    runtime "Release"
    optimize "full"

关于Avalonia的另一件奇怪的事情是:正如您所看到的,我只有一个可用的平台("x64")用于构建。嗯,Avalonia使用(“任意CPU")平台编译,这也破坏了我的整个建筑设置。此外,在加载项目时,Avalonia会使用任何CPU进行编译,而不是在编译项目时,对吗?

谢谢你,这个错误要我的命了。

EN

回答 1

Stack Overflow用户

发布于 2022-08-17 18:12:31

我只是遇到了同样的问题,无论是我的C#项目是用预制件构建的,还是作为外部项目构建的。

解决方案(当然,我放弃了C#的预制作,因此这可能只适用于外部项目)是不向工作区添加architecture或任何特定的platform,而是将其添加到所有的C#项目中。我会留下评论,因为这可能不是你想要的答案,但我没有足够的声誉。总之,比如说,

代码语言:javascript
运行
复制
    workspace "Lotus"
    startproject "LotusEditor"

    configurations
    {
        "Debug",
        "Release"
    }
project "CppProject"
architecture "x86_64" -- sets CppProject as x64 but not the workspace
-- more project config

externalproject "CsProject" -- no architecture/platform set for this. Might work for non externalprojects too
location "path"
uuid "insert uuid"
kind "WindowedApp"
language "C#"

即使我的项目不是用预制件手工完成的,而是以目标平台设置为x64的,它似乎仍然想要“任何CPU”作为配置,这是预制作所不能做到的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71984288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档