Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Add custom tool for packaging as "CLI" package types #174

Merged
merged 1 commit into from
Sep 30, 2016

Conversation

natemcmaster
Copy link
Contributor

@natemcmaster natemcmaster commented Sep 20, 2016

Resolves #157. cref https://github.com/aspnet/Coherence-Signed/issues/367

This 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.

@natemcmaster
Copy link
Contributor Author

Depends on aspnet/BuildTools#101

@natemcmaster
Copy link
Contributor Author

cc @bricelam could you review? This is similar to the command packager in EF.Tools

#repack-tools .remove-intermediates target='compile' if='Directory.Exists("src") && !IsLinux'
@{
Dotnet("run -p tools/NuGetPackager -- -c " + E("Configuration") +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the Sake nuget-pack task?? :trollface:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to avoid putting anything in KoreBuild that will be ripped out when we switch to MSBuild....but actually, maybe I should just override the "pack" target completely now that I've ripped out any "dependency" type packages from this project.

Dotnet("run -p tools/NuGetPackager -- -c " + E("Configuration") +
" -o artifacts/build/ "+
"-n src/Microsoft.Extensions.SecretManager.Tools/project.nuspec " +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project.nuspec makes me smile. (The convention is to name them <packageName>.nuspec)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. oh yeah... this started as wishful thinking that CLI itself could do nuspec. Will rename to keep it clearer.

foreach (var depVersion in GetDependencies(project).OrderBy(p => p.Item1).Select(p => p.Item2))
{
idx++;
props += ";dep_" + idx + "=" + depVersion;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these align? By ensure order in project.nuspec matches project.json?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUST BE alphabetical

Ah.

return nugetPath;
}
Console.WriteLine("log : Downloading nuget.exe 3.5.0-rc1".Bold().Black());
var response = await new HttpClient().GetAsync("https://dist.nuget.org/win-x86-commandline/v3.5.0-rc1/NuGet.exe");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get this from somewhere that stays up-to-date?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can update to latest once 3.5 ships.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is possible to make the download url as well as file name configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAGNI. We need NuGet ≤ 3.5.0-rc1 to get package type support in nuspec. By the time 3.5.0 rtm or 3.6.0 come out, we'll have removed this anyways. See #179

Copy link

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link

@troydai troydai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few minor comments. None of them should block this PR from being merged.

]
}
{
"adx": { // Packages written by the ADX team and that ship on NuGet.org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments in json is not recommended. do we need this?

}
}
},
"Default": { // Rules to run for packages not listed in any other set.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this comment?


private IEnumerable<Tuple<string, string>> GetDependencies(ProjectContext context)
{
// copied from https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-pack/PackageGenerator.cs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a permanent link instead (press 'y' while on the github page)

var dependencyDescription = context.LibraryManager.GetLibraries().First(l => l.RequestedRanges.Contains(dependency));

// REVIEW: Can we get this far with unresolved dependencies
if (dependencyDescription == null || !dependencyDescription.Resolved)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependencyDescription won't be null. if the first element can't be found, exception will be throw from previous First clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

continue;
}


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant empty line.

foreach (var depVersion in GetDependencies(project).OrderBy(p => p.Item1).Select(p => p.Item2))
{
idx++;
props += ";dep_" + idx + "=" + depVersion;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two line can be merged into one line:

props += $";dep_{++idx}={depVersion}";

props += ";dep_" + idx + "=" + depVersion;
}

if (Command.CreateDotNet("build", new[] { project.ProjectFile.ProjectFilePath, "--configuration", config }, configuration: config).Execute().ExitCode != 0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break the line. too long to be reviewed.

return nugetPath;
}
Console.WriteLine("log : Downloading nuget.exe 3.5.0-rc1".Bold().Black());
var response = await new HttpClient().GetAsync("https://dist.nuget.org/win-x86-commandline/v3.5.0-rc1/NuGet.exe");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is possible to make the download url as well as file name configurable?

var pInfo = new ProcessStartInfo
{
Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args),
FileName = await GetNugetExePath()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work on Windows, won't it? (cc @pranavkm)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Running on xplat would require running it via mono (which we don't require and is known to be problematic).

}

#repack-tools .remove-intermediates target='compile' if='Directory.Exists("src") && !IsLinux'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bricelam Yeah, this only runs on Windows

@natemcmaster natemcmaster merged commit 3b1f650 into dev Sep 30, 2016
@natemcmaster natemcmaster deleted the namc/nupkg-type branch September 30, 2016 21:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants