summaryrefslogtreecommitdiff
path: root/xmake/rules/csharp/installcmd.lua
diff options
context:
space:
mode:
authorJassJam <[email protected]>2026-02-24 18:04:11 +0000
committerruki <[email protected]>2026-03-14 00:10:13 +0800
commit454997b0d4e7775ea70f81986528e7fc21dc50f9 (patch)
tree7e3de8d1eb422980927527887f964d15359aba79 /xmake/rules/csharp/installcmd.lua
parentbe2de5598c80f9b9960909aa876d4a4e533b9710 (diff)
feat: split C# rule into multiple modules
Diffstat (limited to 'xmake/rules/csharp/installcmd.lua')
-rw-r--r--xmake/rules/csharp/installcmd.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/xmake/rules/csharp/installcmd.lua b/xmake/rules/csharp/installcmd.lua
new file mode 100644
index 000000000..42733bfb0
--- /dev/null
+++ b/xmake/rules/csharp/installcmd.lua
@@ -0,0 +1,59 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author JassJam
+-- @file installcmd.lua
+--
+
+local csharp_common = import("csharp_common", {anonymous = true})
+
+function main(target, batchcmds, opt)
+ local csprojfile = assert(csharp_common.find_csproj(target), "target(%s): missing csharp .csproj file!", target:name())
+ local dotnet = csharp_common.get_dotnet_program(target)
+ local configuration = csharp_common.build_mode_to_configuration()
+ local verbosity = csharp_common.get_dotnet_verbosity(target)
+
+ local install_path = target:installdir()
+ if target:is_binary() then
+ install_path = target:installdir("bin")
+ elseif target:is_static() or target:is_shared() then
+ install_path = target:installdir("lib")
+ end
+
+ local install_abs
+ local argv = {
+ "publish", csprojfile,
+ "--nologo",
+ "--configuration", configuration,
+ "--verbosity", verbosity
+ }
+ if install_path and #install_path > 0 then
+ install_abs = path.is_absolute(install_path) and install_path or path.absolute(install_path, os.projectdir())
+ table.join2(argv, {"--output", install_abs})
+ end
+
+ local rid = csharp_common.get_runtime_identifier(target)
+ if rid and target:is_binary() then
+ table.join2(argv, {"--runtime", rid})
+ end
+ csharp_common.append_target_flags(target, argv)
+
+ batchcmds:show_progress(opt.progress, "${color.build.target}publishing.csharp.$(mode) %s", target:name())
+ if install_abs then
+ batchcmds:mkdir(install_abs)
+ end
+ batchcmds:vrunv(dotnet, argv, csharp_common.get_dotnet_runopt(csprojfile))
+end