Skip to content

Commit

Permalink
Avoids `error MSB4018: The "PrepareList" task failed unexpectedly / F…
Browse files Browse the repository at this point in the history
…ileNotFoundException`

Now should be simple message:
* List of packages is empty. Use .config or /p:ngpackages="..."

also:

* `ngconfig` property now is `packages.config` by default.
* added 'User-Agent' for `get` command, but...
* updated compressor - C# (name of types) & xml (whitespace-chars before `/>`)
  • Loading branch information
3F committed Dec 5, 2016
1 parent 1b0518e commit b277818
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 25 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ The lightweight non-binary NuGet Client as a portable & embeddable tool for work
(it does not require any additional extensions).

[![Build status](https://ci.appveyor.com/api/projects/status/rv65lbks5frc4k52/branch/master?svg=true)](https://ci.appveyor.com/project/3Fs/getnutool/branch/master)
[![release-src](https://img.shields.io/github/release/3F/GetNuTool.svg)](https://github.com/3F/GetNuTool/releases/latest)
[![License](https://img.shields.io/badge/License-MIT-74A5C2.svg)](https://github.com/3F/GetNuTool/blob/master/LICENSE)

```bash
> gnt # Executable version - full logic inside single script .bat/.cmd
> gnt # Executable version - full logic inside single script
> msbuild gnt.core # Full & Compact versions to execute via MSBuild
[NuGet gnt.raw("/t:pack /p:ngin=\"7z.Libs\"")] # Compiled variant via vssbe
```

[just try](https://github.com/3F/GetNuTool/releases/download/v1.5/gnt.bat) this:
```bash
gnt /p:ngpackages="Conari;regXwild" # To get `Conari` & `regXwild` packages
gnt /t:pack /p:ngin="bin\DllExport" # To create new NuGet package from `bin\DllExport` files
gnt /t:pack /p:ngin="bin\DllExport" # To create new NuGet package from `bin\DllExport` .nuspec
gnt /p:ngpackages="LunaRoad/1.4.1" # To get `LunaRoad` package v1.4.1
msbuild gnt.core /p:ngconfig="packages.config" # Use `packages.config`
```
Expand All @@ -27,19 +29,23 @@ msbuild gnt.core /p:ngconfig="packages.config" # Use `packages.config`

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

```
Copyright (c) 2015-2016 Denis Kuzmin <[email protected]>
```

[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=entry%2ereg%40gmail%2ecom&lc=US&item_name=3F%2dOpenSource%20%5b%20github%2ecom%2f3F&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted)


## Why GetNuTool ?

Primarily this to providing tools for service of your projects and libraries, the build processes, debugging, etc. For all that should be used as a tool for all projects (solution-level) or for each.
Primarily this to providing tools and service of your projects, libraries, the build processes, debugging, etc. For all that should be used as a tool for all projects ([solution-level](https://github.com/NuGet/Home/issues/1521)) or for each.

* The best examples:
* [vsSBE.CI.MSBuild](https://www.nuget.org/packages/vsSBE.CI.MSBuild/)
* [7z.Libs](https://www.nuget.org/packages/7z.Libs/)
* [ILAsm](https://www.nuget.org/packages/ILAsm/)

**But!** How about to consider it like a more lightweight powerful nuget client for getting packages or for new packaging. No, seriously, we already use it for many projects like:
**But!** How about to consider it like a more lightweight & powerful nuget client for getting packages or for new packaging. No, seriously, we already use it for many projects like:

* [Conari](https://github.com/3F/Conari)
* [DllExport](https://github.com/3F/DllExport)
Expand Down Expand Up @@ -70,7 +76,7 @@ So you can use this as you want, for example, automatically getting tool above f
* Creating new (packing) NuGet packages as `.nupkg` by using `.nuspec`
* Wrapping of any package in one executable file, for example:
* CI.MSBuild **in one click** ~10 Kb: **[get.CIM.bat](https://github.com/3F/vsSolutionBuildEvent/releases/download/release_v0.12.10/get.CIM.bat)**
* Via our `.packer` can be easy embedded inside of any scripts.
* With our `.packer` can be easy embedded inside of any scripts.

## Commands

Expand All @@ -82,7 +88,7 @@ Settings:

Property | Description | Default values
-----------|-------------------------------------------------------------------------|-----------------
ngconfig | Where to look the packages.config files. | v1.0+ `.nuget\packages.config`
ngconfig | Where to look the packages.config files. | v1.5.1+ `packages.config`, v1.0 - v1.5: `.nuget\packages.config`
ngserver | NuGet server. | v1.0+ `https://www.nuget.org/api/v2/package/`
ngpackages | List of packages. Use it first if defined, otherwise find via ngconfig | v1.0+ *empty*
ngpath | Common path for all packages. | v1.0+ `packages`
Expand Down Expand Up @@ -124,7 +130,7 @@ packages.config:
<package id="ident.second" version="15.0" output="path" />
</packages>
```
**Note:** Attributes for v1.2+ is now are case sensitive. Use lowercase for `id`, `version`, `output` ...
**Note:** Attributes for v1.2+ are case sensitive now. Use lowercase for `id`, `version`, `output` ...

#### Format of ngconfig

Expand Down Expand Up @@ -164,7 +170,7 @@ debug | false (by default), true | `v1.3+` To display additional information
*note: `v1.4+` also provides executable variant of GetNuTool.*

```bash
> gnt /p:ngpackages="DllExport"
> gnt /p:ngpackages="Conari"
> msbuild gnt.core /p:ngpackages="DllExport"
```

Expand All @@ -180,9 +186,7 @@ debug | false (by default), true | `v1.3+` To display additional information

#### Paths to MSBuild Tools

Use our MSBuild searcher - [msbuild](https://github.com/3F/GetNuTool/blob/master/msbuild.bat) for more convenience.

*but, just a note where to find the msbuild tools by default:*
*Use our msbuild-searcher and have fun. But just a note where to find the MSBuild tools by default:*

* All available versions on your machine: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions`

Expand Down Expand Up @@ -222,7 +226,7 @@ The GetNuTool now is part of [NuGetComponent](http://vssbe.r-eg.net/doc/Scripts/

The `gnt.bat` is already contains `gnt.core` logic. It stored **inside script**.

To build manually this version, you should use our packer from [here](https://github.com/3F/GetNuTool/tree/master/embedded) if needed.
To build this version you should use our packer from [here](https://github.com/3F/GetNuTool/tree/master/embedded).

```bash
> packing
Expand All @@ -232,9 +236,11 @@ To build manually this version, you should use our packer from [here](https://gi
> msbuild embedded/.packer /p:core="path to minified core" /p:output="output file"
```

Then you can use simply:
Now, you can use it simply:

```bash
> gnt ...
> gnt /p:ngpackages="Conari"
```

**note:** you do not need the `gnt.core` or something else ! the final script provides all of what you need as non-binary tool ~10 Kb.
30 changes: 19 additions & 11 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-2016 Denis Kuzmin (reg) [ [email protected] ]
Copyright (c) 2015-2016 Denis Kuzmin [ [email protected] ]
Distributed under the MIT license
(see accompanying file LICENSE or a copy at http://opensource.org/licenses/MIT)
Expand All @@ -16,7 +16,7 @@

<!-- Default values -->
<PropertyGroup>
<ngconfig Condition="'$(ngconfig)' == ''">.nuget\packages.config</ngconfig> <!-- Where to look the packages.config of solution-level -->
<ngconfig Condition="'$(ngconfig)' == ''">packages.config</ngconfig> <!-- Where to look the packages.config of solution-level -->
<ngserver Condition="'$(ngserver)' == ''">https://www.nuget.org/api/v2/package/</ngserver> <!-- Server by default -->
<ngpackages Condition="'$(ngpackages)' == ''"></ngpackages> <!-- Packages by default -->
<ngpath Condition="'$(ngpath)' == ''">packages</ngpath> <!-- Path by default -->
Expand Down Expand Up @@ -97,9 +97,11 @@
}
if(ret.Count < 1) {
throw new FileNotFoundException("List of packages is empty. Use .config or /p:ngpackages=\"...\"");
Console.WriteLine("List of packages is empty. Use .config or /p:ngpackages=\"...\"\n");
}
else {
Result = String.Join(";", ret.ToArray());
}
Result = String.Join(";", ret.ToArray());
]]></Code>
</Task>
Expand All @@ -109,7 +111,7 @@
<UsingTask TaskName="NGDownload" TaskFactory="CodeTaskFactory" AssemblyFile="$(TaskCoreDllPath)">

<ParameterGroup>
<plist ParameterType="System.String" Required="true" />
<plist ParameterType="System.String" />
<url ParameterType="System.String" Required="true" />
<wpath ParameterType="System.String" />
<defpath ParameterType="System.String" />
Expand All @@ -124,6 +126,10 @@
<Using Namespace="System.Net" />
<Code Type="Fragment" Language="cs"><![CDATA[
if(plist == null) {
return false;
}
// to ignore from package
var ignore = new string[] { "/_rels/", "/package/", "/[Content_Types].xml" };
Expand All @@ -147,8 +153,10 @@
Console.Write("Getting `{0}` ... ", link);
string temp = Path.Combine(Path.GetTempPath(), name);
using(WebClient wc = new WebClient()) {
wc.DownloadFile(url + link, temp);
using(var l = new WebClient()) {
l.Headers.Add("User-Agent", "GetNuTool");
l.UseDefaultCredentials = true;
l.DownloadFile(url + link, temp);
}
Console.WriteLine("Extracting into `{0}`", output);
Expand Down Expand Up @@ -315,8 +323,8 @@
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(var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) {
fs.CopyTo(tstream);
}
}
Expand All @@ -332,7 +340,7 @@
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.LastModifiedBy = "GetNuTool v" + vtool;
}
]]></Code>
Expand All @@ -348,7 +356,7 @@
<wpath Condition="'$(wpath)' == ''">$(MSBuildProjectDirectory)</wpath>
</PropertyGroup>
<Target Name="header">
<Message Text="%0D%0AGetNuTool - Version: $(GetNuTool)%0D%0A=========%0D%0A" Importance="high" />
<Message Text="%0D%0AGetNuTool v$(GetNuTool) - github.com/3F%0D%0A=========%0D%0A" Importance="high" />
</Target>

</Project>
22 changes: 21 additions & 1 deletion minified/.compressor
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
var copyr = Regex.Match(content, @"(Copyright[^$]+?)$", RegexOptions.Multiline).Groups[1].Value.Trim();
var vers = Regex.Match(content, @"(GetNuTool[^$]+?)$", RegexOptions.Multiline).Groups[1].Value.Trim();
// XML rules - Pre filter
/*content = Regex.Replace(
content,
@"\s* Required
\s* =
\s* ['""] \s*
.*?
\s* ['""] \s*",
"",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);*/
// protect strings
var strings = new Dictionary<uint, string>();
Expand All @@ -92,19 +104,27 @@
delegate(Match m)
{
var data = m.Groups[0].Value;
data = Regex.Replace(data, @"\s*\/\*.+?\*\/\s*", "", RegexOptions.Singleline);
data = Regex.Replace(data, @"\s*//[^$]+?$", "", RegexOptions.Multiline);
data = Regex.Replace(data, @"\s+const\s+[sS]tring\s+", " var ");
data = Regex.Replace(data, @"\s+\w+\s+(\w+)\s+(in|=)\s+", " var $1 $2 ");
data = Regex.Replace(data, @"\s*([{}()=+\-\[\]*?!@,;.])\s*", "$1");
return data;
},
RegexOptions.Singleline);
// common rules
content = content.Replace("\r", "").Replace("\n", "");
content = Regex.Replace(content, @"\s{2,}", " ");
// XML rules
content = Regex.Replace(content, @"<!--.+?-->", "");
content = Regex.Replace(content, @">\s+<", "><");
content = Regex.Replace(content, @"\s{2,}", " ");
content = Regex.Replace(content, @"\s+\/>", "/>");
content = Regex.Replace(content, @"<\?xml.+?\?>", String.Format("<!-- {0} --><!-- {1} -->", vers, copyr));
// recover strings
Expand Down

0 comments on commit b277818

Please sign in to comment.