> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/glue-plugin-api/flatredball-glue/vshelpers/codebuilditemadder.md).

# codebuilditemadder

### Introduction

The CodeBuildItemAdder provides methods for adding entire .cs files into game projects. Entire files may be needed in projects for a number of reasons:

* As a cross-platform way to embed classes which are needed by a plugin, such as a runtime type for a file
* To create singletons which are used to simplify code generation in each screen or entity
* To provide utility methods to be used in custom code

### Example Usage

The steps for adding code to a project using the CodeBuildItemAdder are:

1. Add a .cs file to your project as an embedded resource:

   ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-30474c0c8bc493aecf3c92badf4494cdb558217e%2F2016-04-img_571b83de50fd8.png?alt=media)
2. (Optional) Set the namespace to use the $PROJECT\_NAMESPACE$ keyword to indicate that it should match the game project's namespace:

   ```lang:c#
   namespace $PROJECT_NAMESPACE$.OcularPlaneRuntime
   {
   ```
3. Add the code to embed the class. Embedded resources use the '.' character to separate folders, so if your file in the project is located at MyPlugin/EmbeddedCodeFiles/CodeFile.cs, then your code to add the file would be as shown in the following snippet:

   ```lang:c#
   var adder = new CodeBuildItemAdder();
   adder.OutputFolderInProject = "PluginFiles";
   adder.AddFileBehavior = AddFileBehavior.IfOutOfDate;
   adder.Add("MyPlugin.EmbeddedCodeFiles.CodeFile.cs");
   ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/api/glue-plugin-api/flatredball-glue/vshelpers/codebuilditemadder.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
