nugetprojectjson icon indicating copy to clipboard operation
nugetprojectjson copied to clipboard

XML error

Open 2E0PGS opened this issue 5 years ago • 6 comments

Hi I get the following XML error. Wonder if someone knows what this could be. Otherwise in the meantime I will try debug it a bit.

EnsureNuGetPackageBuildImports target found:
Setting ToolsVersion to 14.0
Reference Nodes found:
0
$itemGroupNoneNode found:
2
packages.config Nodes found:
0
EnsureNuGetPackageBuildImports target found:
Setting ToolsVersion to 14.0
Reference Nodes found:
0
$itemGroupNoneNode found:
0
Adding ItemGroup for None Nodes
2
packages.config Nodes found:
0
EnsureNuGetPackageBuildImports target found:
Adding TargetFrameworkProfile node for PropertyGroup
Name            : #text
LocalName       : #text
NodeType        : Text
ParentNode      : PlatformTarget
Value           : AnyCPU
PreviousText    :
InnerText       : AnyCPU
Data            : AnyCPU
Length          : 6
PreviousSibling :
NextSibling     :
ChildNodes      : {}
Attributes      :
OwnerDocument   : #document
FirstChild      :
LastChild       :
HasChildNodes   : False
NamespaceURI    :
Prefix          :
IsReadOnly      : False
OuterXml        : AnyCPU
InnerXml        :
SchemaInfo      : System.Xml.Schema.XmlSchemaInfo
BaseURI         :

Adding PlatformTarget node for PropertyGroup
Setting ToolsVersion to 14.0
Reference Nodes found:
0
$itemGroupNoneNode found:
0
Adding ItemGroup for None Nodes
6
Exception calling "InsertAfter" with "2" argument(s): "The reference node is not a child of this node."
At C:\REDACTEDFORPRIVACY\create_project_json.ps1:74 char:3
+         [void]$proj.DocumentElement.InsertAfter($itemGroupNoneNode,$i ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

packages.config Nodes found:
0
EnsureNuGetPackageBuildImports target found:
Adding TargetFrameworkProfile node for PropertyGroup
Name            : #text
LocalName       : #text
NodeType        : Text
ParentNode      : PlatformTarget
Value           : AnyCPU
PreviousText    :
InnerText       : AnyCPU
Data            : AnyCPU
Length          : 6
PreviousSibling :
NextSibling     :
ChildNodes      : {}
Attributes      :
OwnerDocument   : #document
FirstChild      :
LastChild       :
HasChildNodes   : False
NamespaceURI    :
Prefix          :
IsReadOnly      : False
OuterXml        : AnyCPU
InnerXml        :
SchemaInfo      : System.Xml.Schema.XmlSchemaInfo
BaseURI         :

Adding PlatformTarget node for PropertyGroup
Setting ToolsVersion to 14.0
Reference Nodes found:
5
$itemGroupNoneNode found:
1
packages.config Nodes found:
1
EnsureNuGetPackageBuildImports target found:
Adding None node for project.json
Name            : #text
LocalName       : #text
NodeType        : Text
ParentNode      : PlatformTarget
Value           : AnyCPU
PreviousText    :
InnerText       : AnyCPU
Data            : AnyCPU
Length          : 6
PreviousSibling :
NextSibling     :
ChildNodes      : {}
Attributes      :
OwnerDocument   : #document
FirstChild      :
LastChild       :
HasChildNodes   : False
NamespaceURI    :
Prefix          :
IsReadOnly      : False
OuterXml        : AnyCPU
InnerXml        :
SchemaInfo      : System.Xml.Schema.XmlSchemaInfo
BaseURI         :

Adding PlatformTarget node for PropertyGroup

2E0PGS avatar Jun 07 '19 14:06 2E0PGS

This script works fine on one solution of mine but it doesn't like a couple others which are bigger and older. I need to study the XML a bit and see what could be causing the issue.

2E0PGS avatar Jun 07 '19 14:06 2E0PGS

Added a debugging line $CsProjFilePath to end of output: Write-Output 'Adding ItemGroup for None Nodes in project: ' $CsProjFilePath so I know if its a specific projects XML.

Seems to be one specific project causing the issue in the solution so going to check its csproj now.

2E0PGS avatar Jun 07 '19 14:06 2E0PGS

Forgot to update but i found the offending project. Luckily it was old hat and surplus to requirement. I will probably run into this issue again on another project so will try narrow down which XML tag it didnt like.

2E0PGS avatar Jun 10 '19 09:06 2E0PGS

It looks like if a project in a soltuion doesn't have any nuget packages referenced it doesn't have this XML in the csproj and causes the script to except.

Perhaps it should check and skip projects like this which don't need migrating. Otherwise it will try modify other parts of the project and leave it in a unclean state.

  <ItemGroup>
    <None Include="app.config" />
    <None Include="packages.config" />
  </ItemGroup>

2E0PGS avatar Jun 12 '19 11:06 2E0PGS

I am quit suprised that someone is still using this :). You are converting to project.json format even though that is also deprecated by now?

wgtmpeters avatar Jun 12 '19 11:06 wgtmpeters

Yeah adding that into a project without it, it no longer excepts.

Yes I have a specific use case for it. I am however aware they are now trying to move to csproj PackageReference but this isn't ready for .NET Framework MVC projects yet.

2E0PGS avatar Jun 12 '19 11:06 2E0PGS