{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/DotNetTools/pulls/comments/81028658","pull_request_review_id":2039701,"id":81028658,"diff_hunk":"@@ -0,0 +1,146 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Diagnostics;\n+using System.IO;\n+using System.Linq;\n+using System.Net.Http;\n+using System.Threading.Tasks;\n+using Microsoft.DotNet.Cli.Utils;\n+using Microsoft.DotNet.ProjectModel;\n+using Microsoft.DotNet.ProjectModel.Graph;\n+using Microsoft.DotNet.ProjectModel.Utilities;\n+using NuGet.Frameworks;\n+using NuGet.Versioning;\n+\n+namespace NuGetPackager\n+{\n+    internal class PackCommand\n+    {\n+        private readonly string _baseDir;\n+\n+        public PackCommand(string baseDir)\n+        {\n+            _baseDir = baseDir;\n+        }\n+\n+        public async Task PackAsync(string nuspec, string config, string outputDir)\n+        {\n+            var project = ProjectContext.Create(Path.GetDirectoryName(nuspec), FrameworkConstants.CommonFrameworks.NetCoreApp10);\n+            var props = \"configuration=\" + config;\n+            var idx = 0;\n+            foreach (var depVersion in GetDependencies(project).OrderBy(p => p.Item1).Select(p => p.Item2))\n+            {\n+                idx++;\n+                props += \";dep_\" + idx + \"=\" + depVersion;\n+            }\n+\n+            if (Command.CreateDotNet(\"build\", new[] { project.ProjectFile.ProjectFilePath, \"--configuration\", config }, configuration: config).Execute().ExitCode != 0)\n+            {\n+                throw new GracefulException(\"Build failed\");\n+            }\n+\n+            Directory.CreateDirectory(outputDir);\n+\n+            var version = project.ProjectFile.Version.ToNormalizedString();\n+            await Nuget(\"pack\",\n+                nuspec,\n+                \"-Verbosity\", \"detailed\",\n+                \"-OutputDirectory\", outputDir,\n+                \"-Version\", version,\n+                \"-Properties\", props);\n+        }\n+\n+        private IEnumerable<Tuple<string, string>> GetDependencies(ProjectContext context)\n+        {\n+            // copied from https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-pack/PackageGenerator.cs\n+            var project = context.RootProject;\n+\n+            foreach (var dependency in project.Dependencies)\n+            {\n+                if (dependency.Type.Equals(LibraryDependencyType.Build))\n+                {\n+                    continue;\n+                }\n+\n+                // TODO: Efficiency\n+                var dependencyDescription = context.LibraryManager.GetLibraries().First(l => l.RequestedRanges.Contains(dependency));\n+\n+                // REVIEW: Can we get this far with unresolved dependencies\n+                if (dependencyDescription == null || !dependencyDescription.Resolved)\n+                {\n+                    continue;\n+                }\n+\n+                if (dependencyDescription.Identity.Type == LibraryType.Project &&\n+                    ((ProjectDescription)dependencyDescription).Project.EmbedInteropTypes)\n+                {\n+                    continue;\n+                }\n+\n+\n+                VersionRange dependencyVersion = null;\n+\n+                if (dependency.VersionRange == null ||\n+                    dependency.VersionRange.IsFloating)\n+                {\n+                    dependencyVersion = new VersionRange(dependencyDescription.Identity.Version);\n+                }\n+                else\n+                {\n+                    dependencyVersion = dependency.VersionRange;\n+                }\n+\n+                Reporter.Verbose.WriteLine($\"Adding dependency {dependency.Name.Yellow()} {VersionUtility.RenderVersion(dependencyVersion).Yellow()}\");\n+\n+                yield return new Tuple<string, string>(dependency.Name, dependencyVersion.MinVersion.ToString());\n+            }\n+        }\n+\n+        private static string GetLockFileVersion(ProjectContext project, string name) =>\n+            project\n+                .LockFile\n+                .PackageLibraries\n+                .First(l => l.Name.Equals(name))\n+                .Version\n+                .ToNormalizedString();\n+\n+        private async Task Nuget(params string[] args)\n+        {\n+            var pInfo = new ProcessStartInfo\n+            {\n+                Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args),\n+                FileName = await GetNugetExePath()","path":"tools/NuGetPackager/PackCommand.cs","position":115,"original_position":115,"commit_id":"36304b2383f56fb8d0a2a652bd5435e135c7f86a","original_commit_id":"36304b2383f56fb8d0a2a652bd5435e135c7f86a","user":{"login":"bricelam","id":1226749,"avatar_url":"https://avatars.githubusercontent.com/u/1226749?v=3","gravatar_id":"","url":"https://api.github.com/users/bricelam","html_url":"https://github.com/bricelam","followers_url":"https://api.github.com/users/bricelam/followers","following_url":"https://api.github.com/users/bricelam/following{/other_user}","gists_url":"https://api.github.com/users/bricelam/gists{/gist_id}","starred_url":"https://api.github.com/users/bricelam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bricelam/subscriptions","organizations_url":"https://api.github.com/users/bricelam/orgs","repos_url":"https://api.github.com/users/bricelam/repos","events_url":"https://api.github.com/users/bricelam/events{/privacy}","received_events_url":"https://api.github.com/users/bricelam/received_events","type":"User","site_admin":false},"body":"This will only work on Windows, won't it? (cc @pranavkm)","created_at":"2016-09-28T22:10:20Z","updated_at":"2016-09-28T22:10:20Z","html_url":"https://github.com/aspnet/DotNetTools/pull/174#discussion_r81028658","pull_request_url":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174","_links":{"self":{"href":"https://api.github.com/repos/aspnet/DotNetTools/pulls/comments/81028658"},"html":{"href":"https://github.com/aspnet/DotNetTools/pull/174#discussion_r81028658"},"pull_request":{"href":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174","id":86070655,"html_url":"https://github.com/aspnet/DotNetTools/pull/174","diff_url":"https://github.com/aspnet/DotNetTools/pull/174.diff","patch_url":"https://github.com/aspnet/DotNetTools/pull/174.patch","issue_url":"https://api.github.com/repos/aspnet/DotNetTools/issues/174","number":174,"state":"open","locked":false,"title":"Add custom tool for packaging as \"CLI\" package types","user":{"login":"natemcmaster","id":2696087,"avatar_url":"https://avatars.githubusercontent.com/u/2696087?v=3","gravatar_id":"","url":"https://api.github.com/users/natemcmaster","html_url":"https://github.com/natemcmaster","followers_url":"https://api.github.com/users/natemcmaster/followers","following_url":"https://api.github.com/users/natemcmaster/following{/other_user}","gists_url":"https://api.github.com/users/natemcmaster/gists{/gist_id}","starred_url":"https://api.github.com/users/natemcmaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natemcmaster/subscriptions","organizations_url":"https://api.github.com/users/natemcmaster/orgs","repos_url":"https://api.github.com/users/natemcmaster/repos","events_url":"https://api.github.com/users/natemcmaster/events{/privacy}","received_events_url":"https://api.github.com/users/natemcmaster/received_events","type":"User","site_admin":false},"body":"Resolves #157. cref https://github.com/aspnet/Coherence-Signed/issues/367\r\n\r\nThis is throw away work but necessary since CLI won't update to support packing \"packageTypes\" for project.json, and we're not ready to switch to MSBuild based CLI yet. Will open an issue to track the removal of this tool once that changes.\r\n","created_at":"2016-09-20T22:52:46Z","updated_at":"2016-09-28T22:10:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d52f3d0a138f707d6dae23992a1f4cd43b9fd802","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174/commits","review_comments_url":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174/comments","review_comment_url":"https://api.github.com/repos/aspnet/DotNetTools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/DotNetTools/issues/174/comments","statuses_url":"https://api.github.com/repos/aspnet/DotNetTools/statuses/36304b2383f56fb8d0a2a652bd5435e135c7f86a","head":{"label":"aspnet:namc/nupkg-type","ref":"namc/nupkg-type","sha":"36304b2383f56fb8d0a2a652bd5435e135c7f86a","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":42664941,"name":"DotNetTools","full_name":"aspnet/DotNetTools","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/DotNetTools","description":"Various .NET command line tools","fork":false,"url":"https://api.github.com/repos/aspnet/DotNetTools","forks_url":"https://api.github.com/repos/aspnet/DotNetTools/forks","keys_url":"https://api.github.com/repos/aspnet/DotNetTools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/DotNetTools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/DotNetTools/teams","hooks_url":"https://api.github.com/repos/aspnet/DotNetTools/hooks","issue_events_url":"https://api.github.com/repos/aspnet/DotNetTools/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/DotNetTools/events","assignees_url":"https://api.github.com/repos/aspnet/DotNetTools/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/DotNetTools/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/DotNetTools/tags","blobs_url":"https://api.github.com/repos/aspnet/DotNetTools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/DotNetTools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/DotNetTools/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/DotNetTools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/DotNetTools/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/DotNetTools/languages","stargazers_url":"https://api.github.com/repos/aspnet/DotNetTools/stargazers","contributors_url":"https://api.github.com/repos/aspnet/DotNetTools/contributors","subscribers_url":"https://api.github.com/repos/aspnet/DotNetTools/subscribers","subscription_url":"https://api.github.com/repos/aspnet/DotNetTools/subscription","commits_url":"https://api.github.com/repos/aspnet/DotNetTools/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/DotNetTools/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/DotNetTools/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/DotNetTools/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/DotNetTools/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/DotNetTools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/DotNetTools/merges","archive_url":"https://api.github.com/repos/aspnet/DotNetTools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/DotNetTools/downloads","issues_url":"https://api.github.com/repos/aspnet/DotNetTools/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/DotNetTools/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/DotNetTools/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/DotNetTools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/DotNetTools/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/DotNetTools/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/DotNetTools/deployments","created_at":"2015-09-17T15:36:46Z","updated_at":"2016-09-26T22:43:43Z","pushed_at":"2016-09-28T22:10:16Z","git_url":"git://github.com/aspnet/DotNetTools.git","ssh_url":"git@github.com:aspnet/DotNetTools.git","clone_url":"https://github.com/aspnet/DotNetTools.git","svn_url":"https://github.com/aspnet/DotNetTools","homepage":"","size":470,"stargazers_count":143,"watchers_count":143,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":18,"forks":14,"open_issues":18,"watchers":143,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"61dc862e4db1e5d802ab8a5cb1e614a0457222c4","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":42664941,"name":"DotNetTools","full_name":"aspnet/DotNetTools","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/DotNetTools","description":"Various .NET command line tools","fork":false,"url":"https://api.github.com/repos/aspnet/DotNetTools","forks_url":"https://api.github.com/repos/aspnet/DotNetTools/forks","keys_url":"https://api.github.com/repos/aspnet/DotNetTools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/DotNetTools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/DotNetTools/teams","hooks_url":"https://api.github.com/repos/aspnet/DotNetTools/hooks","issue_events_url":"https://api.github.com/repos/aspnet/DotNetTools/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/DotNetTools/events","assignees_url":"https://api.github.com/repos/aspnet/DotNetTools/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/DotNetTools/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/DotNetTools/tags","blobs_url":"https://api.github.com/repos/aspnet/DotNetTools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/DotNetTools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/DotNetTools/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/DotNetTools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/DotNetTools/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/DotNetTools/languages","stargazers_url":"https://api.github.com/repos/aspnet/DotNetTools/stargazers","contributors_url":"https://api.github.com/repos/aspnet/DotNetTools/contributors","subscribers_url":"https://api.github.com/repos/aspnet/DotNetTools/subscribers","subscription_url":"https://api.github.com/repos/aspnet/DotNetTools/subscription","commits_url":"https://api.github.com/repos/aspnet/DotNetTools/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/DotNetTools/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/DotNetTools/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/DotNetTools/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/DotNetTools/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/DotNetTools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/DotNetTools/merges","archive_url":"https://api.github.com/repos/aspnet/DotNetTools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/DotNetTools/downloads","issues_url":"https://api.github.com/repos/aspnet/DotNetTools/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/DotNetTools/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/DotNetTools/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/DotNetTools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/DotNetTools/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/DotNetTools/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/DotNetTools/deployments","created_at":"2015-09-17T15:36:46Z","updated_at":"2016-09-26T22:43:43Z","pushed_at":"2016-09-28T22:10:16Z","git_url":"git://github.com/aspnet/DotNetTools.git","ssh_url":"git@github.com:aspnet/DotNetTools.git","clone_url":"https://github.com/aspnet/DotNetTools.git","svn_url":"https://github.com/aspnet/DotNetTools","homepage":"","size":470,"stargazers_count":143,"watchers_count":143,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":18,"forks":14,"open_issues":18,"watchers":143,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174"},"html":{"href":"https://github.com/aspnet/DotNetTools/pull/174"},"issue":{"href":"https://api.github.com/repos/aspnet/DotNetTools/issues/174"},"comments":{"href":"https://api.github.com/repos/aspnet/DotNetTools/issues/174/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/DotNetTools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/DotNetTools/pulls/174/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/DotNetTools/statuses/36304b2383f56fb8d0a2a652bd5435e135c7f86a"}}}}
{"actor":{"display_login":"bricelam"}}