Yesterday my project was compiling normally, today I updated Visual Studio and now I’m getting a compile error for the Content Builder.
The command “dotnet “” /quiet /@:“M:\Documents\Projects\Farm\Farm\Content\Content.mgcb” /platform:DesktopGL /outputDir:“M:/Documents/Projects/Farm/Farm/Content/bin/DesktopGL/Content” /intermediateDir:“M:/Documents/Projects/Farm/Farm/Content/obj/DesktopGL/net7.0/Content” /workingDir:“M:/Documents/Projects/Farm/Farm/Content/”” exited with code 1.
Here is the offending line
<!-- Execute MGCB from the project directory so we use the correct manifest. -->
<Exec
Condition="'%(ContentReference.FullPath)' != ''"
-> Command="$(DotnetCommand) "$(MGCBPath)" $(MonoGameMGCBAdditionalArguments) /@:"%(ContentReference.FullPath)" /platform:$(MonoGamePlatform) /outputDir:"%(ContentReference.ContentOutputDir)" /intermediateDir:"%(ContentReference.ContentIntermediateOutputDir)" /workingDir:"%(ContentReference.FullDir)""
WorkingDirectory="$(MSBuildProjectDirectory)" />
<ItemGroup>
<ExtraContent
Condition="'%(ContentReference.ContentOutputDir)' != ''"
Include="%(ContentReference.ContentOutputDir)\**\*.*">
<ContentDir>%(ContentReference.ContentDir)</ContentDir>
</ExtraContent>
</ItemGroup>
</Target>
It’s listing all the output directories of the Content.mgcb file and I’ve confirmed that they do indeed exist. I’ve tried rebuilding the Content and then rebuilding the project, no luck. I’ve checked for updates for Monogame and I’m up to date (version 3.8.1.303 for Content.Builder.Task).
A prior fix for this issue I found from several years ago does not work because my Content.Builder.Task.targets already has quotes around the $(MGCBPath) (and I believe it was fixed in the master).
I created a blank new project and am getting the same error.
When I look at the output log I’m not seeing anything that looks particularly helpful
1>------ Build started: Project: Project1, Configuration: Debug Any CPU ------
1>Tool 'dotnet-mgcb' (version '3.8.1.303') was restored. Available commands: mgcb
1>Tool 'dotnet-mgcb-editor' (version '3.8.1.303') was restored. Available commands: mgcb-editor
1>Tool 'dotnet-mgcb-editor-linux' (version '3.8.1.303') was restored. Available commands: mgcb-editor-linux
1>Tool 'dotnet-mgcb-editor-windows' (version '3.8.1.303') was restored. Available commands: mgcb-editor-windows
1>Tool 'dotnet-mgcb-editor-mac' (version '3.8.1.303') was restored. Available commands: mgcb-editor-mac
1>
1>Restore was successful.
1>Unrecognized command or argument '/quiet'.
1>Unrecognized command or argument '/@:M:\Documents\Project1\Project1\Content\Content.mgcb'.
1>Unrecognized command or argument '/platform:DesktopGL'.
1>Unrecognized command or argument '/outputDir:M:/Documents/Project1/Project1/Content/bin/DesktopGL/Content'.
1>Unrecognized command or argument '/intermediateDir:M:/Documents/Project1/Project1/Content/obj/DesktopGL/net6.0/Content'.
1>Unrecognized command or argument '/workingDir:M:/Documents/Project1/Project1/Content/'.
1>
Do you know how I can check where the $(MGCBPath) value isn’t being set?
While I did not fix the error, I did find a solution. I believe when Visual Studio updated it might have changed/reset some paths, as when I went to create a new project the default projects folder was changed. I believe this might have reset the MGCBPath somehow and this is unfortunately something I do not know how to correct. I cleared my Nuget cache and reloaded all the Monogame dependencies which resolved the error on the new project I created while debugging, but the error persisted for the old main project. I opted to simply create a new project and migrate all my classes and content over. This effectively resolved the issue, though I cannot comment on the underlying problem.