craftworkgames / MonoGame.Extended

Extensions to make MonoGame more awesome
http://www.monogameextended.net/
Other
1.44k stars 324 forks source link

Cannot build .tmx files. TiledMapTilesetProcessor showing a MissingMethodException #783

Closed fhb93 closed 6 months ago

fhb93 commented 2 years ago

Hello, I'm trying to migrate a project from Windows to an M1 Macbook Air, so I can handle adjustments to run my game on Intel & Apple Silicon hardware too. After setting everything up I've found that MGCB cannot build the TiledMap files into xnb. The mgcb build task stops in an System.MissingMethodException. After one day seeking for a fix, I downloaded and tried to build the Monogame Extended samples to check if the issue is happening only with my project. Below is the exact output from the CLI mgcb (Issue happens with MGCB-editor and CLI mgcb). The sample project in question is the Platformer one.

/Users/username/Downloads/MonoGame.Extended-samples-master/src/Games/Platformer/Content/test-map.tmx: error: Processor 'TiledMapTilesetProcessor' had unexpected failure! System.MissingMethodException: Method not found: 'Microsoft.Xna.Framework.Color Microsoft.Xna.Framework.Color.get_TransparentBlack()'. at MonoGame.Extended.Content.Pipeline.Tiled.TiledMapTilesetProcessor.Process(TiledMapTilesetContentItem contentItem, ContentProcessorContext context) at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/ContentProcessor.cs:line 60 at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs:line 717

Any ideas on what is going on? Thanks in advance 🙂

devme0 commented 2 years ago

I am facing the same issue :

image

I am running on Windows 11 with Visual Studio 2022, the project uses the Android template. I am using an embedded tile set with a single tile set image for the tile map made using Tiled.

Referenced Versions:

    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
    <PackageReference Include="MonoGame.Extended" Version="3.8.0" />
    <PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.8.0" />
    <PackageReference Include="MonoGame.Extended.Tiled" Version="3.8.0" />
    <PackageReference Include="MonoGame.Framework.Android" Version="3.8.1.303" />

The Content.mgcb file:


#----------------------------- Global Properties ----------------------------#

/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:Android
/config:
/profile:Reach
/compress:False

#-------------------------------- References --------------------------------#

/reference:..\..\..\..\..\.nuget\packages\monogame.extended.content.pipeline\3.8.0\tools\MonoGame.Extended.Content.Pipeline.dll

#---------------------------------- Content ---------------------------------#

#begin Tile/gamemap.tmx
/importer:TiledMapImporter
/processor:TiledMapProcessor
/build:Tile/gamemap.tmx

#begin Tile/rect111.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Tile/rect111.png

I have been at it for two days now, any help will be highly appreciated.

devme0 commented 2 years ago

Even downgrading the MonoGame.Content.Builder.Task and MonoGame.Framework.Android version to 3.8.0 still throws the same error:

    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0" />
    <PackageReference Include="MonoGame.Extended" Version="3.8.0" />
    <PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.8.0" />
    <PackageReference Include="MonoGame.Extended.Tiled" Version="3.8.0" />
    <PackageReference Include="MonoGame.Framework.Android" Version="3.8.0" />
MetaFight commented 2 years ago

I found downgrading mgcb to version 3.7.0 fixed the issue, but unfortunately this left my pipeline artifacts in an unusable version.

damian-666 commented 2 years ago

hope this novella helps #1. I saw in the changes that Transparent Black was removed as redundant. its now just Color.Transparent. because they are both 0,0,0,0 .. but its a msssng symbol. wouldnt that explain the error?.. mabye a global using might switch it ? or Just change that symbol ibuild the source. PRs like this are beng taken in to MG core, but well mabye they should be just as stubborn as before not to take in stuff.. however it was becomng a mess , hard to maintain, so they did. . BUT consider mg 3.81. is NOT .. what if you define static Color.Transparent black in your code, as Color.Transparent, will it work?

3.80 + 01 update, u expect a day on.. featurewise yes, but structurally has MANY breaking changes ... expect WEEKS of work ...

2 or .. if you really give in an revert and still didnt work

this sounds like a vs 2022 cache issue: its subsequent builds are much faster because its caching stuff by date..so if you revert code or refs, might not get reverted results and go mad, so try this before smashing ur PC... find delete all your user Cache files made by VS 2022 .. in user , and temp directories in user your account there are tons of artifacts that might supercede ur reversion..because tghe cache is newer. im using the VS 2022 latest prevew and has similar issue after i reverted code. and even did a clean clone with changes i made that broke something.. , and then deleted all the nuget stuff and the regress was STILL THERE... But theres more artifacts: . search your whole HD at least ur user part, for any extension, and sort by Date, around when things went south ( when u updated) , u will see various files with cache and other extension.. if its in User or Temp, its likely safe to delete. also The GAC is barely used now but it used to matter.

2.so even now, u might need to remove more stuff like config files and json files, so it wll go back to the GAC....... there are MSBuild things that tell nuget to "roll foward" there as json config filles everywhere to learn about if you have to . and if you really wanna downgrade there is PATH order to worry about.. mabye when u reisntall the older .net, its now later in the PATH.. the content manager directives are in a .config at the top of the sln.. part of the update to mg 3,81 requires unstilling netcore 3.1.. taht means if you put it back the path will be after and i might use the new one.

the new MSBuild is better , simpler but completely different. so.. well it sucks that things got broken so im detemined to move forward. to net6 adn 3.81 as they are suppossed to be LTS and 2 years supported.

  1. OR you can try building on windows and deploying on Mac? the mac verson has known content issues taht cannot be address and the devs admitted they need to fix somethng for mac dev studio some are embedded the xnb products in Dlls and makng a custom content manager like Nez has been doing for years to get around this for now.

OR, mabye try vs 2022 preview if yhou are using Vs 2022 release... or vscode...its stable, faster, and better but it caches even more. o ro vs code.. is slow but doenst make caches.

  1. look at Nez core see if it still works wtih MG.. regardless, He builds content xnb, mabye and puts the XNB as embedded resource in a core dll using custom content manager. i dont like this , cause me other issues. and think they are close to getting content working right. he has lots of sprite sheets and tile maps stuff...

    Thsi all stuff that i learned after days and questioning my sanity and all htat. i told a guy about the cache files it worked for him too... now. im fightin with missing ..binding as well. somethingin SharpDX wichis archived. now unsupported... m gong to keep on MG. 3.81, get rid net.48 fork and split MG / or wait for new bindings. but yet ive been fighting 4 weeks over something though mght take 2 days. but i had to do th sooner or later. anyways now i prolly need to trace the dead elephant of sharpDX or move on and go back ot ths feature later MS wllll change somethng. , because i cant use wpf interop with my docking system even if the sample works... sighhh... System.MissingMethodException: ‘Method not found: ‘IntPtr Microsoft.Xna.Framework.Graphics.Texture.GetSharedHandle()’.’ https://community.monogame.net/t/system-missingmethodexception-method-not-found-intptr-microsoft-xna-framework-graphics-texture-getsharedhandle/17894

On Mon, Sep 5, 2022 at 5:48 PM MetaFight @.***> wrote:

I found downgrading mgcb to version 3.7.0 fixed the issue, but unfortunately this left my pipeline artifacts in an unusable version.

— Reply to this email directly, view it on GitHub https://github.com/craftworkgames/MonoGame.Extended/issues/783#issuecomment-1237530070, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD74XGMDC5TLZ23KNTDI7O3V42BFDANCNFSM56MCM75A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MetaFight commented 2 years ago

Thanks for the nudge in the right direction. I had a quick look at the mg-e code and it looks like the dependence on Color.TransparentBlack has already been removed. I'll try to build a new Tiled pipeline extension (or whatever it's called) from the latest sources when I've got a bit of time. Hopefully the issue is already fixed and we just need a new build/nuget package.

MetaFight commented 2 years ago

I've made some progress with this.

I'm able to build and use Tile content with the following component versions

This seems to work because the latest source of Monogame.Extended.Content.Pipeline no longer references Color.TransparentBlack. Unfortunately, the produced assets only work with Monogame.Framework 3.8.0 and not the latest 3.8.1

damian-666 commented 2 years ago

thanks if i could help.. did yp put this file, that your root?

im considering using some netstandard2 dlls with linked code.. and some net 6 at thins point the transition to to net 6 is industry wide PAIN. and even considering going back to 4.8 on my level editor for now..

im using a WPF level editor and the net 6 verion of wpf is a little different.. so its i got 3 show stoppers... still and 4 weeks wrook i didnt expect.. here is how bad it can get https://blog.ndepend.com/5x-lessons-learned-from-migrating-a-large-legacy-to-net-5-6/ /nez has not updated his monamge so i dont know.. if you can build and trace monogame i think its the best idea.. otherwise shooting in the dark..

On Wed, Sep 7, 2022 at 5:06 PM MetaFight @.***> wrote:

I've made some progress with this.

I'm able to build and use Tile content with the following component versions

  • Monogame.Extended.Content.Pipeline built from the latest source
  • dotnet-mgcb v3.8.1.303
  • Monogame.Framework v3.8.0.1641
  • Monogame.Extended.Tile v3.8.0

This seems to work because the latest source of Monogame.Extended.Content.Pipeline no longer references Color.TransparentBlack. Unfortunately, the produces assets only work with Monogame.Framework 3.8.0 and not the latest 3.8.1

— Reply to this email directly, view it on GitHub https://github.com/craftworkgames/MonoGame.Extended/issues/783#issuecomment-1239998020, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD74XGIUU7IEREI7NUTVEFLV5ENXJANCNFSM56MCM75A . You are receiving this because you commented.Message ID: @.***>

MetaFight commented 2 years ago

Are you asking about the Monogame.Extended.Content.Pipeline.dll file? I put it with my other project external dependencies. I used the content editor to add a reference to it. I think there's currently also a bug with relative paths not working in .mgcb files so you'll need to double check that the reference uses an absolute path. I did this by opening the file in a text editor.

Hopefully that helps.

damian-666 commented 2 years ago

i have relative paths working but i put hte mgcb wiht the content in a shared net6 core.. then i link the mgcb to the exe project ... its relative so theres no internal relative path in the mgcb.. i dont link the assets themselves nor copy them.. they are set to None.. the content builder takes care of all that... ... i use ....bin not problem on windows as a base path its min my ..https://github.com/damian-666/MGShadersXPlatform/blob/master/MGXPlatformNet6.sln sample and the files copy.. its important to have the new content builder and rebuld your project files if yo are moving to net6 you have to change tons of tooling and erase old stuff... then new tool and msbuild is way better but it takes time.

but im not using extended content or even mp3 yet.. my sample might help yoyu tho as it copies the content to the right places. feel free to update it with mp3 and or whatever because there are no other new samples that show shared core multiplatfrom developement.. that is the only way to avoid repeat assets or code that i konw of and the simple sample i started with .. is 3.1 netcore and 2 years old..

.. make sure you have the .config folder at your root....{ "version": 1, "isRoot": true, "tools": { "dotnet-mgcb": { "version": "3.8.1.303", "commands": [ "mgcb" ] }, "dotnet-mgcb-editor": { "version": "3.8.1.303", "commands": [ "mgcb-editor" ] }, "dotnet-mgcb-editor-linux": { "version": "3.8.1.303", "commands": [ "mgcb-editor-linux" ] }, "dotnet-mgcb-editor-windows": { "version": "3.8.1.303", "commands": [ "mgcb-editor-windows" ] }, "dotnet-mgcb-editor-mac": { "version": "3.8.1.303", "commands": [ "mgcb-editor-mac" ] } } }

im having trouble with https://github.com/craftworkgames/MonoGame.WpfControl in another vault.... i get mtheod not found.. getShartedHaldle when i acces the rendertexture... in the view module.. its a sharpDX thing.. i think i have to bild monogame and then find out becausethe sample works i put a PR., and theer is another PR im gong to try his version.. . but im using legacy 48 components a detcore windows 6 exe and a only DevCompnonetsRibbon docing system.. its using tabbed dialogs. ill put the issue there but tabbed dialgs were never supported...

btw its 5 weeks and im 99 % though all this... its for 2 years LTS so i hope i dont have to do this again... the biggest pain for me was netstandard 2 dropped bu you can use old dependencies... msft command line upgrade -assistant mgiht help also.. or it might make a mess... the upside is my netcore6 libs are faster and projects cleaner.

kolen commented 2 years ago

Seems that it's fixed in #735. Works for me in latest develop cbbec7d123c2818e4abae7e4583fce5cef68c2a5 when building MonoGame.Extended.Content.Pipeline.dll from source.

MetaFight commented 2 years ago

https://github.com/craftworkgames/MonoGame.Extended/issues/783#issuecomment-1239998020

Indeed it does. When I checked there wasn't a new build and MonoGame 3.8.1 wasn't supported yet.

lithiumtoast commented 2 years ago

@kolen @MetaFight Latest builds are automatically deployed to MyGet. E.g. https://www.myget.org/feed/lithiumtoast/package/nuget/MonoGame.Extended/3.9.0-alpha0079.

8bitAlex commented 1 year ago

+1 still an issue

iNewmanity commented 1 year ago

Yeah, got this error too. Does anyone now, if the TileMap-Object is compatible with the TMX one from tiledsharp?

Lalayqz commented 1 year ago

My problem got solved by upgrading MonoGame.Extended & MonoGame.Extended.Content.Pipeline & MonoGame.Extended.Tiled to 3.9.0-alpha0093.

iNewmanity commented 1 year ago

My problem got solved by upgrading MonoGame.Extended & MonoGame.Extended.Content.Pipeline & MonoGame.Extended.Tiled to 3.9.0-alpha0093.

Could you please tell me, how to do it? Last Time i tried this, i got an error. I need this to work! Thank you in advance!

Lalayqz commented 1 year ago

My problem got solved by upgrading MonoGame.Extended & MonoGame.Extended.Content.Pipeline & MonoGame.Extended.Tiled to 3.9.0-alpha0093.

Could you please tell me, how to do it? Last Time i tried this, i got an error. I need this to work! Thank you in advance!

I'm not an expert at this, but here's what I did. In Visual Studio, use the search bar on the top go to the "Manage NuGet Packages..." page. Then add a new "MyGet" package source there, because alpha builds are deployed to "MyGet", not the default "nuget.org". image

Then upgrade to alpha builds using this "MyGet" package source. image

iNewmanity commented 1 year ago

Thanks a lot for your help; Helped me add the Alpha Package, but i still got issues. Now the MGCB-Editor shows System.NotSupportedException. Any hint where I can find a solution to that :)

Lalayqz commented 1 year ago

Thanks a lot for your help; Helped me add the Alpha Package, but i still got issues. Now the MGCB-Editor shows System.NotSupportedException. Any hint where I can find a solution to that :)

no idea on this one because I never got this issue D: but you can open a new issue and provide more details there if you can't find a solution online.

gldraphael commented 1 year ago

For anyone looking for another example on how to use the alpha package: https://github.com/GameBased/mystery-island/pull/20

iNewmanity commented 1 year ago

In the meantime i got this fixed but now have another problem: It wont build with the dotnet build command, with it saying error NU1102: Unable to find package MonoGame.Extended with version (>= 3.9.0-alpha0093)

purrplingcat commented 1 year ago

use 3.9.0-alpha doesn't work, because MGCB sas TiledMapImporter is invalid. If I look to the list of importers, there is none importer from Monogame extended.

quentinmrzt commented 1 year ago

Thanks a lot for your help; Helped me add the Alpha Package, but i still got issues. Now the MGCB-Editor shows System.NotSupportedException. Any hint where I can find a solution to that :)

Hi, I'm a little late, but I had the same problem and I found the solution! By looking at the error in the code, I understood that it was the presence of 'chunks' that was causing the issue. 'Chunks' are divisions made in your .tmx file to handle large maps. Your map is probably set to 'infinite'; try exporting it with a fixed size, and that should solve your problem!

wiredmatt commented 10 months ago

For anyone looking for another example on how to use the alpha package: GameBased/mystery-island#20

Using that exact config worked perfectly.

<ItemGroup>
    <PackageReference Include="MonoGame.Extended" Version="3.9.0-alpha0093" />
    <PackageReference Include="MonoGame.Extended.Collisions" Version="3.9.0-alpha0093" />
    <PackageReference Include="MonoGame.Extended.Content.Pipeline" Version="3.9.0-alpha0093" />
    <PackageReference Include="MonoGame.Extended.Input" Version="3.9.0-alpha0093" />
    <PackageReference Include="MonoGame.Extended.Tiled" Version="3.9.0-alpha0093" />
    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
  </ItemGroup>
AristurtleDev commented 6 months ago

This issue was caused due to the removal of Color.TransparentBlack in MonoGame 3.8.1.303. This is no longer an issue in develop since it has been updated to the latest MonoGame version.

Until the MonoGame.Extended v4.0.0 release you can use one of the following workaround

  1. Use the source code of MonoGame.Extended directly and reference it in your project
  2. Use the most recent (at the time of writing this) prerelease NuGet https://www.nuget.org/packages/MonoGame.Extended/3.9.0-prerelease.4