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

Commit 249d020

Browse files
committed
brought back the .targets files
We still need them for proguard.txt to ship in the nugets
1 parent ff892fa commit 249d020

File tree

36 files changed

+156
-3
lines changed

36 files changed

+156
-3
lines changed

animated-vector-drawable/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
</dependencies>
2020
</metadata>
2121
<files>
22+
<file src="animated-vector-drawable/nuget/Xamarin.Android.Support.Animated.Vector.Drawable.targets" target="build/MonoAndroid80" />
23+
2224
<file src="output/Xamarin.Android.Support.Animated.Vector.Drawable.dll" target="lib/MonoAndroid80" />
2325

2426
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

appcompat-v7/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
</dependencies>
2727
</metadata>
2828
<files>
29+
<file src="appcompat-v7/nuget/Xamarin.Android.Support.v7.AppCompat.targets" target="build/MonoAndroid80" />
30+
2931
<file src="output/Xamarin.Android.Support.v7.AppCompat.dll" target="lib/MonoAndroid80" />
3032

3133
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

build.cake

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,95 @@ Task ("component-setup").Does (() =>
300300
}
301301
});
302302

303+
304+
Task ("nuget-setup").IsDependentOn ("buildtasks").IsDependentOn ("externals")
305+
.Does (() =>
306+
{
307+
308+
Action<FilePath, FilePath> mergeTargetsFiles = (FilePath fromFile, FilePath intoFile) =>
309+
{
310+
// Load the doc to append to, and the doc to append
311+
var xOrig = System.Xml.Linq.XDocument.Load (MakeAbsolute(intoFile).FullPath);
312+
System.Xml.Linq.XNamespace nsOrig = xOrig.Root.Name.Namespace;
313+
var xMerge = System.Xml.Linq.XDocument.Load (MakeAbsolute(fromFile).FullPath);
314+
System.Xml.Linq.XNamespace nsMerge = xMerge.Root.Name.Namespace;
315+
// Add all the elements under <Project> into the existing file's <Project> node
316+
foreach (var xItemToAdd in xMerge.Element (nsMerge + "Project").Elements ())
317+
xOrig.Element (nsOrig + "Project").Add (xItemToAdd);
318+
319+
xOrig.Save (MakeAbsolute (intoFile).FullPath);
320+
};
321+
322+
var templateText = FileReadText ("./template.targets");
323+
324+
var nugetArtifacts = ARTIFACTS.ToList ();
325+
nugetArtifacts.Add (new ArtifactInfo (SUPPORT_PKG_NAME, "support-v4", "Xamarin.Android.Support.v4", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION));
326+
327+
foreach (var art in nugetArtifacts) {
328+
329+
var proguardFile = new FilePath(string.Format("./externals/{0}/proguard.txt", art.ArtifactId));
330+
331+
var targetsText = templateText;
332+
var targetsFile = new FilePath(string.Format ("{0}/nuget/{1}.targets", art.ArtifactId, art.NugetId));
333+
FileWriteText (targetsFile, targetsText);
334+
335+
// Transform all .targets files
336+
var xTargets = System.Xml.Linq.XDocument.Load (MakeAbsolute(targetsFile).FullPath);
337+
System.Xml.Linq.XNamespace nsTargets = xTargets.Root.Name.Namespace;
338+
339+
if (FileExists (proguardFile)) {
340+
var projElem = xTargets.Element(nsTargets + "Project");
341+
342+
Information ("Adding {0} to {1}", "proguard.txt", targetsFile);
343+
344+
projElem.Add (new System.Xml.Linq.XElement (nsTargets + "ItemGroup",
345+
new System.Xml.Linq.XElement (nsTargets + "ProguardConfiguration",
346+
new System.Xml.Linq.XAttribute ("Include", "$(MSBuildThisFileDirectory)..\\..\\proguard\\proguard.txt"))));
347+
}
348+
349+
xTargets.Save (MakeAbsolute(targetsFile).FullPath);
350+
351+
// Check for an existing .targets file in this nuget package
352+
// we need to merge the generated one with it if it exists
353+
// nuget only allows one automatic .targets file in the build/ folder
354+
// of the nuget package, which must be named {nuget-package-id}.targets
355+
// so we need to merge them all into one
356+
var mergeFile = new FilePath (art.ArtifactId + "/nuget/merge.targets");
357+
358+
if (FileExists (mergeFile)) {
359+
Information ("merge.targets found, merging into generated file...");
360+
mergeTargetsFiles (mergeFile, targetsFile);
361+
}
362+
363+
364+
// Transform all template.nuspec files
365+
var nuspecText = FileReadText(art.ArtifactId + "/nuget/template.nuspec");
366+
//nuspecText = nuspecText.Replace ("$xbdversion$", XBD_VERSION);
367+
var nuspecFile = new FilePath(art.ArtifactId + "/nuget/" + art.NugetId + ".nuspec");
368+
FileWriteText(nuspecFile, nuspecText);
369+
var xNuspec = System.Xml.Linq.XDocument.Load (MakeAbsolute(nuspecFile).FullPath);
370+
System.Xml.Linq.XNamespace nsNuspec = xNuspec.Root.Name.Namespace;
371+
372+
// Check if we have a proguard.txt file for this artifact and include it in the nuspec if so
373+
if (FileExists (proguardFile)) {
374+
Information ("Adding {0} to {1}", "proguard.txt", nuspecFile);
375+
var filesElems = xNuspec.Root.Descendants (nsNuspec + "files");
376+
377+
if (filesElems != null) {
378+
var filesElem = filesElems.First();
379+
filesElem.Add (new System.Xml.Linq.XElement (nsNuspec + "file",
380+
new System.Xml.Linq.XAttribute(nsNuspec + "src", proguardFile.ToString()),
381+
new System.Xml.Linq.XAttribute(nsNuspec + "target", "proguard/proguard.txt")));
382+
}
383+
}
384+
385+
xNuspec.Save(MakeAbsolute(nuspecFile).FullPath);
386+
}
387+
});
388+
389+
Task ("nuget").IsDependentOn ("nuget-setup").IsDependentOn ("nuget-base").IsDependentOn ("libs");
390+
391+
303392
Task ("component").IsDependentOn ("component-docs").IsDependentOn ("component-setup").IsDependentOn ("component-base").IsDependentOn ("libs");
304393

305394
Task ("clean").IsDependentOn ("clean-base").Does (() =>

cardview-v7/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
</dependencies>
2020
</metadata>
2121
<files>
22+
<file src="cardview-v7/nuget/Xamarin.Android.Support.v7.CardView.targets" target="build/MonoAndroid80" />
23+
2224
<file src="output/Xamarin.Android.Support.v7.CardView.dll" target="lib/MonoAndroid80" />
2325

2426
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

customtabs/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
</dependencies>
2020
</metadata>
2121
<files>
22+
<file src="customtabs/nuget/Xamarin.Android.Support.CustomTabs.targets" target="build/MonoAndroid80" />
23+
2224
<file src="output/Xamarin.Android.Support.CustomTabs.dll" target="lib/MonoAndroid80" />
2325

2426
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

design/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
</dependencies>
2929
</metadata>
3030
<files>
31+
<file src="design/nuget/Xamarin.Android.Support.Design.targets" target="build/MonoAndroid80" />
32+
3133
<file src="output/Xamarin.Android.Support.Design.dll" target="lib/MonoAndroid80" />
3234

3335
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

exifinterface/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
</dependencies>
2020
</metadata>
2121
<files>
22+
<file src="exifinterface/nuget/Xamarin.Android.Support.Exif.targets" target="build/MonoAndroid80" />
23+
2224
<file src="output/Xamarin.Android.Support.Exif.dll" target="lib/MonoAndroid80" />
2325

2426
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

gridlayout-v7/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
</dependencies>
2121
</metadata>
2222
<files>
23+
<file src="gridlayout-v7/nuget/Xamarin.Android.Support.v7.GridLayout.targets" target="build/MonoAndroid80" />
24+
2325
<file src="output/Xamarin.Android.Support.v7.GridLayout.dll" target="lib/MonoAndroid80" />
2426

2527
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

leanback-v17/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
</dependencies>
2626
</metadata>
2727
<files>
28+
<file src="leanback-v17/nuget/Xamarin.Android.Support.v17.Leanback.targets" target="build/MonoAndroid80" />
29+
2830
<file src="output/Xamarin.Android.Support.v17.Leanback.dll" target="lib/MonoAndroid80" />
2931

3032
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

mediarouter-v7/nuget/template.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
</dependencies>
2121
</metadata>
2222
<files>
23+
<file src="mediarouter-v7/nuget/Xamarin.Android.Support.v7.MediaRouter.targets" target="build/MonoAndroid80" />
24+
2325
<file src="output/Xamarin.Android.Support.v7.MediaRouter.dll" target="lib/MonoAndroid80" />
2426

2527
<file src="External-Dependency-Info.txt" target="THIRD-PARTY-NOTICES.txt" />

0 commit comments

Comments
 (0)