Skip to content

Commit ad3be42

Browse files
committed
dotnet buildaction uses given build action verbatim if no matching mapping is found rather than using the None fallback
1 parent 55fc4b2 commit ad3be42

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

modules/vstudio/tests/cs2005/test_files.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,17 @@
270270
]]
271271
end
272272

273+
function suite.fallbackUserAction()
274+
files { "Hello.custom" }
275+
filter "files:Hello.custom"
276+
buildaction "CustomAction"
277+
prepare()
278+
test.capture [[
279+
<CustomAction Include="Hello.custom" />
280+
]]
281+
end
282+
283+
273284

274285
--
275286
-- Files that exist outside the project folder should be added as

src/tools/dotnet.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@
7575
info.action = "Page"
7676
end
7777
else
78-
info.action = "None"
78+
if (fcfg.buildaction == nul) then
79+
info.action = "None"
80+
else
81+
info.action = fcfg.buildaction
82+
end
7983
end
8084

8185
-- Try to work out any subtypes, based on the files in the project

website/docs/buildaction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For C/C++, `action` is the name of the MSBuild action as defined by the vcxproj
2424
| Copy | Copy the file to the target directory. |
2525

2626
For C# projects, `buildaction` behaviour is special to support legacy implementation.
27-
In C#, `action` is one of
27+
In C#, `action` can be one of
2828

2929
| Action | Description |
3030
|-------------|-----------------------------------------------------------------------|
@@ -38,6 +38,8 @@ In C#, `action` is one of
3838
| Resource | Copy/embed the file with the project resources. |
3939
| UserControl | Treat the source file as [visual user control][2]. |
4040

41+
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.
42+
4143
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.
4244

4345
### Applies To ###

0 commit comments

Comments
 (0)