{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments/57663352","id":57663352,"diff_hunk":"@@ -0,0 +1,291 @@\n+using Microsoft.VisualStudio.Services.Agent.Util;\n+using System;\n+using System.Collections;\n+using System.Collections.Generic;\n+using System.Diagnostics;\n+using System.IO;\n+using System.Threading;\n+using System.Threading.Tasks;\n+\n+namespace Microsoft.VisualStudio.Services.Agent.Listener\n+{\n+    [ServiceLocator(Default = typeof(CapabilitiesProvider))]\n+    public interface ICapabilitiesProvider : IAgentService\n+    {\n+        Task<Dictionary<string, string>> GetCapabilitiesAsync(string agentName, CancellationToken token);\n+    }\n+\n+    public class Capability\n+    {\n+        public Capability(string name, string tool = null, string[] paths = null)\n+        {\n+            Name = name;\n+            Tool = tool;\n+            Paths = paths;\n+        }\n+\n+        //Name of the capability as requried by the task definition.\n+        public string Name { get; private set; }\n+\n+        //Name of an executable file, which if found in the file system means the capability is present.\n+        public string Tool { get; private set; }\n+\n+        //An array of paths, which if found in the file system means the capability is present.\n+        public string[] Paths { get; private set; }\n+    }\n+\n+    public class ToolCapability\n+    {\n+        public ToolCapability(string name, string command, string commandArgs = null)\n+        {\n+            Name = name;\n+            Command = command;\n+            CommandArgs = commandArgs;\n+        }\n+\n+        //Name of the capability as requried by the task definition.\n+        public string Name { get; private set; }\n+\n+        //Name of an executable file, which can determine if a capability is present.\n+        //The script is expected to print on the standard output the value for the capability.\n+        public string Command { get; private set; }\n+\n+        //Arguments passed to Command.\n+        public string CommandArgs { get; private set; }\n+    }\n+\n+    public sealed class CapabilitiesProvider : AgentService, ICapabilitiesProvider\n+    {\n+        private List<Capability> _regularCapabilities =\n+            new List<Capability>\n+            {\n+                new Capability( \"ant\" ),\n+                new Capability( \"bundler\", \"bundle\" ),\n+                new Capability( \"clang\" ),\n+                new Capability( \"cmake\" ),\n+                new Capability( \"curl\" ),\n+                new Capability( \"git\" ),\n+                new Capability( \"gulp\" ),\n+                new Capability( \"java\" ),\n+                new Capability( \"JDK\", \"javac\" ),\n+                new Capability( \"make\" ),\n+                new Capability( \"maven\", \"mvn\" ),\n+                new Capability( \"MSBuild\", \"xbuild\" ),\n+                new Capability( \"node.js\", \"node\" ),\n+                new Capability( \"node.js\", \"nodejs\" ),\n+                new Capability( \"npm\" ),\n+                new Capability( \"python\" ),\n+                new Capability( \"python3\" ),\n+                new Capability( \"sh\" ),\n+                new Capability( \"subversion\", \"svn\" ),\n+                new Capability( \"ruby\" ),\n+                new Capability( \"rake\" ),\n+                new Capability( \"Xamarin.iOS\", \"mdtool\", new string[] { \"/Applications/Xamarin Studio.app/Contents/MacOS/mdtool\" } ),\n+                new Capability( \"Xamarin.Android\", \"mandroid\", new string[] { \"/Library/Frameworks/Xamarin.Android.framework/Commands/mandroid\" } )\n+            };\n+\n+        private static readonly List<ToolCapability> _toolCapabilities =\n+            new List<ToolCapability>\n+            {\n+                new ToolCapability( \"xcode\", \"xcode-select\", \"-p\" ),\n+            };\n+\n+        private static readonly string[] _ignoredEnvVariables = new string[] {\n+            \"TERM_PROGRAM\",\n+            \"TERM\",\n+            \"TERM_PROGRAM_VERSION\",\n+            \"SHLVL\",\n+            \"ls_colors\",\n+            \"comp_wordbreaks\"\n+        };\n+\n+        // Ignore env vars specified in the 'VSO_AGENT_IGNORE' env var\n+        private const string EnvIgnore = \"VSO_AGENT_IGNORE\";\n+\n+        private Dictionary<string, string> _capsCache;","path":"src/Agent.Listener/CapabilitiesProvider.cs","position":105,"original_position":105,"commit_id":"8a34822d5ad32bfd19dcbc6fbba3a3700d235527","original_commit_id":"8a34822d5ad32bfd19dcbc6fbba3a3700d235527","user":{"login":"TingluoHuang","id":1750815,"avatar_url":"https://avatars.githubusercontent.com/u/1750815?v=3","gravatar_id":"","url":"https://api.github.com/users/TingluoHuang","html_url":"https://github.com/TingluoHuang","followers_url":"https://api.github.com/users/TingluoHuang/followers","following_url":"https://api.github.com/users/TingluoHuang/following{/other_user}","gists_url":"https://api.github.com/users/TingluoHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/TingluoHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TingluoHuang/subscriptions","organizations_url":"https://api.github.com/users/TingluoHuang/orgs","repos_url":"https://api.github.com/users/TingluoHuang/repos","events_url":"https://api.github.com/users/TingluoHuang/events{/privacy}","received_events_url":"https://api.github.com/users/TingluoHuang/received_events","type":"User","site_admin":false},"body":"readonly _capsCache=new dictionary<>();","created_at":"2016-03-29T02:02:20Z","updated_at":"2016-03-29T02:02:20Z","html_url":"https://github.com/Microsoft/vsts-agent/pull/35#discussion_r57663352","pull_request_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments/57663352"},"html":{"href":"https://github.com/Microsoft/vsts-agent/pull/35#discussion_r57663352"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35","id":64106454,"html_url":"https://github.com/Microsoft/vsts-agent/pull/35","diff_url":"https://github.com/Microsoft/vsts-agent/pull/35.diff","patch_url":"https://github.com/Microsoft/vsts-agent/pull/35.patch","issue_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/35","number":35,"state":"open","locked":false,"title":"add capabilities, which exist in XPLAT agent","user":{"login":"stiliev","id":16541189,"avatar_url":"https://avatars.githubusercontent.com/u/16541189?v=3","gravatar_id":"","url":"https://api.github.com/users/stiliev","html_url":"https://github.com/stiliev","followers_url":"https://api.github.com/users/stiliev/followers","following_url":"https://api.github.com/users/stiliev/following{/other_user}","gists_url":"https://api.github.com/users/stiliev/gists{/gist_id}","starred_url":"https://api.github.com/users/stiliev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stiliev/subscriptions","organizations_url":"https://api.github.com/users/stiliev/orgs","repos_url":"https://api.github.com/users/stiliev/repos","events_url":"https://api.github.com/users/stiliev/events{/privacy}","received_events_url":"https://api.github.com/users/stiliev/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-24T22:08:26Z","updated_at":"2016-03-29T02:02:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"305ac0d693d6865d10b39d575c6ea45b1f884c45","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35/commits","review_comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35/comments","review_comment_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/35/comments","statuses_url":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/8a34822d5ad32bfd19dcbc6fbba3a3700d235527","head":{"label":"Microsoft:users/stiliev/capabilities","ref":"users/stiliev/capabilities","sha":"8a34822d5ad32bfd19dcbc6fbba3a3700d235527","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":53052789,"name":"vsts-agent","full_name":"Microsoft/vsts-agent","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vsts-agent","description":"Visual Studio Team Services Build and Release Agent","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-agent","forks_url":"https://api.github.com/repos/Microsoft/vsts-agent/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-agent/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-agent/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-agent/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-agent/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-agent/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-agent/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-agent/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-agent/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-agent/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-agent/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-agent/deployments","created_at":"2016-03-03T13:36:48Z","updated_at":"2016-03-24T18:22:59Z","pushed_at":"2016-03-28T22:51:26Z","git_url":"git://github.com/Microsoft/vsts-agent.git","ssh_url":"git@github.com:Microsoft/vsts-agent.git","clone_url":"https://github.com/Microsoft/vsts-agent.git","svn_url":"https://github.com/Microsoft/vsts-agent","homepage":null,"size":608,"stargazers_count":18,"watchers_count":18,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":18,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"60fc0be4723bc0378d91c2b9821aa4ae33ebe9e2","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":53052789,"name":"vsts-agent","full_name":"Microsoft/vsts-agent","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vsts-agent","description":"Visual Studio Team Services Build and Release Agent","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-agent","forks_url":"https://api.github.com/repos/Microsoft/vsts-agent/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-agent/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-agent/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-agent/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-agent/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-agent/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-agent/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-agent/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-agent/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-agent/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-agent/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-agent/deployments","created_at":"2016-03-03T13:36:48Z","updated_at":"2016-03-24T18:22:59Z","pushed_at":"2016-03-28T22:51:26Z","git_url":"git://github.com/Microsoft/vsts-agent.git","ssh_url":"git@github.com:Microsoft/vsts-agent.git","clone_url":"https://github.com/Microsoft/vsts-agent.git","svn_url":"https://github.com/Microsoft/vsts-agent","homepage":null,"size":608,"stargazers_count":18,"watchers_count":18,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35"},"html":{"href":"https://github.com/Microsoft/vsts-agent/pull/35"},"issue":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/issues/35"},"comments":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/8a34822d5ad32bfd19dcbc6fbba3a3700d235527"}}}}