diff options
| author | ruki <[email protected]> | 2026-03-14 23:59:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-14 23:59:57 +0800 |
| commit | ca72dbcfd8c45f194b9770f63c91ebd00412fa39 (patch) | |
| tree | 55b8bedf7da0a11be16c0ff026db3a8bdcf844b6 /xmake/rules/csharp | |
| parent | 894833ab4ed9cc930c60ab7b9dec889ab1a67277 (diff) | |
improve csproj rules
Diffstat (limited to 'xmake/rules/csharp')
| -rw-r--r-- | xmake/rules/csharp/build/target.lua | 16 | ||||
| -rw-r--r-- | xmake/rules/csharp/xmake.lua | 17 |
2 files changed, 15 insertions, 18 deletions
diff --git a/xmake/rules/csharp/build/target.lua b/xmake/rules/csharp/build/target.lua index 60b26602f..a193b2f8b 100644 --- a/xmake/rules/csharp/build/target.lua +++ b/xmake/rules/csharp/build/target.lua @@ -23,6 +23,20 @@ import("core.base.option") import("core.tool.compiler") import("core.project.depend") import("utils.progress") +import("modules.csharp_common", {rootdir = path.directory(os.scriptdir()), alias = "csharp_common"}) + +-- find or generate .csproj file +function _get_csprojfile(target) + local csprojfile = target:data("csharp.csproj") + if csprojfile then + return csprojfile + end + csprojfile = csharp_common.find_or_generate_csproj(target) + if csprojfile then + target:data_set("csharp.csproj", csprojfile) + end + return csprojfile +end -- build the source files function build_sourcefiles(target, sourcebatch, opt) @@ -35,7 +49,7 @@ function build_sourcefiles(target, sourcebatch, opt) local sourcekind = sourcebatch.sourcekind -- prepend .csproj file so dotnet tool can find it - local csprojfile = target:data("csharp.csproj") + local csprojfile = _get_csprojfile(target) if csprojfile then table.insert(sourcefiles, 1, csprojfile) end diff --git a/xmake/rules/csharp/xmake.lua b/xmake/rules/csharp/xmake.lua index 56772a0e8..3b6e3bf94 100644 --- a/xmake/rules/csharp/xmake.lua +++ b/xmake/rules/csharp/xmake.lua @@ -18,25 +18,8 @@ -- @file xmake.lua -- --- handle .csproj project file -rule("csharp.csproj") - set_extensions(".csproj") - on_config(function (target) - import("modules.csharp_common", {rootdir = os.scriptdir(), alias = "csharp_common"}) - - -- find .csproj from source files or generate one - local csprojfile = csharp_common.find_or_generate_csproj(target, {skip_deps = true}) - if csprojfile then - target:data_set("csharp.csproj", csprojfile) - if not target:get("filename") and not target:get("basename") then - target:set("basename", path.basename(csprojfile)) - end - end - end) - rule("csharp.build") set_sourcekinds("cs") - add_deps("csharp.csproj") on_load(function (target) -- set target extension and prefix if target:is_shared() then |
