diff --git a/animated-vector-drawable/nuget/template.nuspec b/animated-vector-drawable/nuget/template.nuspec index bda07817..1e6b75a2 100644 --- a/animated-vector-drawable/nuget/template.nuspec +++ b/animated-vector-drawable/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/appcompat-v7/nuget/template.nuspec b/appcompat-v7/nuget/template.nuspec index 65da8a01..3516328f 100644 --- a/appcompat-v7/nuget/template.nuspec +++ b/appcompat-v7/nuget/template.nuspec @@ -26,6 +26,8 @@ + + diff --git a/build.cake b/build.cake index 808e295e..f21f0571 100644 --- a/build.cake +++ b/build.cake @@ -300,6 +300,95 @@ Task ("component-setup").Does (() => } }); + +Task ("nuget-setup").IsDependentOn ("buildtasks").IsDependentOn ("externals") + .Does (() => +{ + + Action mergeTargetsFiles = (FilePath fromFile, FilePath intoFile) => + { + // Load the doc to append to, and the doc to append + var xOrig = System.Xml.Linq.XDocument.Load (MakeAbsolute(intoFile).FullPath); + System.Xml.Linq.XNamespace nsOrig = xOrig.Root.Name.Namespace; + var xMerge = System.Xml.Linq.XDocument.Load (MakeAbsolute(fromFile).FullPath); + System.Xml.Linq.XNamespace nsMerge = xMerge.Root.Name.Namespace; + // Add all the elements under into the existing file's node + foreach (var xItemToAdd in xMerge.Element (nsMerge + "Project").Elements ()) + xOrig.Element (nsOrig + "Project").Add (xItemToAdd); + + xOrig.Save (MakeAbsolute (intoFile).FullPath); + }; + + var templateText = FileReadText ("./template.targets"); + + var nugetArtifacts = ARTIFACTS.ToList (); + nugetArtifacts.Add (new ArtifactInfo (SUPPORT_PKG_NAME, "support-v4", "Xamarin.Android.Support.v4", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION)); + + foreach (var art in nugetArtifacts) { + + var proguardFile = new FilePath(string.Format("./externals/{0}/proguard.txt", art.ArtifactId)); + + var targetsText = templateText; + var targetsFile = new FilePath(string.Format ("{0}/nuget/{1}.targets", art.ArtifactId, art.NugetId)); + FileWriteText (targetsFile, targetsText); + + // Transform all .targets files + var xTargets = System.Xml.Linq.XDocument.Load (MakeAbsolute(targetsFile).FullPath); + System.Xml.Linq.XNamespace nsTargets = xTargets.Root.Name.Namespace; + + if (FileExists (proguardFile)) { + var projElem = xTargets.Element(nsTargets + "Project"); + + Information ("Adding {0} to {1}", "proguard.txt", targetsFile); + + projElem.Add (new System.Xml.Linq.XElement (nsTargets + "ItemGroup", + new System.Xml.Linq.XElement (nsTargets + "ProguardConfiguration", + new System.Xml.Linq.XAttribute ("Include", "$(MSBuildThisFileDirectory)..\\..\\proguard\\proguard.txt")))); + } + + xTargets.Save (MakeAbsolute(targetsFile).FullPath); + + // Check for an existing .targets file in this nuget package + // we need to merge the generated one with it if it exists + // nuget only allows one automatic .targets file in the build/ folder + // of the nuget package, which must be named {nuget-package-id}.targets + // so we need to merge them all into one + var mergeFile = new FilePath (art.ArtifactId + "/nuget/merge.targets"); + + if (FileExists (mergeFile)) { + Information ("merge.targets found, merging into generated file..."); + mergeTargetsFiles (mergeFile, targetsFile); + } + + + // Transform all template.nuspec files + var nuspecText = FileReadText(art.ArtifactId + "/nuget/template.nuspec"); + //nuspecText = nuspecText.Replace ("$xbdversion$", XBD_VERSION); + var nuspecFile = new FilePath(art.ArtifactId + "/nuget/" + art.NugetId + ".nuspec"); + FileWriteText(nuspecFile, nuspecText); + var xNuspec = System.Xml.Linq.XDocument.Load (MakeAbsolute(nuspecFile).FullPath); + System.Xml.Linq.XNamespace nsNuspec = xNuspec.Root.Name.Namespace; + + // Check if we have a proguard.txt file for this artifact and include it in the nuspec if so + if (FileExists (proguardFile)) { + Information ("Adding {0} to {1}", "proguard.txt", nuspecFile); + var filesElems = xNuspec.Root.Descendants (nsNuspec + "files"); + + if (filesElems != null) { + var filesElem = filesElems.First(); + filesElem.Add (new System.Xml.Linq.XElement (nsNuspec + "file", + new System.Xml.Linq.XAttribute(nsNuspec + "src", proguardFile.ToString()), + new System.Xml.Linq.XAttribute(nsNuspec + "target", "proguard/proguard.txt"))); + } + } + + xNuspec.Save(MakeAbsolute(nuspecFile).FullPath); + } +}); + +Task ("nuget").IsDependentOn ("nuget-setup").IsDependentOn ("nuget-base").IsDependentOn ("libs"); + + Task ("component").IsDependentOn ("component-docs").IsDependentOn ("component-setup").IsDependentOn ("component-base").IsDependentOn ("libs"); Task ("clean").IsDependentOn ("clean-base").Does (() => diff --git a/cardview-v7/nuget/template.nuspec b/cardview-v7/nuget/template.nuspec index ab7177d5..865a4626 100644 --- a/cardview-v7/nuget/template.nuspec +++ b/cardview-v7/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/customtabs/nuget/template.nuspec b/customtabs/nuget/template.nuspec index 97c956ce..a760add6 100644 --- a/customtabs/nuget/template.nuspec +++ b/customtabs/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/design/nuget/template.nuspec b/design/nuget/template.nuspec index cf7d22f6..e0014271 100644 --- a/design/nuget/template.nuspec +++ b/design/nuget/template.nuspec @@ -28,6 +28,8 @@ + + diff --git a/exifinterface/nuget/template.nuspec b/exifinterface/nuget/template.nuspec index b0ddb4b3..c03354d8 100644 --- a/exifinterface/nuget/template.nuspec +++ b/exifinterface/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/gridlayout-v7/nuget/template.nuspec b/gridlayout-v7/nuget/template.nuspec index d9a50696..2d7e3229 100644 --- a/gridlayout-v7/nuget/template.nuspec +++ b/gridlayout-v7/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/leanback-v17/nuget/template.nuspec b/leanback-v17/nuget/template.nuspec index 45bd62a7..a54a899d 100644 --- a/leanback-v17/nuget/template.nuspec +++ b/leanback-v17/nuget/template.nuspec @@ -25,6 +25,8 @@ + + diff --git a/mediarouter-v7/nuget/template.nuspec b/mediarouter-v7/nuget/template.nuspec index 32e5f53a..44d97c1c 100644 --- a/mediarouter-v7/nuget/template.nuspec +++ b/mediarouter-v7/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/palette-v7/nuget/template.nuspec b/palette-v7/nuget/template.nuspec index 49499e7e..23aec7d8 100644 --- a/palette-v7/nuget/template.nuspec +++ b/palette-v7/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/percent/nuget/template.nuspec b/percent/nuget/template.nuspec index 2bf9ec9f..db52b2dd 100644 --- a/percent/nuget/template.nuspec +++ b/percent/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/preference-leanback-v17/nuget/template.nuspec b/preference-leanback-v17/nuget/template.nuspec index 2fb0888e..c4ff3bc5 100644 --- a/preference-leanback-v17/nuget/template.nuspec +++ b/preference-leanback-v17/nuget/template.nuspec @@ -29,6 +29,8 @@ + + diff --git a/preference-v14/nuget/template.nuspec b/preference-v14/nuget/template.nuspec index 61a36d0f..ca494f0d 100644 --- a/preference-v14/nuget/template.nuspec +++ b/preference-v14/nuget/template.nuspec @@ -27,6 +27,8 @@ + + diff --git a/preference-v7/nuget/template.nuspec b/preference-v7/nuget/template.nuspec index cdb533f9..c8ca6ea3 100644 --- a/preference-v7/nuget/template.nuspec +++ b/preference-v7/nuget/template.nuspec @@ -26,6 +26,8 @@ + + diff --git a/recommendation/nuget/template.nuspec b/recommendation/nuget/template.nuspec index af519ef5..a4ccec7c 100644 --- a/recommendation/nuget/template.nuspec +++ b/recommendation/nuget/template.nuspec @@ -24,6 +24,8 @@ + + diff --git a/recyclerview-v7/nuget/template.nuspec b/recyclerview-v7/nuget/template.nuspec index 5965a50e..28ac93bf 100644 --- a/recyclerview-v7/nuget/template.nuspec +++ b/recyclerview-v7/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/renderscript-v8/nuget/template.nuspec b/renderscript-v8/nuget/template.nuspec index 14952d88..7e680c86 100644 --- a/renderscript-v8/nuget/template.nuspec +++ b/renderscript-v8/nuget/template.nuspec @@ -14,6 +14,8 @@ https://raw.githubusercontent.com/xamarin/AndroidSupportComponents/master/icons/v8-renderscript_128x128.png + + diff --git a/support-annotations/nuget/template.nuspec b/support-annotations/nuget/template.nuspec index 3e2e3662..1c70c9a3 100644 --- a/support-annotations/nuget/template.nuspec +++ b/support-annotations/nuget/template.nuspec @@ -14,6 +14,8 @@ https://raw.githubusercontent.com/xamarin/AndroidSupportComponents/master/icons/support-annotations_128x128.png + + diff --git a/support-compat/nuget/template.nuspec b/support-compat/nuget/template.nuspec index c7f38523..7170481e 100644 --- a/support-compat/nuget/template.nuspec +++ b/support-compat/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/support-core-ui/nuget/template.nuspec b/support-core-ui/nuget/template.nuspec index 2cf3f369..0b39ef26 100644 --- a/support-core-ui/nuget/template.nuspec +++ b/support-core-ui/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/support-core-utils/nuget/template.nuspec b/support-core-utils/nuget/template.nuspec index 0a7f799e..bb16cd1f 100644 --- a/support-core-utils/nuget/template.nuspec +++ b/support-core-utils/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/support-dynamic-animation/nuget/template.nuspec b/support-dynamic-animation/nuget/template.nuspec index 4aec1fec..92ca5b6c 100644 --- a/support-dynamic-animation/nuget/template.nuspec +++ b/support-dynamic-animation/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/support-emoji-appcompat/nuget/template.nuspec b/support-emoji-appcompat/nuget/template.nuspec index 7108b3f6..7f86cffc 100644 --- a/support-emoji-appcompat/nuget/template.nuspec +++ b/support-emoji-appcompat/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/support-emoji-bundled/nuget/template.nuspec b/support-emoji-bundled/nuget/template.nuspec index b5bdae34..eebc202c 100644 --- a/support-emoji-bundled/nuget/template.nuspec +++ b/support-emoji-bundled/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/support-emoji/nuget/template.nuspec b/support-emoji/nuget/template.nuspec index 65777a28..0fbb6680 100644 --- a/support-emoji/nuget/template.nuspec +++ b/support-emoji/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/support-fragment/nuget/template.nuspec b/support-fragment/nuget/template.nuspec index a3aa402a..888a4e77 100644 --- a/support-fragment/nuget/template.nuspec +++ b/support-fragment/nuget/template.nuspec @@ -22,6 +22,8 @@ + + diff --git a/support-media-compat/nuget/template.nuspec b/support-media-compat/nuget/template.nuspec index c6dd2cf7..23ed7e2c 100644 --- a/support-media-compat/nuget/template.nuspec +++ b/support-media-compat/nuget/template.nuspec @@ -19,6 +19,8 @@ + + diff --git a/support-tv-provider/nuget/template.nuspec b/support-tv-provider/nuget/template.nuspec index 1ce57c20..b00beec0 100644 --- a/support-tv-provider/nuget/template.nuspec +++ b/support-tv-provider/nuget/template.nuspec @@ -20,6 +20,8 @@ + + diff --git a/support-v13/nuget/template.nuspec b/support-v13/nuget/template.nuspec index cb9d2686..62a41821 100644 --- a/support-v13/nuget/template.nuspec +++ b/support-v13/nuget/template.nuspec @@ -24,6 +24,8 @@ + + diff --git a/support-v4/nuget/template.nuspec b/support-v4/nuget/template.nuspec index abb9bb9b..f9111e52 100644 --- a/support-v4/nuget/template.nuspec +++ b/support-v4/nuget/template.nuspec @@ -23,6 +23,8 @@ + + diff --git a/support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj b/support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj index e506e284..428060d8 100644 --- a/support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj +++ b/support-vector-drawable/buildtask/Vector-Drawable-BuildTasks.csproj @@ -39,8 +39,8 @@ - - template.targets + + merge.targets PreserveNewest diff --git a/support-vector-drawable/nuget/template.targets b/support-vector-drawable/nuget/merge.targets similarity index 100% rename from support-vector-drawable/nuget/template.targets rename to support-vector-drawable/nuget/merge.targets diff --git a/support-vector-drawable/nuget/template.nuspec b/support-vector-drawable/nuget/template.nuspec index 52eeeb32..9cd29d2e 100644 --- a/support-vector-drawable/nuget/template.nuspec +++ b/support-vector-drawable/nuget/template.nuspec @@ -20,7 +20,7 @@ - + diff --git a/transition/nuget/template.nuspec b/transition/nuget/template.nuspec index 22c12d6e..bcdbd32c 100644 --- a/transition/nuget/template.nuspec +++ b/transition/nuget/template.nuspec @@ -24,6 +24,8 @@ + + diff --git a/wear/nuget/template.nuspec b/wear/nuget/template.nuspec index 5b4c82c5..0afe5d54 100644 --- a/wear/nuget/template.nuspec +++ b/wear/nuget/template.nuspec @@ -20,6 +20,8 @@ + +