Skip to content

Commit

Permalink
* FIXED: Incorrect path to Microsoft.Build.Tasks.dll with new MSBuild…
Browse files Browse the repository at this point in the history
… 14.0

* NEW: Compact version - `gnt-compact.core`
* CHANGED: Ignoring downloading if this folder is already exists. Remove folder to avoid restriction.
  • Loading branch information
3F committed Dec 11, 2015
1 parent 5055da8 commit 9d9bcc3
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin
obj
*.suo
.vs
/packages
/packages
/compact/gnt-compact.core
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,44 @@ The lightweight non-binary tool for getting the NuGet packages via basic MSBuild
## Main features

* Getting the all selected .nupkg packages from NuGet server from user list with formats below.
* Two formats: list from .config files or direct from string.
* Extracting the all data from .nupkg 'as is' into path by default or specific for each package.
* Dependencies are not considered! get it manually.
* +Custom naming for each package with ignoring for already downloaded packages.
* Dependencies are not considered! get it manually as other packages above.

### Settings

Property | Description
---------|------------
ngconfig | Where to look the packages.config of solution-level.
ngconfig | Where to look the packages.config files.
ngserver | NuGet server.
ngpackages | List of packages. Uses first if defined, otherwise find packages.config
ngpath | Common path for all packages.

Sample:
Samples:

```bash

> msbuild.exe gnt.core /p:ngpath="special-packages/new"
```
```bash

> msbuild.exe gnt.core /p:ngconfig=".nuget/packages.config" /p:ngpath="../packages"
```

#### Format of list
#### Format of packages list

Property:

```bash
/p:ngpackages="id/version[:path];id2/version[:path];..."
/p:ngpackages="id[/version][:path]"
```

```bash
/p:ngpackages="id[/version][:path];id2[/version][:path];..."
```

.nuget\packages.config:
packages.config:

```xml

Expand All @@ -46,6 +56,16 @@ Property:
</packages>
```

#### Format of ngconfig

```bash
/p:ngconfig=".nuget/packages.config"
```
multiple:
```bash
/p:ngconfig=".nuget/packages.config|project1/packages.config|project2/packages.config|..."
```

## Examples

```bash
Expand All @@ -54,6 +74,24 @@ Property:
> msbuild.exe gnt.core /p:ngpackages="7z.Libs/15.12.0;vsSBE.CI.MSBuild/1.5.1:../packages/CI.MSBuild"
```

### Paths to msbuild.exe

Sample locations:

```bash

"C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe"
"C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
```

+GAC_32, GAC_64, ...

## Compact version

Simply use compressor from [here](https://github.com/3F/GetNuTool/tree/master/compact) if needed. Currently compact version ~4 Kb.

## License

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

[v1.1]
* FIXED: Incorrect path to Microsoft.Build.Tasks.dll with new MSBuild 14.0
* NEW: Compact version - `gnt-compact.core`
* CHANGED: Ignoring downloading if this folder is already exists. Remove folder to avoid restriction.

[v1.0]
* The first point - lightweight non-binary tool for getting the NuGet packages via MSBuild Tool


130 changes: 130 additions & 0 deletions compact/.compressor
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 Denis Kuzmin (reg) [ entry.reg@gmail.com ]
Distributed under the GetNuTool license
https://github.com/3F/GetNuTool
-->

<!--
Simple compressor of GetNuTool
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Main settings -->
<PropertyGroup>
<core Condition="'$(core)' == ''">..\gnt.core</core>
<output Condition="'$(output)' == ''">gnt-compact.core</output>
</PropertyGroup>

<!-- Entry point -->
<Target Name="handler" BeforeTargets="Build">
<Compress core="$(core)" output="$(output)" />
</Target>

<!-- Tasks settings -->
<PropertyGroup>
<TaskCoreDllPath Condition="Exists('$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll')">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll</TaskCoreDllPath>
<TaskCoreDllPath Condition="'$(TaskCoreDllPath)' == '' and Exists('$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll')">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</TaskCoreDllPath>
</PropertyGroup>

<!-- Prepares list for downloader below -->
<UsingTask
TaskName="Compress"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(TaskCoreDllPath)">

<ParameterGroup>
<core ParameterType="System.String" Required="true" />
<output ParameterType="System.String" Required="true" />
</ParameterGroup>

<Task>
<Using Namespace="System" />
<Using Namespace="System.Collections.Generic" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Func<char, string> quotes = delegate(char symbol)
{
return String.Format(@"
(?<!\\)
(
{0}(?:
(?:
[^{0}\\]
|
\\\\
|
\\{0}?
)*
){0}
)",
symbol);
};
using(StreamReader reader = new StreamReader(core, System.Text.Encoding.UTF8, true))
{
var content = reader.ReadToEnd();
var copyr = Regex.Match(content, @"(Copyright[^$]+?)$", RegexOptions.Multiline).Groups[1].Value.Trim();
var vers = Regex.Match(content, @"(GetNuTool[^$]+?)$", RegexOptions.Multiline).Groups[1].Value.Trim();
// protect strings
var strings = new Dictionary<uint, string>();
uint ident = 0;
content = Regex.Replace(content,
String.Format(@"({0}|{1})", quotes('"'), quotes('\'')),
delegate(Match m)
{
++ident;
strings[ident] = m.Groups[1].Value;
return String.Format("!s{0}!", ident);
},
RegexOptions.IgnorePatternWhitespace);
// C# code
content = Regex.Replace(content,
@"<!\[CDATA\[.+?\]\]>",
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*([{}()=+\-\[\]*?!@,;.])\s*", "$1");
return data;
},
RegexOptions.Singleline);
// common rules
content = content.Replace("\r", "").Replace("\n", "");
content = Regex.Replace(content, @"<!--.+?-->", "");
content = Regex.Replace(content, @">\s+<", "><");
content = Regex.Replace(content, @"\s{2,}", " ");
content = Regex.Replace(content, @"<\?xml.+?\?>", String.Format("<!-- {0} --><!-- {1} -->", vers, copyr));
// recover strings
content = Regex.Replace(content, @"!s(\d+)!", delegate (Match m) {
return strings[uint.Parse(m.Groups[1].Value)];
});
using(TextWriter writer = new StreamWriter(output, false, System.Text.Encoding.UTF8)) {
writer.Write(content);
}
Console.WriteLine("Compact version of `{0}` has been created -> `{1}`", core, output);
}
]]>
</Code>
</Task>
</UsingTask>

<!-- remap targets -->

<Target Name="Build" DependsOnTargets="handler" />

</Project>
1 change: 1 addition & 0 deletions compact/v12.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" .compressor
1 change: 1 addition & 0 deletions compact/v14.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe" .compressor
1 change: 1 addition & 0 deletions compact/v4.0.30319.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" .compressor
Loading

0 comments on commit 9d9bcc3

Please sign in to comment.