From 649557e404ac1e34ad203b7affe6728918f83471 Mon Sep 17 00:00:00 2001 From: shahabhijeet Date: Sun, 26 Feb 2017 18:40:52 -0800 Subject: [PATCH] Ability to publish netCore packages when package names are provided without scope. Helps in publishing packages from multiple scopes. Added tests for publishing packages. Disabling publishing nuget packages for the entire repo if scope or package name is not specifiied Picking all nonAutoRest library projects Making sure nonAutoRest library nuget spec are available when package names are provided --- build.proj | 22 ++++- .../PublishNugetPackageTests.proj | 98 +++++++++++++++---- .../DebugTask.cs | 2 +- .../FilterOutAutoRestLibraries.cs | 27 ++++- tools/nuget.targets | 5 +- 5 files changed, 124 insertions(+), 30 deletions(-) diff --git a/build.proj b/build.proj index e8dbdb2ea67f1..a749608acc2f0 100644 --- a/build.proj +++ b/build.proj @@ -65,7 +65,7 @@ - + @@ -121,19 +121,31 @@ - + + + + - + + + - + + + + + + + - + diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetPackageTests.proj b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetPackageTests.proj index 0863cb32e7793..c662f2e6d2239 100644 --- a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetPackageTests.proj +++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetPackageTests.proj @@ -24,7 +24,26 @@ - + + + + + + + + + + + + + + + + + + + MultiProjectMultiSln @@ -56,26 +75,36 @@ - - - - - - - - - - - - - - - - - - - + + + + + + RP1_MgmtPlane + + + + + + + + + + RP1_MgmtPlane NetCoreTestPublish + + + + + + + + MultiProjectSingleSln + RP1_MgmtPlane NetCoreTestPublish + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/DebugTask.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/DebugTask.cs index 36729e3cd6572..a3494ed3c2e8f 100644 --- a/tools/Microsoft.WindowsAzure.Build.Tasks/DebugTask.cs +++ b/tools/Microsoft.WindowsAzure.Build.Tasks/DebugTask.cs @@ -17,7 +17,7 @@ public class DebugTask : Microsoft.Build.Utilities.Task /// /// Default timeout /// - const int DEFAULT_TASK_TIMEOUT = 20000; + const int DEFAULT_TASK_TIMEOUT = 30000; /// /// Task Timeout diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/FilterOutAutoRestLibraries.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/FilterOutAutoRestLibraries.cs index f9cde92f11809..d0c16b437b7c7 100644 --- a/tools/Microsoft.WindowsAzure.Build.Tasks/FilterOutAutoRestLibraries.cs +++ b/tools/Microsoft.WindowsAzure.Build.Tasks/FilterOutAutoRestLibraries.cs @@ -12,6 +12,9 @@ namespace Microsoft.WindowsAzure.Build.Tasks { public class FilterOutAutoRestLibraries : Task { + [Required] + public ITaskItem[] SdkNugetPackageInput { get; set; } + [Required] public ITaskItem[] AllLibraries { get; set; } @@ -37,6 +40,9 @@ public class FilterOutAutoRestLibraries : Task [Output] public ITaskItem[] NetCore_AutoRestLibraries { get; private set; } + [Output] + public ITaskItem[] SdkNuGetPackageOutput { get; private set; } + public override bool Execute() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); @@ -50,15 +56,32 @@ public override bool Execute() var nonNetCoreAutoRestLibraries = new List(); var netCoreAutoRestLibraries = new List(); var netCoreLibraryTestOnes = new List(); + var SdkNuGetPackage = new List(); var others = new List(); List nPkgsList = null; + List sdkItemSpec = (from item in SdkNugetPackageInput select item.ItemSpec).ToList(); if (!string.IsNullOrWhiteSpace(NugetPackagesToPublish)) { nPkgsList = NugetPackagesToPublish.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + if(nPkgsList != null) + { + List common = nPkgsList.Intersect(sdkItemSpec).ToList(); + foreach(string projName in common) + { + ITaskItem nProj = SdkNugetPackageInput.Where((item) => item.ItemSpec.Equals(projName, StringComparison.OrdinalIgnoreCase)).First(); + if (nProj != null) + SdkNuGetPackage.Add(nProj); + } + } + else + { + SdkNuGetPackage = SdkNugetPackageInput.ToList(); + } + foreach (ITaskItem solution in AllLibraries) { bool isAutoRestLibrary = false; @@ -169,10 +192,12 @@ public override bool Execute() Log.LogMessage(MessageImportance.High, "We have found {0} non netcore autorest libraries.", nonNetCoreAutoRestLibraries.Count); Log.LogMessage(MessageImportance.High, "We have found {0} netcore autorest libraries.", netCoreAutoRestLibraries.Count); - Log.LogMessage(MessageImportance.High, "we have found {0} Non autorest libraries.", others.Count); + Log.LogMessage(MessageImportance.High, "We have found {0} Non autorest libraries.", others.Count); + Log.LogMessage(MessageImportance.High, "We have found {0} SdkNuget Packages.", SdkNuGetPackage.Count); Non_NetCore_AutoRestLibraries = nonNetCoreAutoRestLibraries.ToArray(); NetCore_AutoRestLibraries = netCoreAutoRestLibraries.ToArray(); NonAutoRestLibraries = others.ToArray(); + SdkNuGetPackageOutput = SdkNuGetPackage.ToArray(); return true; } } diff --git a/tools/nuget.targets b/tools/nuget.targets index b593d1ebe0262..877c3240bc0a7 100644 --- a/tools/nuget.targets +++ b/tools/nuget.targets @@ -75,6 +75,7 @@ + @@ -82,7 +83,7 @@ Build NuGet packages --> - + - +