Title
MGFX shader built in shared GameLib project causes platform mismatch at runtime in Windows project
Description
I am encountering a platform compatibility issue when building .fx (MGFX) shaders inside a shared GameLib project and then running the game from a Windows-specific project.
Issue
The shader is compiled in the GameLib project via the Content Pipeline, and the Windows project references this compiled content. However, at runtime, the following error occurs:
This MGFX effect was built for a different platform!
Details
-
The
.fxfile is included and built in the shared GameLib project -
The Windows project references GameLib and runs the game
-
MGCB is invoked during the Windows build with
/platform:Windows -
However, the shader appears to have been previously built (or cached) for a different platform (e.g., DesktopGL)
This suggests that:
-
Content built in a shared project is not properly isolated per platform
-
Intermediate or output files may be reused across different platform builds
Observations
-
The same
.fxfile works correctly when rebuilt cleanly for the target platform -
The issue is more likely to occur when:
-
switching between DesktopGL and Windows
-
sharing Content across multiple projects
-
not cleaning
bin/objdirectories
-
Expected Behavior
-
Content built for one platform should not be reused for another platform
-
The pipeline should either:
-
isolate outputs per platform reliably
-
or warn when mismatched content is being loaded
-
Suggested Improvements
-
Better separation of platform-specific content outputs in multi-project setups
-
Automatic invalidation of cached MGFX binaries when platform changes
-
Clearer diagnostics indicating which platform the shader was built for
Summary
Building MGFX shaders in a shared GameLib project and consuming them from a platform-specific project (Windows) can lead to platform mismatch issues due to reused or improperly separated content outputs.