private ApplicationDetailsListParameter VerifyPreconditions()
        {
            ApplicationDetailsListParameter appDetails = new ApplicationDetailsListParameter()
            {
                DetailsList = new System.Collections.Generic.List<PublishedApplicationDetails>()
                {
                    new PublishedApplicationDetails()
                }
            };

            string appName = null;
            string appPath = null;
            string iconURI = null;
            IconPngUrisType iconPngUris = new IconPngUrisType();

            switch (ParameterSetName)
            {
                case AppPath:
                {
                    appName = Path.GetFileNameWithoutExtension(FileVirtualPath);
                    appPath = FileVirtualPath;
                    
                    break;
                }
                case AppId:
                {
                    GetStartMenuApplicationResult startMenu = Client.Publishing.StartMenuApplication(CollectionName, StartMenuAppId);
                    appName = startMenu.Result.Name;
                    appPath = startMenu.Result.VirtualPath;
                    iconURI = startMenu.Result.IconUri;
                    iconPngUris = new IconPngUrisType()
                    {
                        IconPngUris = startMenu.Result.IconPngUris,
                    };
                    break;
                }
            }

            appDetails.DetailsList[0].Name = String.IsNullOrWhiteSpace(DisplayName) ? appName : DisplayName;
            appDetails.DetailsList[0].VirtualPath = appPath;

            appDetails.DetailsList[0].IconUri = iconURI;
            appDetails.DetailsList[0].IconPngUris = iconPngUris;

            appDetails.DetailsList[0].Alias = "";

            appDetails.DetailsList[0].CommandLineArguments = CommandLine;

            appDetails.DetailsList[0].AvailableToUsers = true; 

            return appDetails;
        }
 /// <summary>
 /// Publishes remote applications with given application details in the
 /// collection.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.RemoteApp.IPublishingOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Collection Name
 /// </param>
 /// <param name='applicationDetailsList'>
 /// Required. List of publishing details
 /// </param>
 /// <returns>
 /// Definition for result of PublishApplications operation.
 /// </returns>
 public static Task<PublishApplicationsResult> PublishApplicationsAsync(this IPublishingOperations operations, string collectionName, ApplicationDetailsListParameter applicationDetailsList)
 {
     return operations.PublishApplicationsAsync(collectionName, applicationDetailsList, CancellationToken.None);
 }
        private void StartApplicationPublishing(ApplicationDetailsListParameter appDetails)
        {
            PublishApplicationsResult response = CallClient(() => Client.Publishing.PublishApplications(CollectionName, appDetails), Client.Publishing);

            WriteObject(response.ResultList, true);
        }
 /// <summary>
 /// Publishes remote applications with given application details in the
 /// collection.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.RemoteApp.IPublishingOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Collection Name
 /// </param>
 /// <param name='applicationDetailsList'>
 /// Required. List of publishing details
 /// </param>
 /// <returns>
 /// Definition for result of PublishApplications operation.
 /// </returns>
 public static PublishApplicationsResult PublishApplications(this IPublishingOperations operations, string collectionName, ApplicationDetailsListParameter applicationDetailsList)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IPublishingOperations)s).PublishApplicationsAsync(collectionName, applicationDetailsList);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }