Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 98472cf

Browse files
committed
Merge other targets files after the main xbd targets
1 parent e723a51 commit 98472cf

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

build.cake

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -368,28 +368,6 @@ Task ("nuget-setup").IsDependentOn ("buildtasks").Does (() => {
368368
var targetsFile = new FilePath(string.Format ("{0}/nuget/{1}.targets", aar.Path, aar.NugetId));
369369
FileWriteText (targetsFile, targetsText);
370370

371-
// Check for an existing .targets file in this nuget package
372-
// we need to merge the generated one with it if it exists
373-
// nuget only allows one automatic .targets file in the build/ folder
374-
// of the nuget package, which must be named {nuget-package-id}.targets
375-
// so we need to merge them all into one
376-
var mergeFile = new FilePath (aar.Path + "/nuget/merge.targets");
377-
378-
if (FileExists (mergeFile)) {
379-
Information ("merge.targets found, merging into generated file...");
380-
381-
// Load the doc to append to, and the doc to append
382-
var xOrig = System.Xml.Linq.XDocument.Load (MakeAbsolute(targetsFile).FullPath);
383-
System.Xml.Linq.XNamespace nsOrig = xOrig.Root.Name.Namespace;
384-
var xMerge = System.Xml.Linq.XDocument.Load (MakeAbsolute(mergeFile).FullPath);
385-
System.Xml.Linq.XNamespace nsMerge = xMerge.Root.Name.Namespace;
386-
// Add all the elements under <Project> into the existing file's <Project> node
387-
foreach (var xItemToAdd in xMerge.Element (nsMerge + "Project").Elements ())
388-
xOrig.Element (nsOrig + "Project").Add (xItemToAdd);
389-
390-
xOrig.Save (MakeAbsolute (targetsFile).FullPath);
391-
}
392-
393371
// Merge each generated targets file into one main one
394372
// this makes one file to import into our actual binding projects
395373
// which is much easier/less maintenance
@@ -416,6 +394,28 @@ Task ("nuget-setup").IsDependentOn ("buildtasks").Does (() => {
416394
}
417395

418396
xFileRoot.Save ("./generated.targets");
397+
398+
// Check for an existing .targets file in this nuget package
399+
// we need to merge the generated one with it if it exists
400+
// nuget only allows one automatic .targets file in the build/ folder
401+
// of the nuget package, which must be named {nuget-package-id}.targets
402+
// so we need to merge them all into one
403+
var mergeFile = new FilePath (aar.Path + "/nuget/merge.targets");
404+
405+
if (FileExists (mergeFile)) {
406+
Information ("merge.targets found, merging into generated file...");
407+
408+
// Load the doc to append to, and the doc to append
409+
var xOrig = System.Xml.Linq.XDocument.Load (MakeAbsolute(targetsFile).FullPath);
410+
System.Xml.Linq.XNamespace nsOrig = xOrig.Root.Name.Namespace;
411+
var xMerge = System.Xml.Linq.XDocument.Load (MakeAbsolute(mergeFile).FullPath);
412+
System.Xml.Linq.XNamespace nsMerge = xMerge.Root.Name.Namespace;
413+
// Add all the elements under <Project> into the existing file's <Project> node
414+
foreach (var xItemToAdd in xMerge.Element (nsMerge + "Project").Elements ())
415+
xOrig.Element (nsOrig + "Project").Add (xItemToAdd);
416+
417+
xOrig.Save (MakeAbsolute (targetsFile).FullPath);
418+
}
419419
}
420420
});
421421

0 commit comments

Comments
 (0)