@@ -244,6 +244,7 @@ Task ("externals")
244244 MoveFile ( implFile , path + aarDir + "/libs/internal_impl.jar" ) ;
245245 }
246246
247+ CopyFile ( string . Format ( path + "m2repository/com/android/support/support-annotations/{0}/support-annotations-{0}.jar" , AAR_VERSION ) , path + "support-annotations.jar" ) ;
247248 // We get docs a different way now
248249 // // Get android docs
249250 // if (!FileExists (path + "docs.zip")) {
@@ -327,7 +328,23 @@ Task ("component-setup").Does (() =>
327328} ) ;
328329
329330Task ( "nuget-setup" ) . IsDependentOn ( "buildtasks" ) . IsDependentOn ( "externals" )
330- . WithCriteria ( ! FileExists ( "./generated.targets" ) ) . Does ( ( ) => {
331+ . WithCriteria ( ! FileExists ( "./generated.targets" ) ) . Does ( ( ) =>
332+ {
333+
334+ Action < FilePath , FilePath > mergeTargetsFiles = ( FilePath fromFile , FilePath intoFile ) =>
335+ {
336+ // Load the doc to append to, and the doc to append
337+ var xOrig = System . Xml . Linq . XDocument . Load ( MakeAbsolute ( intoFile ) . FullPath ) ;
338+ System . Xml . Linq . XNamespace nsOrig = xOrig . Root . Name . Namespace ;
339+ var xMerge = System . Xml . Linq . XDocument . Load ( MakeAbsolute ( fromFile ) . FullPath ) ;
340+ System . Xml . Linq . XNamespace nsMerge = xMerge . Root . Name . Namespace ;
341+ // Add all the elements under <Project> into the existing file's <Project> node
342+ foreach ( var xItemToAdd in xMerge . Element ( nsMerge + "Project" ) . Elements ( ) )
343+ xOrig . Element ( nsOrig + "Project" ) . Add ( xItemToAdd ) ;
344+
345+ xOrig . Save ( MakeAbsolute ( intoFile ) . FullPath ) ;
346+ } ;
347+
331348 var templateText = FileReadText ( "./template.targets" ) ;
332349
333350 if ( FileExists ( "./generated.targets" ) )
@@ -417,19 +434,20 @@ Task ("nuget-setup").IsDependentOn ("buildtasks").IsDependentOn ("externals")
417434
418435 if ( FileExists ( mergeFile ) ) {
419436 Information ( "merge.targets found, merging into generated file..." ) ;
420-
421- // Load the doc to append to, and the doc to append
422- var xOrig = System . Xml . Linq . XDocument . Load ( MakeAbsolute ( targetsFile ) . FullPath ) ;
423- System . Xml . Linq . XNamespace nsOrig = xOrig . Root . Name . Namespace ;
424- var xMerge = System . Xml . Linq . XDocument . Load ( MakeAbsolute ( mergeFile ) . FullPath ) ;
425- System . Xml . Linq . XNamespace nsMerge = xMerge . Root . Name . Namespace ;
426- // Add all the elements under <Project> into the existing file's <Project> node
427- foreach ( var xItemToAdd in xMerge . Element ( nsMerge + "Project" ) . Elements ( ) )
428- xOrig . Element ( nsOrig + "Project" ) . Add ( xItemToAdd ) ;
429-
430- xOrig . Save ( MakeAbsolute ( targetsFile ) . FullPath ) ;
437+ mergeTargetsFiles ( mergeFile , targetsFile ) ;
431438 }
432439 }
440+
441+ // Support annotations needs merging tool
442+ var annotationsPart = downloadParts . FirstOrDefault ( p => p . LocalPath . EndsWith ( "/support-annotations-" + AAR_VERSION + ".jar" ) ) ;
443+ var annotationsTemplateText = FileReadText ( "./support-annotations/nuget/template.targets" ) ;
444+ annotationsTemplateText = annotationsTemplateText . Replace ( "$AarVersion$" , AAR_VERSION )
445+ . Replace ( "$XbdRangeStart$" , annotationsPart . RangeStart . ToString ( ) )
446+ . Replace ( "$XbdRangeEnd$" , annotationsPart . RangeEnd . ToString ( ) )
447+ . Replace ( "$XbdMd5$" , annotationsPart . Md5 ) ;
448+
449+ FileWriteText ( "./support-annotations/nuget/Xamarin.Android.Support.Annotations.targets" , annotationsTemplateText ) ;
450+ mergeTargetsFiles ( "./support-annotations/nuget/Xamarin.Android.Support.Annotations.targets" , "./generated.targets" ) ;
433451} ) ;
434452
435453Task ( "nuget" ) . IsDependentOn ( "nuget-setup" ) . IsDependentOn ( "nuget-base" ) . IsDependentOn ( "libs" ) ;
0 commit comments