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;
}
}
}