Skip to main content

buildaction

Specifies how a file or set of files should be treated during the compilation process. It is usually paired with a filter to select a file set. If no build action is specified for a file a default action will be used, based on the file's extension.

buildaction ("action")

Parameters

For C/C++, action is the name of the MSBuild action as defined by the vcxproj format; eg: ClCompile, FxCompile, None, etc, and may refer to any such action available to MSBuild.

ActionDescription
ClIncludeTreat the file as an include file.
ClCompileTreat the file as source code; compile and link it.
FxCompileTreat the file as HLSL shader source code; compile and link it.
NoneDo nothing with this file.
ResourceCompileCopy/embed the file with the project resources.
CustomBuildTreat the file as custom build code; compile and optionally link it.
MidlTreat the file as MIDL source code; compile and link it.
MasmTreat the file as MASM source code; compile and link it.
ImageTreat the file as an Image.
NatvisTreat the file as Natvis source; use it for custom data layouts while debugging.
AppxManifestTreat the file as AppX Manifest; required for UWP applications.
CopyCopy the file to the target directory.

For C# projects, buildaction behaviour is special to support legacy implementation. In C#, action is one of

ActionDescription
ApplicationMark the file as the application definition XAML for WPF.
CompileTreat the file as source code; compile and link it.
ComponentTreat the source file as a component, usually a visual control.
CopyCopy the file to the target directory.
EmbedEmbed the file into the target binary as a resource.
FormTreat the source file as visual (Windows) form.
NoneDo nothing with this file.
ResourceCopy/embed the file with the project resources.
UserControlTreat the source file as visual user control.

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

File configurations.

Availability

Build actions are currently supported for C/C++ and C# projects.

Compile, Copy, Embed, and None are available in Premake 4.4 or later. All actions are available in Premake 5.0 or later.

Examples

Embed all PNG images files into the target binary.

filter "files:**.png"
buildaction "Embed"