File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,10 +82,10 @@ public void AddItem(string protoFile)
8282 xe3 . InnerText = "MSBuild:Compile" ;
8383 xe2 . AppendChild ( xe3 ) ;
8484
85- var protoBufNode = xd . SelectSingleNode ( "/msbuild:Project/msbuild:ItemGroup/msbuild:ProtoBuf" , xnm ) ;
86- if ( protoBufNode == null )
85+ var protoBufNodes = xd . SelectNodes ( "/msbuild:Project/msbuild:ItemGroup/msbuild:ProtoBuf" , xnm ) ;
86+ if ( protoBufNodes . Count == 0 )
8787 {
88- protoBufNode = xd . CreateElement ( "ItemGroup" , msbuildNS ) ;
88+ var protoBufNode = xd . CreateElement ( "ItemGroup" , msbuildNS ) ;
8989 var itemGroupNodes = xd . SelectNodes ( "/msbuild:Project/msbuild:ItemGroup" , xnm ) ;
9090 if ( itemGroupNodes . Count > 0 )
9191 xd . DocumentElement . InsertAfter ( protoBufNode , itemGroupNodes [ itemGroupNodes . Count - 1 ] ) ;
@@ -94,7 +94,10 @@ public void AddItem(string protoFile)
9494 protoBufNode . AppendChild ( xe2 ) ;
9595 }
9696 else
97- protoBufNode . ParentNode . AppendChild ( xe2 ) ;
97+ {
98+ if ( ! protoBufNodes . Cast < XmlElement > ( ) . Any ( a => a . GetAttribute ( "Include" ) == protoFile ) )
99+ protoBufNodes [ protoBufNodes . Count - 1 ] . ParentNode . AppendChild ( xe2 ) ;
100+ }
98101 }
99102
100103 public void Save ( string projectFile )
You can’t perform that action at this time.
0 commit comments