What do the different build actions do in a csproj. I.e. AdditionalFiles or Fakes
There is no centralized documentation on these properties. The reason for it is that this list is extensible, each Visual Studio Project type can supply it's own. This also means that the contents of the drop-down changes depending on what Visual Studio payloads you have installed, which extensions, what programing language you're using etc.
This is an example of how this is extended for Code Analysis:
<!-- Make AdditionalFiles and CodeAnalysisDictionary available as a Build Action in Visual Studio -->
<ItemGroup>
<AvailableItemName Include="AdditionalFiles" />
<AvailableItemName Include="CodeAnalysisDictionary" />
</ItemGroup>
The others can be found by crawling the MsBuild targets folder, each is registered through AvailableItemName
items in the .target
files.
- None,
- Compile - Passes the files to the compiler that belongs to the project type
- Content - Marks files as content and optionally copies them to the output directory
- Embedded Resource - Used to embed content into asseblies as resource
- AdditionalFiles - Used by Code Analysis features. Defined in Microsoft.CodeAnalysis.Targets
- CodeAnalysisDictionary - Used by Code Analysis features, FxCop and Roslyn. Defined in Microsoft.CodeAnalysis.Targets
- ApplicationDefinition - Defined in Microsoft.Winfx.targets
- Page - Defined in Microsoft.Winfx.targets
- Resource - Defined in Microsoft.Winfx.targets
- SplashScreen - Defined in Microsoft.Winfx.targets
- DesignData - Defined in Microsoft.Winfx.targets
- DesignDataWithDesignTimeCreatableTypes - Defined in Microsoft.Winfx.targets
- EntityDeploy - Defined in Microsoft.Data.Entity.targets
- XamlAppDef - Defined in Microsoft.Winfx.targets and Microsoft.Xaml.targets
- Fakes - Used by the Fakes framework (part of Visual Studio Enterprise). A framework which allows writing tests that can bypass static, internal and private API's.
My system has a few extra ones on top of the ones you've posted. You'll need to search the docs for each project type for the meaning. Depending on their source you may need to look at the docs of 3rd party systems.
The extensibility of MsBuild makes it a very powerful system, at the same time it sometimes makes it nightmarish to figure out why things are the way they are. I've kept to the reasoning: "If I don't know what it means, I probably won't need it...".
It's an old question however in addition to jessehouwing's answer, it seems Microsoft now has official documentation regarding the Build Actions: https://docs.microsoft.com/en-us/visualstudio/ide/build-actions?view=vs-2019
Sharing below for reference (copied verbatim from the documentation):
[!NOTE] This topic applies to Visual Studio on Windows. For Visual Studio for Mac, see Build actions in Visual Studio for Mac.
+-----------------------------------------+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Build Action | Project types | Description |
+-----------------------------------------+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| **AdditionalFiles** | C#, Visual Basic | A non-source text file that's passed to the C# or Visual Basic compiler as input. This build action is mainly used to provide inputs to [analyzers](../code-quality/roslyn-analyzers-overview.md) that are referenced by a project to verify code quality. For more information, see [Use additional files](https://github.com/dotnet/roslyn/blob/master/docs/analyzers/Using%20Additional%20Files.md). |
| **ApplicationDefinition** | WPF | The file that defines your application. When you first create a project, this is *App.xaml*. |
| **CodeAnalysisDictionary** | .NET | A custom word dictionary, used by Code Analysis for spell checking. See [How to: Customize the Code Analysis Dictionary](../code-quality/how-to-customize-the-code-analysis-dictionary.md) |
| **Compile** | any | The file is passed to the compiler as a source file. |
| **Content** | .NET | A file marked as **Content** can be retrieved as a stream by calling <xref:System.Windows.Application.GetContentStream%2A?displayProperty=nameWithType>. For ASP.NET projects, these files are included as part of the site when it's deployed. |
| **DesignData** | WPF | Used for XAML ViewModel files, to enable user controls to be viewed at design time, with dummy types and sample data. |
| **DesignDataWithDesignTimeCreateable** | WPF | Like **DesignData**, but with actual types. |
| **Embedded Resource** | .NET | The file is passed to the compiler as a resource to be embedded in the assembly. You can call <xref:System.Reflection.Assembly.GetManifestResourceStream%2A?displayProperty=fullName> to read the file from the assembly. |
| **EntityDeploy** | .NET | For Entity Framework (EF) .edmx files that specify deployment of EF artifacts. |
| **Fakes** | .NET | Used for the Microsoft Fakes testing framework. See [Isolate code under test using Microsoft Fakes](../test/isolating-code-under-test-with-microsoft-fakes.md) |
| **None** | any | The file isn't part of the build in any way. This value can be used for documentation files such as "ReadMe" files, for example. |
| **Page** | WPF | Compile a XAML file to a binary .baml file for faster loading at run time. |
| **Resource** | WPF | Specifies to embed the file in an assembly manifest resource file with the extension *.g.resources*. |
| **Shadow** | .NET | Used for an .accessor file that contains a list of built assembly filenames, one per line. For each assembly on the list, generate public classes with the names `ClassName_Accessor` that are just like the originals, but with public methods instead of private methods. Used for unit testing. |
| **Splash Screen** | WPF | Specifies an image file to be displayed at run time when the app is starting up. |
| **XamlAppDef** | Windows Workflow Foundation | Instructs the build to build a workflow XAML file into an assembly with an embedded workflow. |
+-----------------------------------------+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[!NOTE] Additional build actions may be defined by 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.