GithubHelp home page GithubHelp logo

nopipeline's Introduction

Nopipeline

Nopipeline

nuget

For some reason, the only Monogame's resource manager, Pipeline tool, is a total pain in the ass to work with. A lot of stuff which should've been automated is instead painfully done by hand in a crappy UI. After you've dragged and dropped 100 pngs one by one, you come to realization that the Pipeline tool is nothing but tears and sadness.

So what shall we do about all this?

Fear not - Nopipeline comes to the rescue. It's an addon for Pipeline Tool, which generates and updates .mgcb config for you. You can safely add, delete and move around resource files directly in Explorer - Nopipeline will do the rest for you.

Additionally, you can make resource files watch other files! Let's say, you got Tiled map project. It has one main .tmx file and a bunch of textures and tileset files. But Pipeline Tool has referenced only .tmx file, so if you update only texture or only tileset, you have to either update the .tmx or do a manual rebuild, because Pipeline Tool doesn't know about files other than .tmx.

With Nopipeline you don't have to do any of that - just set .tmx file to watch textures and tilesets - and Pipeline Tool will detect and update everything by itself.

Sounds cool and all, but is it compatible with my existing setup/engine/pipeline extensions?

Nopipeline is not a Pipeline Tool replacement - it's an addon. Its only function is to scoop up all resource files and put them into .mgcb config. The rest of the resource compilaton process will go exactly the same. You can add or remove Nopipeline at any point in development, and nothing will break. Nopipeline won't override resources which already exist in the .mgcb config and will leave a perfectly valid config after itself.

Now we're talking. How do I integrate this thing in my project?

First of all, install the Nopipeline.Task via Nuget. After that, you will need a NPL config. NPL config is what Nopipeline uses to generate MGCB config. Nopipeline will generate an empty NPL config automaticaly on first build. After that, you can just delete MGCB config. Yep, that's right, you don't need it anymore - Nopipeline will generate a new MGCB automatically. I also recommend adding your .mgcb files to the gitignore.

Now you need to understand how NPL config works and fill it up with rules so that Nopipeline would know what content goes where. NPL config looks like this:

{
	"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",
		}
	}
}

It is essentially a JSON. Config above has two content rules: textures and specificFile. Each rule describes one specific resource type. Rules can affect entire directories or specific files.

Let's look at an each parameter:

  • root is appended to each path field unless specified otherwise. This is an optional field.
  • path is a path to the resource files relative to the main Content folder. Here are some examples:
    • Graphics/Textures/texture.png will grab only texture.png file.
    • Graphics/Textures/*.png will grab any .png file.
    • Graphics/Textures/* will grab any file in the Textures directory.
    • $Graphics/Textures/* will ignore root property. NOTE: Rule paths cannot contain ../. Use root if you need those.
  • recursive tells Nopipeline to include resource files from subdirectories. For example, if set to True, and the path is Graphics/Textures/*.png, files from Graphics/Textures/Subdir/ will be grabbed as well. If set to False, they will be ignored.
  • action tells what action has to be done for this rule. Can be build or copy.
  • importer tells what importer should be used for building. Ignored if action is set to copy.
  • processor tells what processor should be used for building. Ignored if action is set to copy.
  • processorParam is an optional list of processor parameters, if resource has any.

There is also an optional watch parameter. Its usage looks like this:

{
	"content": 
	{
		"spriteGroup": 
		{
			"path": "Graphics/*.spritegroup",
			"recursive": "True",
			"action": "build",
			"importer": "SpriteGroupImporter",
			"processor": "SpriteGroupProcessor",
			"watch": 
			[
				"Default/*.png",
				"Default/*.json",
			]
		},
	}
}

With watch parameter present, all the .spritegroup files will be built by Pipeline Tool, if any .png or .json file will be changed. Note that all the paths listed in watch are relative to the main path, so final paths will look like this: Graphics/Default/*.png.

But that's not all. Nopipeline also provides an extended reference management. Add references section into your .npl config like this:

{
	"references":
	[
		"%PROGRAMFILES%/YourLibDir/Library.dll",
		"RelativePath/RelativeLibrary.dll",
		"OtherPath/*.dll",
	],
	"content": 
	{

	}
}

With Nopipeline you can use environment variables like %PROGRAMFILES% - something Pipeline Tool can't do by itself. If referenced libraries are missing, Nopipeline will delete their entries from config. Additionally, you can add references the old way from the Pipeline Tool - Nopipeline will not delete them unless the files themselves don't exist. References also support wildcards just like normal file paths.

With NPL config done, save it in the same directory as MGCB config and give it the same name. For example, if your MGCB config is named Content/Content.mgcb, your NPL config should be Content/Content.npl

You can also include NPL in Visual Studio project, if you want.

If you want more seamless pipeline-forgetting experience, you can check out Monofoxe Engine, with Nopipeline integrated out of the box.

Running the sample.

Before running the sample, build Nopipeline.Sample.Content project. This will build the custom pipeline extension.

All the other stuffs.

The thing is licensed under MPL 2.0, so you can use it and its code in anything you want for free.

Huge thanks to MirrorOfSun, who wrote most of the code.

Don't forget to pet your foxes.

nopipeline's People

Contributors

jamsilva avatar martenfur avatar mcmillen avatar mirrorofsun avatar seclerp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nopipeline's Issues

Use value from `MonoGameMGCBAdditionalArguments` to build MGCB

Currently, it's possible to customize the build process for MGCB using the property MonoGameMGCBAdditionalArguments.

https://monogame.net/articles/tools/mgcb.html#customizing-your-build-process

However, with the way Nopipeline works, it's running the MGCB manually, without waiting for the RunContentBuilder target from the MonoGame.Content.Builder.Task package.

I wish the Nopipeline task didn't do the generation of the content, and instead targetted running before the RunContentBuilder target. This would help a lot with configuring building for different platforms and configs through the csproj file.

For example, this is what I wanna be able to do while keeping the Nopipeline task included :

<Target Name="SetMGCBArgumentsMyself" BeforeTargets="RunContentBuilder">
  <PropertyGroup Condition="'$(Platform)' == 'desktopgl-linux' Or '$(Platform)' == 'desktopgl-windows'">
    <MonoGamePlatform>DesktopGL</MonoGamePlatform>
    <MonoGameMGCBAdditionalArguments>/profile:HiDef /platform:$(MonoGamePlatform)</MonoGameMGCBAdditionalArguments>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Platform)' == 'WindowsDX'">
    <MonoGamePlatform>Windows</MonoGamePlatform>
    <MonoGameMGCBAdditionalArguments>/profile:HiDef /platform:$(MonoGamePlatform)</MonoGameMGCBAdditionalArguments>
  </PropertyGroup>
  <Message Importance="high" Text="'$(Platform)' '$(Configuration)' '$(MonoGameMGCBAdditionalArguments)' HELLO THERE HERE" />
</Target>

Unfortunately, this won't work if you build using Nopipeline.

Content2.npl

Hi!

I'd like to keep separate the mgcb for NoPipeline project and the mgcb project, and run mgcb twice when building the game.

When creating Content2.npl (or whatever name I put to the npl file) I always get this error

1>  O:/tbd/Game1/Game1/Content/Content.npl not found!
1>  Run with path to .mgcb or .npl config as an argument:
1>      NoPipeline.exe Content/Content.mgcb
1>  or
1>      NoPipeline.exe Content/Content.npl
1>  

It never works, unless of course npl file is Content.npl , then it seems to work well.

Is it a bug or I have to do something extra in order to get a different name working?

thanks!

NoPipeline generating an odd structure for the MGCB file

Hi!

I've been struggling to get the NoPipeline to work. Running nopipeline produces the MGCB but not the XNB files, and the MGCB file it outputs also has a very odd structure.

Here's the content of the MGCB npl generates

CleanShot 2022-12-04 at 16 13 51@2x

Here's what the files look in the solution

Here's the repository that reproduces the issue. I can reproduce this on macOS by running the NPL from the terminal or building the project with Visual Studio 2022 and the latest version of Rider.

Nopipeline log is the following

I got this by running dotnet "/Users/jussi/.nuget/packages/nopipeline.task/2.2.0/tools/net6.0/any/npl.dll" Jelly/Content/Content.npl.

Nopipeline v2.2.0.0
Reading MGCB config /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/Content.mgcb

Reading setting: /outputDir:bin/$(Platform)
Reading setting: /intermediateDir:obj/$(Platform)
Reading setting: /config:
Reading setting: /profile:Reach
Reading setting: /compress:False

Reading content:././Graphics/fire.png
Reading content:././Graphics/jelly.png
Reading content:./Graphics/jelly.png
Reading content:./Graphics/fire.png
Reading content:Graphics/jelly.png
Reading content:Graphics/fire.png
Finished reading MGCB config! Got 6 items.

-------------------------------------

Reading NPL config.

No root found! Using default paths.



Reading content for: Graphics/*.png
    Reading Graphics/fire.png
    Reading Graphics/jelly.png

Finished reading NPL config!

-------------------------------------

Checking integrity of the final config.

Checking /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/././Graphics/fire.png
Checking /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/././Graphics/jelly.png
Checking /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/./Graphics/jelly.png
Checking /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/./Graphics/fire.png
Checking /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/Graphics/jelly.png
Checking /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/Graphics/fire.png

Updating snapshot!


-------------------------------------

Saving new config as /Users/jussi/tmp/ContentPipelineIssue/Jelly/Content/Content.mgcb

DONE. o-o

Any pointers for getting this work are appreciated. Hopefully, I'm just doing something obvious very wrong.

Possible to install as NuGet package?

Rather than have this be deployed via an exe/vsix, would it be possible to deploy this as a nuget package, similar to how the Monogame.Content.Builder nuget works?

I believe the package would just need an exe/dll and a targets file, very similar to how the monogame nuget files work

Curious if this has been explored at all? If not, maybe I'll take a shot at submitting a PR.

This seems to me like it would be a much simpler integration/installation story...

Easy way of referencing nugets

Hi, this is looking really promising, I really struggle with the default editor so I'm going to try this out tonight thanks!

One issue with the original editor is keeping references between machines, especially nuget references. Could we add a reserved variable that points to the user's nuget folder or better yet a convention that finds nugets based on package name and version? Eg nuget:SomePackage-1.0.0. I could contribute if you think it's a good idea.

Then all we need is a simple ui that generates an npl config and we can phase out the mgcb-editor ;)

Full paths instead of Relative paths not working as expected

Hello @Martenfur
I'm not 100% positive, but I couldn't make it work with full paths instead of relative paths. I was getting paths like C:\Path\To\ContentC:\Path\To\Project\Content and things like that. I ended up fixing it, at least for my specific use case. I would issue a Pull Request but in my fork I also got rid of some things and updated it to be compatible with .Net Core so if you want to check it out, the changes I made and an explanation are in my fork (b9aac72). The changes are a couple of lines but let me know if there is a better way of fixing the isse. For all I know I fixed my case but made it not work with plenty of other cases, didn't really test it in depth.

Cheers.

Unable to install version 2.1.0 from NuGet

After being driven almost to tears by how awful the MonoGame Content Pipeline is, I decided to give this package a whirl. But when I try to install it into my project, I get the error

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command "dotnet C:\Users\owner\.nuget\packages\nopipeline.task\2.1.0\build\\..\tools\netcoreapp3.1\any\npl.dll """ exited with code -532462766.	PongBreaker	C:\Users\owner\.nuget\packages\nopipeline.task\2.1.0\build\Nopipeline.Task.targets	8	

The tutorial on the readme file of this repository says that an NPL Config file is supposed to be created on the first build, but trying to build past this point results in the same error as before.

Installing the previous version, v2.0.1, does not result in any fatal errors, however, no NPL config file is produced anywhere in the file structure upon building, and instead I get the debug log

C:/Users/owner/Documents/MonoGame Projects/PixelDoughEngine/Engine/Content/Content.npl not found!
1>Run with path to .mgcb or .npl config as an argument:
1>    NoPipeline.exe Content/Content.mgcb
1>or
1>    NoPipeline.exe Content/Content.npl
C:/Users/owner/Documents/MonoGame Projects/PongBreaker/PongBreaker/Content/Content.npl not found!
1>Run with path to .mgcb or .npl config as an argument:
1>    NoPipeline.exe Content/Content.mgcb
1>or
1>    NoPipeline.exe Content/Content.npl

I have a Content.mgcb in my project, and I have one in the MonoGame Shared Library project in my solution. Could that have anything to do with it?

.net5 and .net6 usage

Currently this project requires .netcore 3.1 to be installed when building. Due to being backwards compatible, i would like to see this being able to run with only .net5 or .net6 installed on the machine.

Importing Music and Fonts

Hi, how can I go about importing music and fonts with NoPipeline? I don't think I want to use TextureImporter do I?

Unix paths don't work as expected

When putting in a Unix path to the references block in the .npl, the paths don't resolve as expected. For example, ~/.nuget/packages/... resolves to {Project Working Directory}/~/.nuget/packages/.... The expected behavior would be for it to resolve to {home directory}/~/.nuget/packages/.... Likewise, /etc/... resolves to {Project Working Directory}/etc/... instead of /etc/....

A workaround solution could be platform-specific reference settings in the .npl file.

Make Nopipeline work with .Net Core on Linux

I am unable to use Nopipeline as-is on Linux. However, changing all backslashes to slashes in Nopipeline.Task.targets makes things work correctly.
I expect macOS to have the same problem and I think Windows doesn't care but I only tested this change on Linux.

.Net Core

Hello,
Just in case anyone is interested, I made it compatible in .net Core (3.1). Also deleted some things on the process tho, like the sample application which I couldn't compile as it requires some things from other packages that I don't have (And also didn't care about those). It's [here] (https://github.com/OAguinagalde/NoPipeline).

@Martenfur feel free to update your repo if necessary.

awesome works!

hey, you did really awesome works. I think you can add a donate link or a sponsor page .

Linked files (mgcb)

Are there plans to support linked files? I usually have my code (and content.mgcb file) in a development drive and all my assets are in another drive, which forces me to use 'linking' in my MGCB for all my files.

MonoGame/MonoGame#5109

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.