Skip to content

Commit

Permalink
* NEW: Added /p:debug to display additional information from select…
Browse files Browse the repository at this point in the history
…ed command.

* CHANGED: Compact output for processed files.
* CHANGED: CA2202 -> sout
  • Loading branch information
3F committed Jan 7, 2016
1 parent afbe1a8 commit 7be8bf2
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ obj
.vs
/packages
/compact/gnt-compact.core
/compact/gnt-min.core
.nupkg
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Denis Kuzmin (reg) <entry.reg@gmail.com>
Copyright (c) 2015-2016 Denis Kuzmin (reg) <entry.reg@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The lightweight non-binary tool for work with NuGet packages via basic MSBuild T
> msbuild.exe gnt.core
```

**Download:** [/releases](https://github.com/3F/GetNuTool/releases) ( [latest](https://github.com/3F/GetNuTool/releases/latest) )

## License

The [MIT License (MIT)](https://github.com/3F/GetNuTool/blob/master/LICENSE)

## Main features

* Getting the all selected `.nupkg` packages from NuGet server from user list with formats below.
Expand All @@ -28,9 +34,11 @@ The GetNuTool can't use events from Visual Studio by default. However, it can be

So you can use this as you want, for example, to automatically getting tool above for work with complex scripts with MSBuild Tool and Visual Studio as unified engine., etc.

### Getting & Extracting packages
## Commands

### `get`

*The `get` command is used by default. You can also call it as `/t:get`*
The `get` command is used by default. For getting & extracting packages. You can also use it as `/t:get`

Settings:

Expand Down Expand Up @@ -89,9 +97,9 @@ multiple:
/p:ngconfig=".nuget/packages.config|project1/packages.config|project2/packages.config|..."
```

### Packing
### `pack`

The `pack` command. Call it as `/t:pack`
The `pack` command. For creating the new .nupkg packages by .nuspec specification. Use it as `/t:pack`

Settings:

Expand All @@ -105,6 +113,12 @@ ngout | Optional path to output the final `.nupkg` package.
> msbuild.exe gnt.core /t:pack /p:ngin="path to .nuspec" /p:ngout="path for .nupkg"
```

## Properties

Property | Values | Description
---------|--------------------------|------------
debug | false (by default), true | v1.3+ To display additional information from selected command.

## Examples

```bash
Expand All @@ -118,7 +132,7 @@ ngout | Optional path to output the final `.nupkg` package.
> msbuild.exe gnt.core /t:pack /p:ngin="D:\tmp\7z.Libs" /p:ngout="newdir/"
```

### Paths to msbuild.exe
#### Paths to msbuild.exe

*just a note where to find the msbuild tool by default:*

Expand All @@ -143,6 +157,13 @@ Currently compact version ~4 Kb for `get` command and ~4 Kb for `pack` command,
> msbuild.exe .compressor /p:core="path to core" /p:output="output file"
```

## License
## Compiled variant

The GetNuTool now is part of [NuGetComponent](http://vssbe.r-eg.net/doc/Scripts/SBE-Scripts/Components/NuGetComponent/) ([SBE-Scripts](http://vssbe.r-eg.net/doc/Scripts/SBE-Scripts/))

```java
#[NuGet gnt.raw("/t:pack /p:ngin=\"D:\7z.Libs\"")]
...
```

The MIT License (MIT)
etc.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
GetNuTool
____________________

[v1.3]
* NEW: Added `/p:debug` to display additional information from selected command.
* CHANGED: Compact output for processed files.
* CHANGED: CA2202 -> sout

[v1.2]
* NEW: Packing packages into .nupkg by using .nuspec
* CHANGED: The `get` & `pack` commands for calling of main features.
Expand Down
2 changes: 1 addition & 1 deletion compact/.compressor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- Main settings -->
<PropertyGroup>
<core Condition="'$(core)' == ''">..\gnt.core</core>
<output Condition="'$(output)' == ''">gnt-compact.core</output>
<output Condition="'$(output)' == ''">gnt-min.core</output>
</PropertyGroup>

<!-- Entry point -->
Expand Down
112 changes: 61 additions & 51 deletions gnt.core
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 Denis Kuzmin (reg) [ entry.reg@gmail.com ]
Copyright (c) 2015-2016 Denis Kuzmin (reg) [ entry.reg@gmail.com ]
Distributed under the MIT license
(see accompanying file LICENSE or a copy at http://opensource.org/licenses/MIT)
Expand All @@ -27,10 +27,10 @@
<PrepareList config="$(ngconfig)" plist="$(ngpackages)">
<Output PropertyName="plist" TaskParameter="Result" />
</PrepareList>
<NGDownload plist="$(plist)" url="$(ngserver)" defpath="$(ngpath)" />
<NGDownload plist="$(plist)" url="$(ngserver)" defpath="$(ngpath)" debug="$(debug)" />
</Target>
<Target Name="pack" DependsOnTargets="header">
<NGPack dir="$(ngin)" dout="$(ngout)" vtool="$(GetNuTool)" />
<NGPack dir="$(ngin)" dout="$(ngout)" vtool="$(GetNuTool)" debug="$(debug)" />
</Target>

<!-- Tasks settings -->
Expand Down Expand Up @@ -73,7 +73,7 @@
if(id == null) {
throw new ArgumentException(String.Format("Attribute - 'id' is not found in '{0}'", cfg));
}
string link = id.Value;
var link = id.Value;
if(version != null) {
link += "/" + version.Value;
Expand Down Expand Up @@ -110,6 +110,7 @@
<plist ParameterType="System.String" Required="true" />
<url ParameterType="System.String" Required="true" />
<defpath ParameterType="System.String" />
<debug ParameterType="System.Boolean" />
</ParameterGroup>

<Task>
Expand All @@ -123,14 +124,20 @@
// to ignore from package
var ignore = new string[] { "/_rels/", "/package/", "/[Content_Types].xml" };
Action<string, object> dbg = delegate(string s, object p) {
if(debug) {
Console.WriteLine(s, p);
}
};
Action<string, string, string> get = delegate(string link, string name, string path)
{
string output = Path.GetFullPath(path ?? name);
if(Directory.Exists(output)) {
Console.WriteLine("The `{0}` is already exists. /pass -> `{1}`", name, output);
return;
}
Console.WriteLine("Getting `{0}` ...", link);
Console.Write("Getting `{0}` ... ", link);
string temp = Path.Combine(Path.GetTempPath(), name);
using(WebClient wc = new WebClient()) {
Expand All @@ -147,10 +154,10 @@
continue;
}
string dest = Path.Combine(output, uri.TrimStart('/'));
Console.WriteLine("-> `{0}`", uri);
var dest = Path.Combine(output, uri.TrimStart('/'));
dbg("-> `{0}`", uri);
string dir = Path.GetDirectoryName(dest);
var dir = Path.GetDirectoryName(dest);
if(!Directory.Exists(dir)) {
Directory.CreateDirectory(dir);
}
Expand All @@ -161,7 +168,7 @@
}
}
}
Console.WriteLine("Done.{0}", Environment.NewLine);
dbg("Done.{0}", Environment.NewLine);
};
//Format: id/version[:path];id2/version[:path];...
Expand Down Expand Up @@ -190,6 +197,7 @@
<dir ParameterType="System.String" Required="true" />
<dout ParameterType="System.String" />
<vtool ParameterType="System.String" Required="true" />
<debug ParameterType="System.Boolean" />
</ParameterGroup>

<Task>
Expand All @@ -214,6 +222,12 @@
// Tags
const string ID = "id";
const string VER = "version";
Action<string, object> dbg = delegate(string s, object p) {
if(debug) {
Console.WriteLine(s, p);
}
};
// Get metadata
Expand Down Expand Up @@ -259,60 +273,56 @@
}
Console.WriteLine("Started packing `{0}` ...", pout);
using(var sout = File.Create(pout))
using(Package package = Package.Open(pout, FileMode.Create))
{
using(Package package = Package.Open(sout, FileMode.Create))
{
// manifest relationship
// manifest relationship
Uri manifestUri = new Uri(String.Format("/{0}{1}", metadata[ID], EXT_NUSPEC), UriKind.Relative);
package.CreateRelationship(manifestUri, TargetMode.Internal, MANIFEST_URL);
Uri manifestUri = new Uri(String.Format("/{0}{1}", metadata[ID], EXT_NUSPEC), UriKind.Relative);
package.CreateRelationship(manifestUri, TargetMode.Internal, MANIFEST_URL);
// content
// content
foreach(var file in Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories))
{
if(ignore.Any(x => file.StartsWith(x, StringComparison.Ordinal))) {
continue;
}
foreach(var file in Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories))
{
if(ignore.Any(x => file.StartsWith(x, StringComparison.Ordinal))) {
continue;
}
string pUri;
if(file.StartsWith(dir, StringComparison.OrdinalIgnoreCase)) {
pUri = file.Substring(dir.Length).TrimStart(Path.DirectorySeparatorChar);
}
else {
pUri = file;
}
Console.WriteLine("-> `{0}`", pUri);
string pUri;
if(file.StartsWith(dir, StringComparison.OrdinalIgnoreCase)) {
pUri = file.Substring(dir.Length).TrimStart(Path.DirectorySeparatorChar);
}
else {
pUri = file;
}
dbg("-> `{0}`", pUri);
// to protect path without separators
var escaped = String.Join("/", pUri.Split('\\', '/').Select(p => Uri.EscapeDataString(p)));
Uri uri = PackUriHelper.CreatePartUri(new Uri(escaped, UriKind.Relative));
// to protect path without separators
var escaped = String.Join("/", pUri.Split('\\', '/').Select(p => Uri.EscapeDataString(p)));
Uri uri = PackUriHelper.CreatePartUri(new Uri(escaped, UriKind.Relative));
PackagePart part = package.CreatePart(uri, DEF_CONTENT_TYPE, CompressionOption.Maximum);
PackagePart part = package.CreatePart(uri, DEF_CONTENT_TYPE, CompressionOption.Maximum);
using (Stream tstream = part.GetStream())
using(FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
fileStream.CopyTo(tstream);
}
using (Stream tstream = part.GetStream())
using(FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read)) {
fileStream.CopyTo(tstream);
}
}
// metadata for package
// metadata for package
Func<string, string> getmeta = delegate(string key) {
return (metadata.ContainsKey(key))? metadata[key] : "";
};
Func<string, string> getmeta = delegate(string key) {
return (metadata.ContainsKey(key))? metadata[key] : "";
};
package.PackageProperties.Creator = getmeta("authors");
package.PackageProperties.Description = getmeta("description");
package.PackageProperties.Identifier = metadata[ID];
package.PackageProperties.Version = metadata[VER];
package.PackageProperties.Keywords = getmeta("tags");
package.PackageProperties.Title = getmeta("title");
package.PackageProperties.LastModifiedBy = String.Format("GetNuTool v{0}", vtool);
}
package.PackageProperties.Creator = getmeta("authors");
package.PackageProperties.Description = getmeta("description");
package.PackageProperties.Identifier = metadata[ID];
package.PackageProperties.Version = metadata[VER];
package.PackageProperties.Keywords = getmeta("tags");
package.PackageProperties.Title = getmeta("title");
package.PackageProperties.LastModifiedBy = String.Format("GetNuTool v{0}", vtool);
}
Console.WriteLine("Done.");
]]></Code>
</Task>
Expand All @@ -323,7 +333,7 @@
<Target Name="Build" DependsOnTargets="get" />

<PropertyGroup>
<GetNuTool>1.2</GetNuTool>
<GetNuTool>1.3</GetNuTool>
</PropertyGroup>
<Target Name="header">
<Message Text="%0D%0AGetNuTool - Version: $(GetNuTool)%0D%0A=========%0D%0A" Importance="high" />
Expand Down

0 comments on commit 7be8bf2

Please sign in to comment.