Repository navigation
Resolve the content builder paths from the build instead of assuming bin/Debug - #62
Merged
SimonDarksideJ merged 1 commit intoSep 23, 2026
Conversation
…bin/Debug BuildContent.targets composed the output and intermediate paths by writing $(ProjectDir) directly in front of $(OutputPath), and pointed at the content builder executable through a hardcoded bin\Debug folder. Both assume the default output layout. With UseArtifactsOutput the SDK makes those two properties absolute and moves the executable under artifacts/bin, so the concatenation produced a doubled path and the Exec call could not find the program, failing with exit code 127 before a single asset was built. Compose the paths with Path.Combine, which returns the second argument when it is already absolute and joins otherwise, and take the executable from the TargetOutputs of the build that has just run.
2 tasks done
SimonDarksideJ
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes MonoGame/MonoGame#9486.
The defect
BuildContent.targetsbuilds two paths by writing$(ProjectDir)straight in front of$(OutputPath)and$(IntermediateOutputPath), and points at the content builder through a hardcodedbin\Debugfolder. Both hold only for the default output layout.With
UseArtifactsOutputthe SDK makes those two properties absolute and moves the executable underartifacts/bin. Measured on a project with and without the property, same SDK:$(OutputPath)bin/Debug/net9.0//src/artifacts/bin/app/debug/$(ProjectDir)$(OutputPath)/src/bin/Debug/net9.0//src//src/artifacts/bin/app/debug/bin\Debug\<builder>So the
Execcall becomes:and the build stops with exit code 127 before a single asset is built.
The change
Paths are composed with
Path.Combine, which returns the second argument when it is already absolute and joins otherwise, so both layouts come out right. Measured on the same project:Path.Combine($(ProjectDir), $(OutputPath))/src/bin/Debug/net9.0//src/artifacts/bin/app/debug/The executable is taken from the
TargetOutputsof theMSBuildtask that has just built the content project, rather than assumed. That also stops depending onAppendTargetFrameworkToOutputPathbeingfalse, which is what madebin\Debug\<name>work until now.The three copies of the file in the templates carry the same two lines, so all three are updated.
Verification
A project generated from
mg2dmgcbstartkit, withUseArtifactsOutputset totrue, built for DesktopVK:exited with code 127.xnbBuild succeeded.xnbThe same test with the default layout succeeds on both, and the resolved command line is byte for byte what it was before, so nothing moves for projects that do not use the artifacts layout.
I also ran it against the reporter's own reproduction,
distantcam/ContentBuilderExample, with the same outcome, and checked that the generated content lands inartifacts/bin/<project>/debug/Contentwhere the game looks for it.One thing worth knowing, unrelated to this fix: the content project is not part of the generated solution, so a plain
dotnet restoredoes not cover it and the first build stops onNETSDK1004until it is restored once. That happens in both layouts. Happy to open a separate issue if you would like it addressed.