Hello everyone, In this post we are going to learn about various Build Actions of Visual Studio. The Build Action property indicates what Visual Studio does with a file when a build is executed.
Actually you can change build action of each and every file in any visual studio project. Each build action has its own functionality as described below:
- None: The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file.
- Compile: The file is compiled into the build output. This setting is used for code files.
- Content: Allows you to retrieve a file (in same dir as assembly) as a stream via Application.GetContentStream( uri ). For this method to work, it needs a AssemblyAssociatedContentFile custom attribute which VS graciously adds when you mark a file as “Content”
- Embedded resource: embeds the file in an exclusive assembly manifest resource.
- Resource (wpf only): embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources.
- Page (wpf only): Used to compile a xaml file into baml. The baml is then embedded with the same technique as Resource (i.e. available as `AppName.g.resources)
- ApplicationDefinition (wpf only): Mark the XAML/class file that defines your application. You specify the code-behind with the x:Class=”Namespace.ClassName” and set the startup form/page with StartupUri=”Window1.xaml”
- SplashScreen (wpf only): An image that is marked as SplashScreen is shown automatically when an WPF application loads, and then fades
- DesignData: Compiles xaml viewmodels so that usercontrols can be previewed with sample data in visual studio (uses mock types)
- DesignDataWithDesignTimeCreatableTypes: Compiles xaml viewmodels so that usercontrols can be previewed with sample data in visual studio (uses actual types)
- EntityDeploy: (Entity Framework): used to deploy the Entity Framework artifacts
- CodeAnalysisDictionary: A xml file containing custom word dictionary for spelling rules
Common Questions / Issues associated with understanding Build Action:
- My class under App_Code / App_Data is not accessible in Visual Studio .NET
- Cannot reference App_Code in .NET
The above questions mostly asked with the ASP.NET development, The answer is simple change the Build Action of the files under App_Data from Content to Compile.
- Select the file under App_Code / App_Data
- Go to Properties window
- Change Build Action to Compile