diff --git a/build.proj b/build.proj
index c11e49de8a065..e3c0abed258f5 100644
--- a/build.proj
+++ b/build.proj
@@ -2,15 +2,15 @@
-
+
-
+
-
-
+
+
diff --git a/src/SDKs/Billing/Billing.Tests/Billing.Tests.csproj b/src/SDKs/Billing/Billing.Tests/Billing.Tests.csproj
index d01af345180fb..03624ca860f18 100644
--- a/src/SDKs/Billing/Billing.Tests/Billing.Tests.csproj
+++ b/src/SDKs/Billing/Billing.Tests/Billing.Tests.csproj
@@ -13,7 +13,6 @@
-
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/Build.Tasks.Tests.csproj b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/Build.Tasks.Tests.csproj
index 7a2cede283219..eeefc7693edaa 100644
--- a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/Build.Tasks.Tests.csproj
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/Build.Tasks.Tests.csproj
@@ -1,7 +1,10 @@
- net46
+ net46
+ True
+ $(OutputPath)
+ true
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetTests/PublishTests.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetTests/PublishTests.cs
new file mode 100644
index 0000000000000..34558dfe925c1
--- /dev/null
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks.Tests/PublishNugetTests/PublishTests.cs
@@ -0,0 +1,192 @@
+using Microsoft.WindowsAzure.Build.Tasks;
+using Microsoft.WindowsAzure.Build.Tasks.ExecProcess;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Build.Tasks.Tests.PublishNugetTests
+{
+
+ public class PublishTests
+ {
+ const string NUGET_PKG_NAME = "Build.Tasks.Tests";
+
+ string _nugetPkgBuiltDir;
+ string _publishToDir;
+
+ public string NugetPkgBuiltDir
+ {
+ get
+ {
+ if(string.IsNullOrEmpty(_nugetPkgBuiltDir))
+ {
+ string codeBasePath = Assembly.GetExecutingAssembly().CodeBase;
+ var uri = new UriBuilder(codeBasePath);
+ string path = Uri.UnescapeDataString(uri.Path);
+ path = Path.GetDirectoryName(path);
+
+ _nugetPkgBuiltDir = Directory.GetParent(path).FullName;
+ }
+
+ return _nugetPkgBuiltDir;
+ }
+ }
+
+ public string PublishToDir
+ {
+ get
+ {
+ return _publishToDir;
+ }
+ }
+
+ public PublishTests()
+ {
+ if(Directory.Exists(NugetPkgBuiltDir))
+ {
+ string pubDir = Path.Combine(NugetPkgBuiltDir, "testPublish");
+ if(!Directory.Exists(pubDir))
+ {
+ Directory.CreateDirectory(pubDir);
+ }
+
+ _publishToDir = pubDir;
+ }
+ }
+
+
+ [Fact]
+ public void PublishSingleNuget()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.NugetPackageName = NUGET_PKG_NAME;
+ pubNug.PublishNugetToPath = PublishToDir;
+
+ pubNug.Execute();
+
+ List statusList = pubNug.NugetPublishStatus;
+
+ foreach(NugetPublishStatus status in statusList)
+ {
+ Assert.Equal(0, status.NugetPublishExitCode);
+ }
+ }
+
+ [Fact]
+ public void NonExistentPublishLocation()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.NugetPackageName = NUGET_PKG_NAME;
+ pubNug.PublishNugetToPath = "http://somelocation";
+ pubNug.SkipSymbolPublishing = true;
+ pubNug.ApiKey = "1234";
+
+ Assert.ThrowsAny(() => pubNug.Execute());
+ }
+
+ [Fact]
+ public void SkipPublishingSymbols()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.NugetPackageName = NUGET_PKG_NAME;
+ pubNug.PublishNugetToPath = PublishToDir;
+ pubNug.SkipSymbolPublishing = true;
+
+ pubNug.Execute();
+
+ List statusList = pubNug.NugetPublishStatus;
+
+ Assert.Equal(1, statusList?.Count);
+
+ foreach (NugetPublishStatus status in statusList)
+ {
+ Assert.Equal(0, status.NugetPublishExitCode);
+ }
+ }
+
+ #region Error Tests
+
+ [Fact]
+ public void PublishWithUnAuthenticatedKey()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.NugetPackageName = NUGET_PKG_NAME;
+ pubNug.PublishNugetToPath = "https://www.nuget.org/api/v2/package/";
+ pubNug.SkipSymbolPublishing = true;
+ pubNug.ApiKey = "1234";
+
+ try
+ {
+ pubNug.Execute();
+ }
+ catch(Exception ex)
+ {
+ if(!ex.Message.Contains("The specified API key is invalid"))
+ {
+ Assert.Equal("The specified API key is invalid", ex.Message);
+ }
+ }
+ }
+
+ [Fact]
+ public void IncorrectNugetExePath()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.NugetPackageName = NUGET_PKG_NAME;
+ pubNug.PublishNugetToPath = PublishToDir;
+ pubNug.SkipSymbolPublishing = true;
+ pubNug.NugetExePath = @"C:\Foo\NoExistantPath\nuget.exe";
+ Assert.ThrowsAny(() => pubNug.Execute());
+ }
+
+ [Fact]
+ public void MissingNugetPackageName()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.PublishNugetToPath = PublishToDir;
+ pubNug.SkipSymbolPublishing = true;
+ Assert.ThrowsAny(() => pubNug.Execute());
+ }
+
+ [Fact]
+ public void PublishAllNugetUnderScope()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.publishAllNugetsUnderScope = true;
+ Assert.Throws(() => pubNug.Execute());
+ }
+
+ [Fact]
+ public void MissingRequiredProperties()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ Assert.ThrowsAny(() => pubNug.Execute());
+ }
+
+ [Fact]
+ public void SkipPublishingCompletely()
+ {
+ PublishSDKNuget pubNug = new PublishSDKNuget();
+ pubNug.PackageOutputPath = NugetPkgBuiltDir;
+ pubNug.NugetPackageName = NUGET_PKG_NAME;
+ pubNug.PublishNugetToPath = PublishToDir;
+ pubNug.SkipSymbolPublishing = true;
+ pubNug.SkipNugetPublishing = true;
+ Assert.Throws(() => pubNug.Execute());
+ }
+
+ #endregion
+ }
+}
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/ExecProcess/NugetExec.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/ExecProcess/NugetExec.cs
new file mode 100644
index 0000000000000..b6d1c15edf1ae
--- /dev/null
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/ExecProcess/NugetExec.cs
@@ -0,0 +1,186 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using Microsoft.WindowsAzure.Build.Tasks.Utilities;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.WindowsAzure.Build.Tasks.ExecProcess
+{
+ public class NugetExec : ShellExec
+ {
+ #region CONST
+ //const string NUGET_PATH = "nuget.exe";
+ //const string NUGET_PUBLISH_URL = "https://www.nuget.org/api/v2/package/";
+ //const string NUGET_SYMBOL_PUBLISH_URL = "nuget.smbsrc.net";
+ //const int NUGET_TIMEOUT = 60; //Seconds
+ //const string DEFAULT_API_KEY = "1234";
+ #endregion
+
+
+ #region Fields
+ string _defaultNugetArgsFormat;
+ //string _apiKey;
+ string _publishToPath;
+ string _publishSymbolToPath;
+ string _nugetExePath;
+ #endregion
+
+
+ public string ApiKey { get; set; }
+ //{
+ // get
+ // {
+ // if(string.IsNullOrEmpty(_apiKey))
+ // {
+ // _apiKey = Constants.NugetDefaults.DEFAULT_API_KEY;
+ // }
+
+ // return _apiKey;
+ // }
+
+ // set
+ // {
+ // _apiKey = value;
+ // }
+ //}
+
+ public string PublishToPath
+ {
+ get
+ {
+ if(string.IsNullOrEmpty(_publishToPath))
+ {
+ _publishToPath = Constants.NugetDefaults.NUGET_PUBLISH_URL;
+ }
+
+ return _publishToPath;
+ }
+
+ set
+ {
+ _publishToPath = value;
+ }
+ }
+
+ public string PublishSymbolToPath
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(_publishToPath))
+ {
+ _publishSymbolToPath = Constants.NugetDefaults.NUGET_SYMBOL_PUBLISH_URL;
+ }
+
+ return _publishSymbolToPath;
+ }
+
+ set
+ {
+ _publishSymbolToPath = value;
+ }
+ }
+
+ public string NugetExePath
+ {
+ get
+ {
+ if(string.IsNullOrEmpty(_nugetExePath))
+ {
+ _nugetExePath = Constants.NugetDefaults.NUGET_PATH;
+ }
+
+ return _nugetExePath;
+ }
+
+ set
+ {
+ _nugetExePath = value;
+ }
+ }
+
+ public bool SkipPublishingNuget { get; set; }
+
+ public bool SkipPublishingSymbols { get; set; }
+
+
+ public NugetExec(string nugetExePath): base(nugetExePath)
+ {
+ _defaultNugetArgsFormat = "push {0} -source {1} -ApiKey {2} -NonInteractive -Timeout {3}";
+ }
+
+ public NugetExec() : this(Constants.NugetDefaults.NUGET_PATH)
+ {
+ //_defaultNugetArgsFormat = "push {0} -source {1} -ApiKey {2} -NonInteractive -Timeout {3}";
+ }
+
+ public NugetPublishStatus Publish(string nupkgPath)
+ {
+ string args = string.Empty;
+ string displayArgs = string.Empty;
+ if(nupkgPath.Contains("symbols"))
+ {
+ args = string.Format("push {0} -source {1} -NonInteractive -Timeout {2} -SymbolSource {3}", nupkgPath, PublishSymbolToPath, Constants.NugetDefaults.NUGET_TIMEOUT, PublishSymbolToPath);
+ displayArgs = string.Format("{0} {1}", NugetExePath, args);
+ }
+ else
+ {
+ args = string.Format(_defaultNugetArgsFormat, nupkgPath, PublishToPath, ApiKey, Constants.NugetDefaults.NUGET_TIMEOUT);
+ displayArgs = string.Format("{0} push {1} -source {2} -ApiKey {3} -NonInteractive -Timeout {4}", NugetExePath, nupkgPath, PublishToPath, "", Constants.NugetDefaults.NUGET_TIMEOUT);
+ }
+
+ int exitCode = ExecuteCommand(args);
+ string output = this.AnalyzeExitCode();
+
+ return new NugetPublishStatus() { NugetPackagePath = nupkgPath, NugetPublishExitCode = exitCode, NugetPublishStatusOutput = output, PublishArgs = displayArgs };
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public List Publish(Tuple nugPkgs)
+ {
+ StringBuilder sb = new StringBuilder();
+ List publishStatusList = new List();
+ NugetPublishStatus nugPubStatus = null;
+
+ // Check if publishing nuget has to be skipped
+ if (SkipPublishingNuget == false)
+ {
+ nugPubStatus = Publish(nugPkgs.Item1);
+ publishStatusList.Add(nugPubStatus);
+ }
+
+ // Check if publishing symbols has to be skipped
+ if (SkipPublishingSymbols == false)
+ {
+ if (nugPubStatus.NugetPublishExitCode == 0)
+ {
+ publishStatusList.Add(Publish(nugPkgs.Item2));
+ }
+ }
+
+ return publishStatusList;
+ }
+ }
+
+ ///
+ /// Structure to get publish status
+ ///
+ public class NugetPublishStatus
+ {
+ public string NugetPackagePath { get; set; }
+
+ public int NugetPublishExitCode { get; set; }
+
+ public string NugetPublishStatusOutput { get; set; }
+
+ public string PublishArgs { get; set; }
+ }
+}
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/ExecProcess/ShellExec.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/ExecProcess/ShellExec.cs
new file mode 100644
index 0000000000000..b0f044a056558
--- /dev/null
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/ExecProcess/ShellExec.cs
@@ -0,0 +1,99 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.WindowsAzure.Build.Tasks.ExecProcess
+{
+ public class ShellExec
+ {
+ #region CONST
+ const int DEFAULT_WAIT_TIMEOUT = 30000; // 30 seconds default timeout
+ //const string COMMAND_ARGS = "push {0} -source {1} -ApiKey {2} -NonInteractive -Timeout {3}";
+ #endregion
+
+
+ #region Fields
+ //Process _shellProc;
+
+ #endregion
+
+ protected int LastExitCode { get; set; }
+
+ ///
+ ///
+ ///
+ public Process ShellProcess { get; protected set; }
+
+ protected ShellExec()
+ {
+ ShellProcess = new Process();
+ }
+
+ public ShellExec(string commandPath): this()
+ {
+ ProcessStartInfo procInfo = new ProcessStartInfo(commandPath);
+ procInfo.CreateNoWindow = true;
+ procInfo.UseShellExecute = false;
+ procInfo.RedirectStandardError = true;
+ procInfo.RedirectStandardInput = true;
+ procInfo.RedirectStandardOutput = true;
+ ShellProcess.StartInfo = procInfo;
+ }
+
+ public virtual int ExecuteCommand(string args)
+ {
+ try
+ {
+ ShellProcess.StartInfo.Arguments = args;
+ ShellProcess.Start();
+ ShellProcess.WaitForExit(DEFAULT_WAIT_TIMEOUT);
+ LastExitCode = ShellProcess.ExitCode;
+ return LastExitCode;
+ }
+ finally
+ {
+ //ShellProcess.Close();
+ //ShellProcess.Dispose();
+ //_lazyProcess.Value.WaitForExit(DEFAULT_WAIT_TIMEOUT);
+ //_lazyProcess.Value.Close();
+ //_lazyProcess.Value.Dispose();
+ }
+ }
+
+ public virtual string GetError()
+ {
+ string error = ShellProcess.StandardError?.ReadToEnd();
+ return error;
+ }
+
+ public virtual string GetOutput()
+ {
+ string output = ShellProcess.StandardOutput?.ReadToEnd();
+ return output;
+ }
+
+ public virtual string AnalyzeExitCode(int exitCode = 9999)
+ {
+ string finalOutput = string.Empty;
+ if (exitCode == 9999) exitCode = LastExitCode;
+
+ if (exitCode != 0)
+ {
+ finalOutput = ShellProcess.StandardError?.ReadToEnd();
+ }
+ else
+ {
+ finalOutput = ShellProcess.StandardOutput?.ReadToEnd();
+ }
+
+ return finalOutput;
+ }
+ }
+}
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/PublishSDKNuget.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/PublishSDKNuget.cs
new file mode 100644
index 0000000000000..c3488ef7ad627
--- /dev/null
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/PublishSDKNuget.cs
@@ -0,0 +1,298 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+namespace Microsoft.WindowsAzure.Build.Tasks
+{
+ using System;
+ using Microsoft.Build.Framework;
+ using Microsoft.Build.Utilities;
+ using Microsoft.WindowsAzure.Build.Tasks.ExecProcess;
+ using Microsoft.WindowsAzure.Build.Tasks.Utilities;
+ using System.IO;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Diagnostics;
+
+ public class PublishSDKNuget : Task
+ {
+ //const string SDK_NUGET_APIKEY_ENV = "NetSdkNugetApiKey";
+ //const string DEFUALT_NUGET_URI = "https://www.nuget.org";
+ #region fields
+ ///
+ ///
+ ///
+ private bool _publishAllNugetsunderScope;
+ private bool _buildEngineInitialized;
+ private string _apiKey;
+ #endregion
+
+ public PublishSDKNuget()
+ {
+ _publishAllNugetsunderScope = false;
+ _buildEngineInitialized = false;
+
+ //By default do not skip publishing both nuget and symbols
+ SkipNugetPublishing = false;
+ SkipSymbolPublishing = false;
+ }
+
+ internal bool IsBuildEngineInitialized
+ {
+ get
+ {
+ if(this.BuildEngine != null)
+ {
+ _buildEngineInitialized = true;
+ }
+
+ return _buildEngineInitialized;
+ }
+ }
+
+ #region Required Properties
+
+ ///
+ /// Gets or sets Nuget Package Name that needs to be published
+ ///
+ [Required]
+ public string NugetPackageName { get; set; }
+
+ ///
+ /// Gets or sets output path for nuget that got packaged/generated
+ ///
+ [Required]
+ public string PackageOutputPath { get; set; }
+
+ ///
+ /// Gets or sets nuget publishing path.
+ /// Official Nuget Path is https://www.nuget.org/api/v2/package/
+ ///
+ [Required]
+ public string PublishNugetToPath { get; set; }
+ #endregion
+
+ ///
+ /// Sets or gets the path to Nuget.exe
+ ///
+ public string NugetExePath { get; set; }
+ ///
+ /// GitHub userId
+ ///
+ public string UserId { get; set; }
+
+ ///
+ /// Publish all nuget found under particular scope
+ /// e.g. publish all nugets under KeyVault
+ ///
+ public bool publishAllNugetsUnderScope { get { return _publishAllNugetsunderScope; } set { _publishAllNugetsunderScope = value; } }
+
+ ///
+ /// Gets or Sets relative scope Path (e.g. SDKs\Compute relative path after root\src)
+ ///
+ public string scopePath { get; set; }
+
+ public bool SkipSymbolPublishing { get; set; }
+
+ public bool SkipNugetPublishing { get; set; }
+
+ public bool DebugOutput { get; set; }
+
+ public List NugetPublishStatus { get; private set; }
+
+ ///
+ /// API key to be used to publish the nuget pakcage
+ ///
+ public string ApiKey
+ {
+ get
+ {
+ if(string.IsNullOrEmpty(_apiKey))
+ {
+ if(!string.IsNullOrEmpty(PublishNugetToPath))
+ {
+ if(PublishNugetToPath.StartsWith(Constants.NugetDefaults.NUGET_PUBLISH_URL))
+ {
+ _apiKey = System.Environment.GetEnvironmentVariable(Constants.NugetDefaults.SDK_NUGET_APIKEY_ENV);
+ Check.NotNull(_apiKey, "ApiKeyRetrieval");
+ }
+ else
+ {
+ // If local path or file share, we publish using a default api key
+ Check.DirectoryExists(PublishNugetToPath);
+ _apiKey = Constants.NugetDefaults.DEFAULT_API_KEY;
+ }
+ }
+ }
+
+ return _apiKey;
+ }
+ set
+ {
+ _apiKey = value;
+ }
+
+ }
+
+ public override bool Execute()
+ {
+ //NugetExec nug = null;
+ try
+ {
+ DebugInfo();
+
+ if (publishAllNugetsUnderScope)
+ {
+ // Check.DirectoryExists(publishNugetToPath);
+ throw new NotSupportedException("Publishing multiple nugets....This feature is currently Not Supported");
+ }
+ else
+ {
+ Check.NotEmptyNotNull(NugetPackageName, "NugetPackageName");
+ Check.NotEmptyNotNull(PackageOutputPath, "PackageOutputPath");
+ Check.NotEmptyNotNull(PublishNugetToPath, "PublishNugetToPath");
+
+ NugetPublishStatus = ExecPublishCommand();
+ ThrowForNonZeroExitCode(NugetPublishStatus);
+ }
+
+ return true;
+ }
+ catch(Exception ex)
+ {
+ LogException(ex);
+ throw ex;
+ }
+ }
+
+ private Tuple GetNugetPkgs(string nugetPkgName)
+ {
+ string nugPattern = string.Format("*{0}*.nupkg", nugetPkgName);
+ string nugSymPkgPattern = string.Format("*{0}*.symbols.nupkg", nugetPkgName);
+ IEnumerable dupeFiles = Directory.EnumerateFiles(PackageOutputPath, nugPattern);
+ IEnumerable foundSymbolPkgFiles = Directory.EnumerateFiles(PackageOutputPath, nugSymPkgPattern);
+
+ var foundNugetPkgFiles = dupeFiles.Except(foundSymbolPkgFiles, new ObjectComparer((left, right) => left.Equals(right, StringComparison.OrdinalIgnoreCase)));
+
+ string nupkg = string.Empty;
+ string nuSymPkg = string.Empty;
+
+ if (foundNugetPkgFiles.Any())
+ {
+ nupkg = foundNugetPkgFiles.First();
+ Check.NotEmptyNotNull(nupkg, "NugetPackage");
+ }
+
+ if (foundSymbolPkgFiles.Any())
+ {
+ nuSymPkg = foundSymbolPkgFiles.First();
+ Check.NotEmptyNotNull(nuSymPkg, "Nuget Symbol Package");
+ }
+
+ return new Tuple(nupkg, nuSymPkg);
+ }
+
+ private void ThrowForNonZeroExitCode(List statusList)
+ {
+ foreach(NugetPublishStatus status in statusList)
+ {
+ if(status.NugetPublishExitCode != 0)
+ {
+ string exMessage = string.Format("{0}\r\n ExitCode:{1}\r\n {2}\r\n", status.PublishArgs, status.NugetPublishExitCode.ToString(), status.NugetPublishStatusOutput);
+ throw new ApplicationException(exMessage);
+ }
+ else
+ {
+ LogInfo(status.PublishArgs);
+ LogInfo(status.NugetPublishStatusOutput);
+ }
+ }
+ }
+
+ private List ExecPublishCommand()
+ {
+ NugetExec nug = null;
+ Tuple nupkgs = GetNugetPkgs(NugetPackageName);
+
+ if (string.IsNullOrEmpty(NugetExePath))
+ {
+ nug = new NugetExec();
+ }
+ else
+ {
+ nug = new NugetExec(NugetExePath);
+ }
+
+ nug.PublishToPath = PublishNugetToPath;
+ nug.PublishSymbolToPath = PublishNugetToPath;
+ nug.SkipPublishingNuget = SkipNugetPublishing;
+ nug.SkipPublishingSymbols = SkipSymbolPublishing;
+ nug.ApiKey = ApiKey;
+
+ if (SkipNugetPublishing == true && SkipSymbolPublishing == true)
+ {
+ throw new ApplicationException("Requested to skip Publishing Nuget and Symbols");
+ }
+
+ List publishStatusList = nug.Publish(nupkgs);
+ return publishStatusList;
+ //NugetPublishStatus = publishStatusList;
+ }
+
+ private void DebugInfo()
+ {
+ if(DebugOutput)
+ {
+ LogInfo("UserId: {0}", UserId);
+ LogInfo("Nuget Package Name: {0}", NugetPackageName);
+ LogInfo("Nuget Output Path: {0}", PackageOutputPath);
+ LogInfo("Nuget Publish Path: {0}", PublishNugetToPath);
+ LogInfo("NugetExe Path: {0}", NugetExePath);
+ }
+ }
+
+ #region Logging
+ private void LogInfo(string messageToLog)
+ {
+ if(IsBuildEngineInitialized)
+ {
+ Log.LogMessage(messageToLog);
+ }
+ else
+ {
+ Debug.WriteLine(messageToLog);
+ }
+ }
+
+ private void LogInfo(string outputFormat, params string[] info)
+ {
+ LogInfo(string.Format(outputFormat, info));
+ }
+
+ private void LogException(Exception ex)
+ {
+ if (IsBuildEngineInitialized)
+ {
+ Log.LogErrorFromException(ex);
+ }
+ else
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+ }
+
+ private void LogError(string errorMessage)
+ {
+ if (IsBuildEngineInitialized)
+ {
+ Log.LogError(errorMessage);
+ }
+ else
+ {
+ Debug.WriteLine(errorMessage);
+ }
+ }
+
+ #endregion
+
+ }
+}
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/SDKCategorizeProjects.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/SDKCategorizeProjects.cs
index 23318beefcb1c..c63354afd201a 100644
--- a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/SDKCategorizeProjects.cs
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/SDKCategorizeProjects.cs
@@ -167,7 +167,6 @@ public override bool Execute()
var projTimeBefore = DateTime.Now;
projWithMetaData = GetProjectData(allProjects, projWithMetaData);
- //projWithMetaData = GetMetaData(allProjects, projWithMetaData);
var projTimeAfter = DateTime.Now;
Debug.WriteLine("Parsing Projects took {0}", (projTimeAfter - projTimeBefore).TotalSeconds.ToString());
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/Constants.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/Constants.cs
new file mode 100644
index 0000000000000..1e2f5489c0cda
--- /dev/null
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/Constants.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.WindowsAzure.Build.Tasks.Utilities
+{
+ ///
+ /// Constants used within the Build.Tasks library
+ ///
+ static class Constants
+ {
+
+ ///
+ /// Constants, defaults used for Nuget Publish task
+ ///
+ public static class NugetDefaults
+ {
+ public const string NUGET_PATH = "nuget.exe";
+ public const string NUGET_PUBLISH_URL = "https://www.nuget.org/api/v2/package/";
+ public const string NUGET_SYMBOL_PUBLISH_URL = "nuget.smbsrc.net";
+ public const int NUGET_TIMEOUT = 60; //Seconds
+ public const string DEFAULT_API_KEY = "1234";
+ public const string SDK_NUGET_APIKEY_ENV = "NetSdkNugetApiKey";
+ }
+ }
+}
diff --git a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/ProjectSearchUtility.cs b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/ProjectSearchUtility.cs
index 615b8c6118b1c..4f672c3638011 100644
--- a/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/ProjectSearchUtility.cs
+++ b/tools/Microsoft.WindowsAzure.Build.Tasks/Build.Tasks/Utilities/ProjectSearchUtility.cs
@@ -5,8 +5,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Microsoft.WindowsAzure.Build.Tasks.Utilities
{
@@ -158,44 +156,12 @@ public List GetFilteredProjects()
{
IEnumerable filteredProjects = AllProjectList.Except(IgnoredProjectList, new ObjectComparer((left, right) => left.Equals(right, StringComparison.OrdinalIgnoreCase)));
return filteredProjects?.ToList();
-
- /*
- List ignoreProjectPaths = new List();
- foreach (string iP in IgnorePathTokenList)
- {
- var ignorePaths = from proj in AllProjectList where proj.Contains(iP) select proj;
- if (ignorePaths.Any())
- {
- ignoreProjectPaths.AddRange(ignorePaths);
- }
- }
-
- filteredProjects = AllProjectList.Except(ignoreProjectPaths, new ObjectComparer((left, right) => left.Equals(right, StringComparison.OrdinalIgnoreCase)));
-
- return filteredProjects?.ToList();
- */
}
public List GetFilteredTestProjects()
{
IEnumerable filteredTestProjects = AllTestProjectList.Except(IgnoredProjectList, new ObjectComparer((left, right) => left.Equals(right, StringComparison.OrdinalIgnoreCase)));
return filteredTestProjects?.ToList();
-
- /*
- List ignoreProjects = new List();
- foreach(string iTP in IgnorePathTokenList)
- {
- var ignorePaths = from proj in AllTestProjectList where proj.Contains(iTP) select proj;
- if(ignorePaths.Any())
- {
- ignoreProjects.AddRange(ignorePaths);
- }
- }
-
- filteredTestProjects = AllTestProjectList.Except(ignoreProjects, new ObjectComparer((left, right) => left.Equals(right, StringComparison.OrdinalIgnoreCase)));
-
- return filteredTestProjects?.ToList();
- */
}
public List GetAllSDKProjects()
diff --git a/tools/buildTargets/common.targets b/tools/buildTargets/common.targets
index b9bf67d7e22b2..be0a3171a503c 100644
--- a/tools/buildTargets/common.targets
+++ b/tools/buildTargets/common.targets
@@ -198,8 +198,26 @@
-
+
+
+
+
+ $(LibraryRoot)PublishedNugets
+
+
+
+
+
+
+
@@ -285,6 +303,14 @@
+
+
diff --git a/tools/buildTargets/common.tasks b/tools/buildTargets/common.tasks
index c1c4c62b80176..54ae129b18d4a 100644
--- a/tools/buildTargets/common.tasks
+++ b/tools/buildTargets/common.tasks
@@ -11,10 +11,11 @@
+
-
+