From 905c1182219641e81287c2daf678db28a136f648 Mon Sep 17 00:00:00 2001 From: "Denis Kuzmin (reg)" Date: Mon, 5 Dec 2016 22:10:20 +0300 Subject: [PATCH] Implemented `-unpack` & `-msbuild` arguments for Executable version --- README.md | 7 +++++++ compress.bat | 2 +- embedded/.packer | 7 +++++-- embedded/exec.tpl | 38 ++++++++++++++++++++++++++++++-------- packing.bat | 2 +- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 83ebc0f..e314e96 100644 --- a/README.md +++ b/README.md @@ -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"` \ No newline at end of file diff --git a/compress.bat b/compress.bat index 63fa8c1..fc580f0 100644 --- a/compress.bat +++ b/compress.bat @@ -1,3 +1,3 @@ @echo off -msbuild minified/.compressor /p:core="../gnt.core" /p:output="gnt.core" /nologo /v:m /m:4 \ No newline at end of file +msbuild minified/.compressor /p:core="../gnt.core" /p:output="gnt.core" /nologo /v:m /m:4 %* \ No newline at end of file diff --git a/embedded/.packer b/embedded/.packer index 4f3f607..b0bea7f 100644 --- a/embedded/.packer +++ b/embedded/.packer @@ -15,7 +15,7 @@ ..\gnt.core gnt.bat - 1400 + 1572 @@ -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 diff --git a/embedded/exec.tpl b/embedded/exec.tpl index b748c26..440bf48 100644 --- a/embedded/exec.tpl +++ b/embedded/exec.tpl @@ -1,27 +1,49 @@ @echo off +:: GetNuTool - Executable version +:: Copyright (c) 2015-2016 Denis Kuzmin [ entry.reg@gmail.com ] +:: 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 -%$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 +%$tpl.corevar$% +$gnt.core.logic$ :exit \ No newline at end of file diff --git a/packing.bat b/packing.bat index c76ffdc..5d3f685 100644 --- a/packing.bat +++ b/packing.bat @@ -1,3 +1,3 @@ @echo off -compress & msbuild embedded/.packer /p:core="../minified/gnt.core" /p:output="gnt.bat" /nologo /v:m /m:4 \ No newline at end of file +compress & msbuild embedded/.packer /p:core="../minified/gnt.core" /p:output="gnt.bat" /nologo /v:m /m:4 %* \ No newline at end of file