From 64602026563f989462c10310df7909502791817d Mon Sep 17 00:00:00 2001 From: Ben Nicholson Date: Tue, 19 May 2026 21:53:39 +0100 Subject: [PATCH] dotnet buildaction uses given build action verbatim if no matching mapping is found rather than using the None fallback --- modules/vstudio/tests/cs2005/test_files.lua | 11 +++++++++++ src/tools/dotnet.lua | 6 +++++- website/docs/buildaction.md | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/vstudio/tests/cs2005/test_files.lua b/modules/vstudio/tests/cs2005/test_files.lua index 22a0113d48..d01a285dc9 100644 --- a/modules/vstudio/tests/cs2005/test_files.lua +++ b/modules/vstudio/tests/cs2005/test_files.lua @@ -270,6 +270,17 @@ ]] end + function suite.fallbackUserAction() + files { "Hello.custom" } + filter "files:Hello.custom" + buildaction "CustomAction" + prepare() + test.capture [[ + + ]] + end + + -- -- Files that exist outside the project folder should be added as diff --git a/src/tools/dotnet.lua b/src/tools/dotnet.lua index d100bb0919..9b78b161cf 100644 --- a/src/tools/dotnet.lua +++ b/src/tools/dotnet.lua @@ -75,7 +75,11 @@ info.action = "Page" end else - info.action = "None" + if fcfg.buildaction == nil then + info.action = "None" + else + info.action = fcfg.buildaction + end end -- Try to work out any subtypes, based on the files in the project diff --git a/website/docs/buildaction.md b/website/docs/buildaction.md index d7a9516f1f..ce8f021746 100644 --- a/website/docs/buildaction.md +++ b/website/docs/buildaction.md @@ -24,7 +24,7 @@ For C/C++, `action` is the name of the MSBuild action as defined by the vcxproj | Copy | Copy the file to the target directory. | For C# projects, `buildaction` behaviour is special to support legacy implementation. -In C#, `action` is one of +In C#, `action` can be one of | Action | Description | |-------------|-----------------------------------------------------------------------| @@ -38,6 +38,8 @@ In C#, `action` is one of | Resource | Copy/embed the file with the project resources. | | UserControl | Treat the source file as [visual user control][2]. | +If not matched by any of the above, the Action falls back to using the given action name verbatim (with no SubType). This allows project specific user defined custom BuildActions to be specified. + The descriptive actions such as **Component**, **Form*, and **UserControl** are only recognized by Visual Studio, and may be considered optional as Visual Studio will automatically deduce the types when it first examines the project. You only need to specify these actions to avoid unnecessary modifications to the project files on save. ### Applies To ###