none
how to run an exe file on release in VSTS RRS feed

  • Question

  • I have created a console application for fetching the SharePoint site title inside visual studio online. The  url of the SharePoint site is passed along in the code, but the password needs to entered in at console window at the run-time.

    And then i have defined the build definition and is able to build the solution and copy the files to the artifact.

    now, i configured the release definition, and i am trying to  run the build-ed .exe file, but is getting the bellow error: 

     Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file.

    PS: I have defined a variable $pass and then added it in the arguments section for getting the password of the SharePoint site.

    Error Screen which i am getting:

    Code for the console app:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Security;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.SharePoint.Client; 

    namespace VSTS_Demo_App
    {
        class Program
        {
            static void Main(string[] args)
            {
                string userName = "$$$@$$$.onmicrosoft.com";  
                Console.WriteLine("Enter your password.");  
                SecureString password = GetPassword();  
                // ClienContext - Get the context for the SharePoint Online Site  
                // SharePoint site URL - https://c986.sharepoint.com  
                using (var clientContext = new ClientContext("https://$$$$$$$$$$$$$$$$$$$$$$$$$$"))   
                {  
                    // SharePoint Online Credentials  
                    clientContext.Credentials = new SharePointOnlineCredentials(userName, password);  
                    // Get the SharePoint web  
                    Web web = clientContext.Web;  
                    // Load the Web properties  
                    clientContext.Load(web);  
                    // Execute the query to the server.  
                    clientContext.ExecuteQuery();  
                    // Web properties - Display the Title and URL for the web  
                    Console.WriteLine("Title: " + web.Title + "; URL: " + web.Url);  
                    Console.ReadLine();  
                }  
            }  
            private static SecureString GetPassword()  
          {  
                ConsoleKeyInfo info;
                Console.WriteLine("get passwod -called");
                //Get the user's password as a SecureString  
                SecureString securePassword = new SecureString();  
                do   
                {  
                    info = Console.ReadKey(true);  
                    if (info.Key != ConsoleKey.Enter)   
                    {  
                        securePassword.AppendChar(info.KeyChar);  
                    }  
                }  
                while (info.Key != ConsoleKey.Enter);  
                return securePassword;  
            }  
        }  
    }  
    Wednesday, April 11, 2018 8:39 AM

All replies

  • Hi Shibin_te,

    Thanks for posting here.

    This forum is about the MSBuild(Discuss the Microsoft build engine aka MSBuild. Topics including: usage of MSBuild, build customization, and MSBuild extensibility via tasks, loggers and hosting.), as your issue is more related to the VSTS, However, the VSTS forum on MSDN is locked, so I suggest that you could open a new thread on the stackoverflow with VSTS tag.

    More community members and MVP on that forum may further look at your issue and provide more suggestions.

    If you have some MSBuild questions, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding and cooperation.


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, April 11, 2018 10:29 AM