Godot version:
master
/ 8e8240450edc48f4fb379e593a4ef7f54ab656b7
OS/device including version:
_Manjaro Linux 17.1-rc2_
Issue description:
Whenever I save the project from the editor, it logs a following error message:
modules/mono/editor/csharp_project.cpp:117 - Method/Function Failed.
If I launch the editor from a terminal, I can see more detailed information of the problem as below:
Unhandled Exception:
Microsoft.Build.Exceptions.InvalidProjectFileException: Attribute "Version" is not known on node "PackageReference" [type Microsoft.Build.Construction.ProjectItemElement]. at: /home/fender/workspace/AlleyCat/Alley Cat.csproj (72,6)
at Microsoft.Build.Construction.ProjectElement.LoadAttribute (System.String name, System.String value) [0x0005f] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectItemElement.LoadAttribute (System.String name, System.String value) [0x00080] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectElementContainer.Load (System.Xml.XmlReader reader) [0x00091] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectElementContainer.LoadValue (System.Xml.XmlReader reader) [0x00018] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectElementContainer.Load (System.Xml.XmlReader reader) [0x0009e] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectElementContainer.LoadValue (System.Xml.XmlReader reader) [0x00018] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectElementContainer.Load (System.Xml.XmlReader reader) [0x0009e] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectRootElement.Load (System.Xml.XmlReader reader) [0x00000] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectRootElement.Open (System.String path, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x0000f] in <654565be0438470588cb32d8f896dc6e>:0
at Microsoft.Build.Construction.ProjectRootElement.Open (System.String path) [0x00006] in <654565be0438470588cb32d8f896dc6e>:0
at GodotSharpTools.Project.ProjectUtils.AddItemToProjectChecked (System.String projectPath, System.String itemType, System.String include) [0x0000c] in <14701c1a54e940ccafcd8ac62f6777fc>:0
ERROR: add_item: Method/Function Failed.
At: modules/mono/editor/csharp_project.cpp:117.
It seems that it somehow doesn't recognize the Version
attribute in PackageReference
node in my project file. The offending line reads as follows:
<ItemGroup>
<PackageReference Include="Ensure.That" Version="7.2.1" />
<PackageReference Include="FluentCache.Microsoft.Extensions.Caching.Memory" Version="4.0.0.1" />
<PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.1" />
<PackageReference Include="NETStandard.Library.NETFramework" Version="2.0.0-preview2-25405-01" />
</ItemGroup>
Aside from the error messages, the project seems to build and run without any noticeable problem.
CC @neikeq
Is this still reproducible in the current master branch or latest beta build?
Yes, it is still a valid issue. It's ok to move it to 3.2 as it will take some more time to fix. We need to use the official Microsoft.Build, which we need to build from source as the nuget packages are Windows-only.
As far as I remember, a workaround was to specify the Version as a child element instead of an attribute:
<PackageReference Include="NETStandard.Library">
<Version>2.0.1</Version>
</PackageReference>
Maybe this workaround should be somehow hinted there somewhere?
I also just ran into this same issue on Windows except the project wouldn't even run. Specifying the version in the child element worked.
To anyone with this problem, beware: do not use dotnet restore
, that seems to corrupt the .csproj in some way (I think CRLF or BOM tweaks).
download nuget.exe and do nuget restore
instead.
I stumbled across this while trying to get Tuples working: https://github.com/godotengine/godot/issues/34803#issuecomment-570752688
Using the version workaround for me breaks the project. The project now gives:
editor/editor_node.cpp:5268 - An EditorPlugin build callback failed.
Fixed by #40595 (master
) and #41408 (3.2
).
Most helpful comment
Maybe this workaround should be somehow hinted there somewhere?