Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build Effects on Ubuntu 22.04 in MonoGame 3.8.1 #7905

Open
macabrett opened this issue Aug 11, 2022 · 20 comments
Open

Cannot build Effects on Ubuntu 22.04 in MonoGame 3.8.1 #7905

macabrett opened this issue Aug 11, 2022 · 20 comments
Labels
Linux MacOS Setup Related to setuping a MonoGame project for the first time
Milestone

Comments

@macabrett
Copy link

I can't seem to build Effects on Ubuntu 22.04 in MonoGame 3.8.1. I have deleted my .winemonogame, reinstalled Wine, and re-ran mgfxc_wine_setup.sh (I did all of this today, after the recent fixes to mgfxc_wine_setup.sh).

The shader does build on my Windows PC and it also built on Ubuntu before the upgrade to .NET 6.

I don't get any error message. Here's the entire build output for the project:

1>dotnet tool restore
1>Tool 'dotnet-mgcb' (version '3.8.1.263') was restored. Available commands: mgcb
1>Tool 'dotnet-mgcb-editor' (version '3.8.1.263') was restored. Available commands: mgcb-editor
1>Tool 'dotnet-mgcb-editor-linux' (version '3.8.1.263') was restored. Available commands: mgcb-editor-linux
1>Tool 'dotnet-mgcb-editor-windows' (version '3.8.1.263') was restored. Available commands: mgcb-editor-windows
1>Tool 'dotnet-mgcb-editor-mac' (version '3.8.1.263') was restored. Available commands: mgcb-editor-mac
1>
1>Restore was successful.
1>dotnet mgcb /quiet /@:"/home/brett/Development/Macabre2D/Content/Content.DesktopGL.mgcb" /platform:DesktopGL /outputDir:"/home/brett/Development/Macabre2D/Content/bin/DesktopGL/Content.DesktopGL" /intermediateDir:"/home/brett/Development/Macabre2D/Content/obj/DesktopGL/net6.0/Content.DesktopGL" /workingDir:"/home/brett/Development/Macabre2D/Content/"
1>/home/brett/Development/Macabre2D/Content/Shaders/ColorFill.fx
1>/home/brett/Development/Macabre2D/Content/Shaders/ColorFill.fx: 
1>Skipping /home/brett/Development/Macabre2D/Content/Sprites/Automotons/Walker.png
1>Skipping /home/brett/Development/Macabre2D/Content/Sprites/Background/Railing.png
1>Skipping /home/brett/Development/Macabre2D/Content/Sprites/Environment/Ground.png
1>Skipping /home/brett/Development/Macabre2D/Content/Sprites/Environment/GroundRamp.png
1>/home/brett/.nuget/packages/monogame.content.builder.task/3.8.1.303/build/MonoGame.Content.Builder.Task.targets(142,5): Error MSB3073 : The command "dotnet mgcb /quiet /@:"/home/brett/Development/Macabre2D/Content/Content.DesktopGL.mgcb" /platform:DesktopGL /outputDir:"/home/brett/Development/Macabre2D/Content/bin/DesktopGL/Content.DesktopGL" /intermediateDir:"/home/brett/Development/Macabre2D/Content/obj/DesktopGL/net6.0/Content.DesktopGL" /workingDir:"/home/brett/Development/Macabre2D/Content/"" exited with code 1.
1>------- Finished building project: Macabre2D.Platforms.DesktopGL. Succeeded: False. Errors: 1. Warnings: 0

Here's the shader:

#if OPENGL
    #define SV_POSITION POSITION
    #define VS_SHADERMODEL vs_3_0
    #define PS_SHADERMODEL ps_3_0
#else
    #define VS_SHADERMODEL vs_4_0_level_9_1
    #define PS_SHADERMODEL ps_4_0_level_9_1
#endif
extern float4 Fill;
sampler InputTexture;

float4 MainPS(float2 textureCoordinates: TEXCOORD0): COLOR0
{
    float4 color = tex2D(InputTexture, textureCoordinates);

    if (color.a > 0) 
    {
        return Fill;
    }

    return color;
}

technique ColorFill
{
    pass Pass0
    {
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};

What version of MonoGame does the bug occur on:

  • MonoGame 3.8.1

What operating system are you using:

  • Ubuntu 22.04

What MonoGame platform are you using:

  • DesktopGL
@mrhelmut
Copy link
Contributor

Likely not the cause but you have a version mismatch between the tools and the latest release of MonoGame. Your project uses the 303 build (which is the correct 3.8.1 version) but your tools are on build 263 which has been deprecated and unlisted from nuget due to a critical bug. This is because you created your project with the wrong nuget templates or wrong VS extension. You can upgrade your tools by updating your .config/dotnet-tools.json file.

Your output doesn't tell anything about the error. I would suggest trying to run your shader through 2MGFX manually to get an output.

@swoog
Copy link

swoog commented Aug 11, 2022

Same Error on MacOS (Apple M2). I test to build effects of https://github.com/prime31/Nez/tree/master/DefaultContentSource/effects. But build failed and no error is display.

I have installed .net6 runtime (x64). Tool is 'dotnet-mgcb' (version '3.8.1.303')

@Tacodiva
Copy link
Contributor

Maybe caused by #7898

@macabrett
Copy link
Author

Likely not the cause but you have a version mismatch between the tools and the latest release of MonoGame. Your project uses the 303 build (which is the correct 3.8.1 version) but your tools are on build 263 which has been deprecated and unlisted from nuget due to a critical bug. This is because you created your project with the wrong nuget templates or wrong VS extension. You can upgrade your tools by updating your .config/dotnet-tools.json file.

Your output doesn't tell anything about the error. I would suggest trying to run your shader through 2MGFX manually to get an output.

I updated the .config/dotnet-tools.json file to the 303 build and as you suspected, I am still getting a failed build without error.

Your output doesn't tell anything about the error. I would suggest trying to run your shader through 2MGFX manually to get an output.

I'm unsure how to manually run 2MGFX. Is there a guide somewhere I can follow?

I appreciate the help.

@Apostolique
Copy link
Contributor

There is a guide here: https://docs.monogame.net/articles/tools/mgfxc.html.

@macabrett
Copy link
Author

There is a guide here: https://docs.monogame.net/articles/tools/mgfxc.html.

Running it this way, it also does not compile the shader and there is no error message.

Maybe caused by #7898

I've run the script with both the x86 and x64 dotnet installs and no luck, unfortunately.

@mrhelmut
Copy link
Contributor

Could you try running '''dotnet mgfxc''' on your .fx directly to get a proper output to read?

@mrhelmut mrhelmut added this to the 3.8.2 milestone Sep 18, 2022
@KieranFleckney
Copy link

I have the same issue (running in WSL2 Ubuntu 22.04)
image

Get no meaningful error message when using dotnet mgfxc tool

@mrhelmut
Copy link
Contributor

That's peculiar. Looks like wine fails at some point.

@KieranFleckney
Copy link

I tried to debug the mgfxc tool on Ubuntu and as you say wine is failing to run dotnet tool but I have very little experience with wine. So, I couldn't gather any more information than this.

@mrhelmut
Copy link
Contributor

@harry-cpp would likely know, but without traces it will be hard to figure out.

@KieranFleckney
Copy link

Okay so I have managed to get it too work.

After running (Provided by monogame docs)

wget -qO- https://raw.githubusercontent.com/MonoGame/MonoGame/master/Tools/MonoGame.Effect.Compiler/mgfxc_wine_setup.sh | bash

i run theses commands

cd ~/.winemonogame/drive_c/windows/system32

DOTNET_URL="https://download.visualstudio.microsoft.com/download/pr/44d08222-aaa9-4d35-b24b-d0db03432ab7/52a4eb5922afd19e8e0d03e0dbbb41a0/dotnet-sdk-6.0.302-win-x64.zip"
curl "https://download.visualstudio.microsoft.com/download/pr/44d08222-aaa9-4d35-b24b-d0db03432ab7/52a4eb5922afd19e8e0d03e0dbbb41a0/dotnet-sdk-6.0.302-win-x64.zip" --output "dotnet-sdk.zip"

7z x "dotnet-sdk.zip" -y

rm dotnet-sdk.zip

it just reinstalls dotnet sdk in wine for .winemonogame instance and now running dotnet build in my monogame project build shaders fine.

So, I am unsure if there is an issue with the mgfxc_wine_setup.sh script and how it unpacks the dotnet sdk but I couldn't see anything funky happening.

@BrettStory Could you try this work around and see if it fixes the issue for you too?

@macabrett
Copy link
Author

@KieranFleckney That does fix it for me. Signs seem to point to mgfxc_wine_setup.sh somehow not unpacking the SDK correctly.

@mrhelmut
Copy link
Contributor

Cool to know than it's "just that". If anyone knows has more insights, feel free to keep commenting (I'm very rarely on Linux to check it out myself).

@jphoelz
Copy link

jphoelz commented Oct 16, 2022

@KieranFleckney Fixed it for me, too. Thanks a bunch!

@virtexedge
Copy link

Just want to chime in that this fixed it for me also after upgrading my Ubuntu rig from 20.04 to 22.04. Thanks @KieranFleckney!

@Lojemiru
Copy link

Gonna +rep this, @KieranFleckney's solution worked immediately on my Arch desktop after about an hour of head-bashing on vague error messages leading me here. The issue I was getting fed by mgfxc before the fix was Failed to resolve full path of the current executable [C:\windows\system32\dotnet.exe]; based on this and the fix I would agree that something's going wrong with the extraction in the install script.

@wayne-dillon
Copy link

Hey guys, I'm pretty new to MonoGame and having the same issue on Windows, I tried manually replacing the dotnet package in my program files with the one from the download suggested above but it doesn't seem to have done anything. Can anyone tell me what I'm missing? Do I need to apply the changes somehow?

@KieranFleckney
Copy link

@wayne-dillon this issue was related to people developing on Linux as they use Wine to build. It is very strange you would get this error on Window. All I could suggest is reinstall dotnet via Microsoft website and do fresh install of Monogame too. If the issue still presistes then I would open a new bug report.

@mrhelmut mrhelmut added Linux MacOS Setup Related to setuping a MonoGame project for the first time labels Jan 19, 2024
@mrhelmut
Copy link
Contributor

Please refer to #8124 while this issue is being worked on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux MacOS Setup Related to setuping a MonoGame project for the first time
Projects
None yet
Development

No branches or pull requests

10 participants