Contentless/README.md

76 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

2021-10-24 00:48:23 +02:00
![The Contentless logo](https://raw.githubusercontent.com/Ellpeck/Contentless/main/Logo.png)
2022-09-25 23:32:35 +02:00
**Contentless** is tool for MonoGame that automatically handles adding assets to the Content Pipeline project, so you don't have to use their interface to add every content file manually.
2019-10-08 13:23:18 +02:00
# How to use
2019-11-07 01:42:07 +01:00
To use Contentless, you first have to add it to your project, either through your NuGet package manager or by adding it to your `.csproj` file as follows. Keep in mind to update the `Version` to the most recent one. You can find the package on the [NuGet website](https://www.nuget.org/packages/Contentless/) as well.
```xml
2022-09-25 23:32:35 +02:00
2019-11-07 01:42:07 +01:00
<ItemGroup>
<PackageReference Include="Contentless" Version="VERSION" />
</ItemGroup>
```
Next, you need to find the reference to your `Content.mgcb` file in your `.csproj` file or create one if there isn't already one present. The reference's type should be `MonoGameContentReference` so that Contentless can identify it correctly. If you're using the [MonoGame Content Builder](https://www.nuget.org/packages/MonoGame.Content.Builder.Task) alongside Contentless, this setting should already be applied.
2019-10-08 13:23:18 +02:00
```xml
2022-09-25 23:32:35 +02:00
2019-11-07 01:42:07 +01:00
<ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" />
</ItemGroup>
2019-10-08 13:23:18 +02:00
```
2019-11-07 01:42:07 +01:00
2019-10-08 19:27:42 +02:00
Contentless will now automatically add any content files from your `Content` directory and subdirectories to your `Content.mgcb` file if they haven't already been added either manually or by Contentless. No existing items' configurations will be overridden, so you can still use the Content Pipeline tool to modify any settings as well.
# Configuring
2022-09-25 23:32:35 +02:00
If you want to change the way Contentless works, you can use a configuration file. To do so, simply create a file named `Contentless.json` in the same directory as your `Content.mgcb` file. You can use the config to change several options:
```json5
2019-10-08 19:27:42 +02:00
{
2019-11-07 01:42:07 +01:00
// The list of files that should be excluded. Can use regex.
// Default: ["obj/", "bin/"]
2019-10-08 19:27:42 +02:00
"exclude": [
"obj/",
"bin/"
],
// If any files that were skipped without errors should be logged (Files that already have entries or files that were ignored)
2019-11-07 01:42:07 +01:00
// Default: true
2019-10-28 23:43:48 +01:00
"logSkipped": true,
// The list of files that should use a different importer or processor than the one that Contentless automatically determined. Can use regex.
2019-11-07 01:42:07 +01:00
// Default: {}
2019-10-30 23:59:47 +01:00
"overrides": {
2019-11-07 01:42:07 +01:00
// Example: Make all files matching the regex ".json" use the importer "JsonImporter"
".json": {
2022-09-25 23:32:35 +02:00
"importer": "JsonImporter"
},
// Example: Specifying both an importer and a processor
".ogg": {
"importer": "OggImporter",
"processor": "SongProcessor"
},
// Example: Only specifying a processor
".wav": {
"processor": "SoundEffectProcessor"
},
// Example: Setting a file to the Copy build action
".txt": {
"copy": true
},
// Example: Adding processor parameters for files
"TestFile.png": {
"processorParams": {
"TextureFormat": "Compressed"
}
}
2023-12-21 18:39:15 +01:00
},
// A set of content pipeline library references that should optionally be added to the content file, or whose paths should be changed in the content file if they don't match the project's package references
// Default: []
"references": ["MonoGame.Extended.Content.Pipeline"]
2019-10-08 19:27:42 +02:00
}
```
2021-10-24 00:48:23 +02:00
For an example of a config in use, see the [test config](https://github.com/Ellpeck/Contentless/blob/main/Test/Content/Contentless.json).
2019-10-08 17:24:50 +02:00
# What it does
2022-09-25 23:32:35 +02:00
When running Contentless and supplying the location of a MonoGame Content Pipeline project (`Content.mgcb`), it scans all the files in the project's directory as well as its subdirectories. For each file, it checks if the `Content.mgcb` file already contains any references to that file. If no references are found, then a new reference to the file is added.
2019-10-08 17:24:50 +02:00
2022-09-25 23:32:35 +02:00
Contentless figures out which importer and processor to register for any given file by generating a list of all the importers and processors that are available, both inside of MonoGame, and inside of References added to the `Content.mgcb` file. This process is similar to what occurs when adding an existing file through MonoGame's Content Pipeline tool. If Contentless sets the wrong importer or processor for any file, the user can simply open `Content.mgcb` in MonoGame's Content Pipeline tool and edit it manually.
2019-10-08 17:24:50 +02:00
2023-12-21 18:39:15 +01:00
As Contentless never changes any existing content of a `Content.mgcb` file, all changes that are made to it by hand or using the Content Pipeline tool will not be overridden.