Compartilhar via


Configure build actions in Visual Studio for Mac

Important

Visual Studio for Mac was retired on August 31, 2024 in accordance with Microsoft’s Modern Lifecycle Policy. While you can continue to work with Visual Studio for Mac, there are several other options for developers on Mac such as the preview version of the new C# Dev Kit extension for VS Code.

Learn more about support timelines and alternatives.

All files in a Visual Studio for Mac project have a build action. The build action controls what happens to the file when the project is compiled.

Note

This topic applies to Visual Studio for Mac. For Visual Studio on Windows, see Build actions.

Set a build action

To set a build action for a file in Visual Studio for Mac, you can right-click on any file and browsing to Build Action, as illustrated below:

Selecting Compile build action from Solution Explorer

Build actions for this file will be shown in the flyout menu.

Build action values

Some of the common build actions for projects you can build in Visual Studio for Mac include:

Build Action Project types Description
Compile any The file is passed to the C# compiler as a source file.
Content .NET, Xamarin For ASP.NET projects, these files are included as part of the site when it's deployed. For Xamarin.iOS and Xamarin.Mac projects, they'll be included in the app bundle.
Embedded Resource .NET The file is passed to the C# compiler as a resource to be embedded in the assembly. Assembly.GetManifestResourceStream, from the System.Reflection namespace, can then be used to read the file from the assembly.
None any The file isn't part of the build in any way and is included in the project for easy access from the IDE. This value can be used for documentation files such as "ReadMe" files, for example.

Note

Additional build actions can be defined for specific project types, so the list of build actions depends on the project type and values might appear that are not in this list.

Xamarin.iOS projects have the BundleResource build action, which will add the file as part of the app bundle. Information on Xamarin.Android specific build actions can be found in the build process guide.

It's also possible to select more than one file in the Solution Explorer, allowing you to set the build action to many files at once.

See also