Nopipeline

repository·master·Indexed 42 days ago

https://github.com/martenfur/nopipeline

An addon for the MonoGame Pipeline Tool that automates the management of .mgcb configuration files using a JSON-based .npl configuration. It enables resource management via file patterns, file-watching dependencies, and external reference management using environment variables.

Tokens
1.3K
Snippets
4
Records
5
Agent score
4%

What's inside Nopipeline

  1. How the 'watch' parameter works

    master

    The watch parameter allows a resource file to trigger a rebuild if other files change. This is useful for complex assets like Tiled maps (.tmx) that depend on external textures or tilesets.

    When watch is used, the paths listed are relative to the rule's path.

    Example: If a rule has path: "Graphics/*.spritegroup" and watch: ["Default/*.png"], Nopipeline will watch Graphics/Default/*.png.

    {
    	"content": 
    	{
    		"spriteGroup": 
    		{
    			"path": "Graphics/*.spritegroup",
    			"recursive": "True",
    			"action": "build",
    			"importer": "SpriteGroupImporter",
    			"processor": "SpriteGroupProcessor",
    			"watch": 
    			[
    				"Default/*.png",
    				"Default/*.json",
    			]
    		}
    	}
    }
  2. Configure Nopipeline using an .npl file

    master

    Nopipeline uses an .npl configuration file (a JSON format) to define how resource files are handled.

    Setup Steps:

    1. Install Nopipeline.Task via NuGet.
    2. Run a build; Nopipeline will automatically generate an empty .npl config file on the first build.
    3. Define your resource rules in the .npl file.
    4. Save the .npl file in the same directory as your .mgcb file and ensure they have the same name (e.g., Content/Content.mgcb and Content/Content.npl).
    5. (Optional) You can safely add your .mgcb files to .gitignore as Nopipeline will regenerate them automatically.
    {
    	"root": "../Path/To/Your/Content/",
    	"content": 
    	{
    		"textures": 
    		{
    			"path": "Textures/*.png",
    			"recursive": "True",
    			"action": "build",
    			"importer": "TextureImporter",
    			"processor": "TextureProcessor",
    			"processorParam": 
    			{
    				"ColorKeyColor": "255,0,255,255",
    				"ColorKeyEnabled": "True",
    				"GenerateMipmaps": "False",
    				"PremultiplyAlpha": "True",
    				"ResizeToPowerOfTwo": "False",
    				"MakeSquare": "False",
    				"TextureFormat": "Color",
    			}
    		},
    		"specificFile": 
    		{
    			"path": "Path/To/File/specificFile.txt",
    			"recursive": "False",
    			"action": "copy"
    		}
    	}
    }
  3. Install Nopipeline via NuGet

    master

    To integrate Nopipeline into your MonoGame project, install the Nopipeline.Task NuGet package. Nopipeline acts as an addon for the MonoGame Pipeline Tool, automatically generating and updating your .mgcb configuration files based on an .npl configuration file.

    # Install via NuGet
    nupkg install Nopipeline.Task
  4. Configure NPL content rules

    master

    The content object in your .npl config contains rules for different resource types. Each rule can target entire directories or specific files.

    Parameters:

    • root: (Optional) A base path appended to each path field.
    • path: The path to resource files relative to the main Content folder.
      • Graphics/Textures/texture.png: Grabs only that specific file.
      • Graphics/Textures/*.png: Grabs all .png files in that folder.
      • Graphics/Textures/*: Grabs all files in the directory.
      • $Graphics/Textures/*: The $ prefix ignores the root property.
      • Note: Rule paths cannot contain ../. Use root for parent directory access.
    • recursive: Boolean ("True" or "False"). If "True", includes files from subdirectories.
    • action: Determines the operation. Use "build" for processing or "copy" for simple file copying.
    • importer: (Required if action is "build") The importer to use.
    • processor: (Required if action is "build") The processor to use.
    • processorParam: (Optional) A JSON object containing processor-specific parameters.
  5. Manage external references with NPL

    master

    Nopipeline provides extended reference management via a references array in the .npl config. This allows you to include external libraries (like .dll files) using environment variables and wildcards.

    Key Features:

    • Environment Variables: Supports syntax like %PROGRAMFILES%.
    • Wildcards: Supports standard file path wildcards.
    • Automatic Cleanup: If a referenced file is missing, Nopipeline will automatically remove its entry from the generated .mgcb config.
    • Compatibility: You can still add references the traditional way in the Pipeline Tool; Nopipeline will only remove them if the files no longer exist.
    {
    	"references":
    	[
    		"%PROGRAMFILES%/YourLibDir/Library.dll",
    		"RelativePath/RelativeLibrary.dll",
    		"OtherPath/*.dll",
    	],
    	"content": 
    	{
    		
    	}
    }