Skip to content

Commit

Permalink
Implemented -unpack & -msbuild arguments for Executable version
Browse files Browse the repository at this point in the history
  • Loading branch information
3F committed Dec 5, 2016
1 parent b277818 commit 905c118
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,10 @@ Now, you can use it simply:
```

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

### Additional arguments

key | Description | Sample
----------------|---------------------------------------------------------|----------------
`-unpack` | To generate minified version from executable. `v1.5.1+` | `gnt -unpack`
`-msbuild` path | To use specific msbuild if needed. `v1.5.1+` | `gnt -msbuild "D:\MSBuild\bin\amd64\msbuild" /p:ngpackages="Conari"`
2 changes: 1 addition & 1 deletion compress.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

msbuild minified/.compressor /p:core="../gnt.core" /p:output="gnt.core" /nologo /v:m /m:4
msbuild minified/.compressor /p:core="../gnt.core" /p:output="gnt.core" /nologo /v:m /m:4 %*
7 changes: 5 additions & 2 deletions embedded/.packer
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PropertyGroup>
<core Condition="'$(core)' == ''">..\gnt.core</core>
<output Condition="'$(output)' == ''">gnt.bat</output>
<maxline Condition="'$(maxline)' == ''">1400</maxline> <!-- length of line / max 2047 or 8191 characters https://support.microsoft.com/en-us/kb/830473 -->
<maxline Condition="'$(maxline)' == ''">1572</maxline> <!-- length of line / max 2047 or 8191 characters https://support.microsoft.com/en-us/kb/830473 -->
</PropertyGroup>

<!-- Entry point -->
Expand Down Expand Up @@ -78,12 +78,15 @@
// but later we also should replace this double quotes :( that more problem for batch
content = content.Replace("%", "%%");
content = content.Replace("^", "^^");
// content = content.Replace("^", "^^"); - today we use it only inside double strings
content = content.Replace("&", "^&");
content = content.Replace("<", "^<");
content = content.Replace(">", "^>");
content = content.Replace("|", "^|");
// Required only when enableDelayedExpansion is active
//content = content.Replace("!", "^^!");
// Secondly, keep in mind where placed all strings.
// We will work without double quotes, so we should correctly define all pairs of "..." per line
Expand Down
38 changes: 30 additions & 8 deletions embedded/exec.tpl
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
@echo off
:: GetNuTool - Executable version
:: Copyright (c) 2015-2016 Denis Kuzmin [ [email protected] ]
:: https://github.com/3F/GetNuTool

set gntcore=gnt.core
set $tpl.corevar$=%temp%/%gntcore%
set $tpl.corevar$="%temp%\%random%%random%%gntcore%"

set args=%*
if "%args:~0,7%"=="-unpack" goto unpack
if "%args:~0,8%"=="-msbuild" goto ufound

for %%v in (14.0, 12.0, 15.0, 4.0, 3.5, 2.0) do (
for /F "usebackq tokens=2* skip=2" %%a in (
`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%%v" /v MSBuildToolsPath 2^> nul`
) do if exist %%b (
set msbuild="%%bmsbuild.exe"
set msbuild="%%b\msbuild.exe"
goto found
)
)
echo MSBuild was not found, try: gnt -msbuild "fullpath" args 1>&2
goto exit

echo MSBuild was not found. Please use it manually like: ` "full_path_to_msbuild.exe" %gntcore% arguments ` 1>&2

goto exit
:ufound
call :popa %1
shift
set msbuild=%1
call :popa %1

:found
call :core
%msbuild% %$tpl.corevar$% /nologo /p:wpath="%~dp0/" /v:m %args%
del /Q/F %$tpl.corevar$%
goto exit

<nul set /P ="">%$tpl.corevar$%
$gnt.core.logic$

:popa
call set args=%%args:%1^=%%
exit /B 0

%msbuild% %$tpl.corevar$% %* /nologo /verbosity:m /p:wpath="%~dp0/"
:unpack
set $tpl.corevar$=%~dp0\%gntcore%
echo Generate minified version in %$tpl.corevar$% ...

:core
<nul set /P ="">%$tpl.corevar$%
$gnt.core.logic$

:exit
2 changes: 1 addition & 1 deletion packing.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

compress & msbuild embedded/.packer /p:core="../minified/gnt.core" /p:output="gnt.bat" /nologo /v:m /m:4
compress & msbuild embedded/.packer /p:core="../minified/gnt.core" /p:output="gnt.bat" /nologo /v:m /m:4 %*

0 comments on commit 905c118

Please sign in to comment.