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

Error on saving project: Attribute "Version" is not known on node "PackageReference" #15386

Closed
mysticfall opened this issue Jan 6, 2018 · 8 comments
Assignees
Milestone

Comments

@mysticfall
Copy link
Contributor

Godot version:
master / 8e82404

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.

@akien-mga akien-mga added this to the 3.0 milestone Jan 6, 2018
@akien-mga
Copy link
Member

CC @neikeq

@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 24, 2018
mysticfall added a commit to mysticfall/alleycat-godot that referenced this issue Jan 5, 2019
@akien-mga akien-mga modified the milestones: 3.1, 3.2 Feb 23, 2019
@akien-mga
Copy link
Member

Is this still reproducible in the current master branch or latest beta build?

@neikeq
Copy link
Contributor

neikeq commented Feb 23, 2019

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>

@ghost
Copy link

ghost commented Jun 12, 2019

Maybe this workaround should be somehow hinted there somewhere?

@Keelar
Copy link

Keelar commented Jul 18, 2019

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.

@jasonswearingen
Copy link

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: #34803 (comment)

@thorlucas
Copy link

Using the version workaround for me breaks the project. The project now gives:

editor/editor_node.cpp:5268 - An EditorPlugin build callback failed.

@akien-mga
Copy link
Member

Fixed by #40595 (master) and #41408 (3.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants