hMSBuild.bat 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. @echo off
  2. :: hMSBuild [Minified version] - v1.2.2.62992 [ 3ee58c3 ]
  3. :: Copyright (c) 2017 Denis Kuzmin [ entry.reg@gmail.com ]
  4. :: https://github.com/3F/hMSBuild
  5. setlocal enableDelayedExpansion
  6. set aa=1.0.62
  7. set ab=%temp%\hMSBuild_vswhere
  8. set /a ac=0
  9. set /a ad=0
  10. set /a ae=0
  11. set /a af=0
  12. set /a ag=0
  13. set /a ah=0
  14. set "ai="
  15. set "aj="
  16. set ak=0
  17. set al=2
  18. set am=3
  19. set "an=%* "
  20. set ao=%an:"=%
  21. set ap=%ao%
  22. set ap=%ap:-help =%
  23. set ap=%ap:-h =%
  24. set ap=%ap:-? =%
  25. if not "%ao%"=="%ap%" goto a_
  26. goto ba
  27. :a_
  28. echo.
  29. @echo :: hMSBuild [Minified version] - v1.2.2.62992 [ 3ee58c3 ]
  30. @echo Copyright (c) 2017 Denis Kuzmin [ entry.reg@gmail.com :: github.com/3F ]
  31. echo Distributed under the MIT license
  32. @echo https://github.com/3F/hMSBuild
  33. echo.
  34. @echo.
  35. @echo Usage: hMSBuild [args to hMSBuild] [args to msbuild.exe or GetNuTool core]
  36. echo ------
  37. echo.
  38. echo Arguments:
  39. echo ----------
  40. echo -novswhere - Do not search via vswhere.
  41. echo -novs - Disable searching from Visual Studio.
  42. echo -nonet - Disable searching from .NET Framework.
  43. echo -vswhere-version {num} - Specific version of vswhere. Where {num}:
  44. echo * Versions: 1.0.50 ...
  45. echo * Keywords:
  46. echo `latest` to get latest available version;
  47. echo `local` to use only local versions:
  48. echo (.bat;.exe /or from +15.2.26418.1 VS-build);
  49. echo.
  50. echo -nocachevswhere - Do not cache vswhere. Use this also for reset cache.
  51. echo -notamd64 - To use 32bit version of found msbuild.exe if it's possible.
  52. echo -eng - Try to use english language for all build messages.
  53. echo -GetNuTool {args} - Access to GetNuTool core. https://github.com/3F/GetNuTool
  54. echo -only-path - Only display fullpath to found MSBuild.
  55. echo -debug - To show additional information from hMSBuild.
  56. echo -version - Display version of hMSBuild.
  57. echo -help - Display this help. Aliases: -help -h -?
  58. echo.
  59. echo.
  60. echo --------
  61. echo Samples:
  62. echo --------
  63. echo hMSBuild -vswhere-version 1.0.50 -notamd64 "Conari.sln" /t:Rebuild
  64. echo hMSBuild -vswhere-version latest "Conari.sln"
  65. echo.
  66. echo hMSBuild -novswhere -novs -notamd64 "Conari.sln"
  67. echo hMSBuild -novs "DllExport.sln"
  68. echo hMSBuild vsSolutionBuildEvent.sln
  69. echo.
  70. echo hMSBuild -GetNuTool -unpack
  71. echo hMSBuild -GetNuTool /p:ngpackages="Conari;regXwild"
  72. echo.
  73. echo "hMSBuild -novs "DllExport.sln" || goto err"
  74. echo.
  75. echo ---------------------
  76. echo Possible Error Codes: ERROR_FILE_NOT_FOUND (0x2), ERROR_PATH_NOT_FOUND (0x3), ERROR_SUCCESS (0x0)
  77. echo ---------------------
  78. echo.
  79. exit /B 0
  80. :ba
  81. call :bb an _is
  82. if [!_is!]==[1] goto bc
  83. set /a aq=1 & set ar=12
  84. :bd
  85. if "!an:~0,11!"=="-GetNuTool " (
  86. call :be %1 & shift
  87. goto bf
  88. )
  89. if "!an:~0,11!"=="-novswhere " (
  90. call :be %1 & shift
  91. set af=1
  92. )
  93. if "!an:~0,16!"=="-nocachevswhere " (
  94. call :be %1 & shift
  95. set ag=1
  96. )
  97. if "!an:~0,6!"=="-novs " (
  98. call :be %1 & shift
  99. set ad=1
  100. )
  101. if "!an:~0,7!"=="-nonet " (
  102. call :be %1 & shift
  103. set ae=1
  104. )
  105. if "!an:~0,16!"=="-vswhereVersion " set as=1
  106. if "!an:~0,17!"=="-vswhere-version " set as=1
  107. if defined as (
  108. set "as="
  109. call :be %1 & shift
  110. set aj=%2
  111. echo selected new vswhere version: !aj!
  112. call :be %2 & shift
  113. )
  114. if "!an:~0,10!"=="-notamd64 " (
  115. call :be %1 & shift
  116. set ac=1
  117. )
  118. if "!an:~0,5!"=="-eng " (
  119. call :be %1 & shift
  120. chcp 437 >nul
  121. )
  122. if "!an:~0,11!"=="-only-path " (
  123. call :be %1 & shift
  124. set ai=1
  125. )
  126. if "!an:~0,7!"=="-debug " (
  127. call :be %1 & shift
  128. set ah=1
  129. )
  130. if "!an:~0,9!"=="-version " (
  131. @echo hMSBuild [Minified version] - v1.2.2.62992 [ 3ee58c3 ]
  132. exit /B 0
  133. )
  134. set /a "aq+=1"
  135. if !aq! LSS %ar% goto bd
  136. goto bc
  137. :be
  138. set an=!!an:%1 ^=!!
  139. call :bg an
  140. set "an=!an! "
  141. exit /B 0
  142. :bc
  143. if "!ag!"=="1" (
  144. call :bh "resetting cache of vswhere"
  145. rmdir /S/Q "%ab%" 2>nul
  146. )
  147. if not "!af!"=="1" if not "!ad!"=="1" (
  148. call :bi
  149. if "!ERRORLEVEL!"=="0" goto bj
  150. )
  151. if not "!ad!"=="1" (
  152. call :bk
  153. if "!ERRORLEVEL!"=="0" goto bj
  154. )
  155. if not "!ae!"=="1" (
  156. call :bl
  157. if "!ERRORLEVEL!"=="0" goto bj
  158. )
  159. echo MSBuild tools was not found. Try to use other settings. Use key `-help` for details.
  160. exit /B %al%
  161. :bj
  162. call :bb a0 _is
  163. if [!_is!]==[1] (
  164. echo Something went wrong. Use `-debug` key for details.
  165. exit /B %al%
  166. )
  167. if defined ai (
  168. echo !a0!
  169. exit /B 0
  170. )
  171. set at="!a0!"
  172. echo hMSBuild: !at!
  173. call :bh "Arguments: !an!"
  174. !at! !an!
  175. exit /B %ERRORLEVEL%
  176. :bi
  177. call :bh "trying via vswhere..."
  178. if defined aj (
  179. if not "!aj!"=="local" (
  180. call :bm
  181. call :bn
  182. exit /B !ERRORLEVEL!
  183. )
  184. )
  185. call :bo
  186. if "!ERRORLEVEL!"=="%am%" (
  187. if "!aj!"=="local" (
  188. exit /B %am%
  189. )
  190. call :bm
  191. )
  192. call :bn
  193. exit /B !ERRORLEVEL!
  194. :bo
  195. if exist "%~dp0vswhere.bat" set au="%~dp0vswhere" & exit /B 0
  196. if exist "%~dp0vswhere.exe" set au="%~dp0vswhere" & exit /B 0
  197. set av=Microsoft Visual Studio\Installer
  198. if exist "%ProgramFiles(x86)%\!av!" set au="%ProgramFiles(x86)%\!av!\vswhere" & exit /B 0
  199. if exist "%ProgramFiles%\!av!" set au="%ProgramFiles%\!av!\vswhere" & exit /B 0
  200. call :bh "local vswhere is not found."
  201. exit /B %am%
  202. :bm
  203. if "!ag!"=="1" (
  204. set aw=%temp%\%random%%random%vswhere
  205. ) else (
  206. set aw=%ab%
  207. )
  208. call :bh "tvswhere: !aw!"
  209. if "!aj!"=="latest" (
  210. set ax=vswhere
  211. ) else (
  212. set ax=vswhere/!aj!
  213. )
  214. call :bh "vswpkg: !ax!"
  215. if "!ah!"=="1" (
  216. call :bp /p:ngpackages="!ax!:vswhere" /p:ngpath="!aw!"
  217. ) else (
  218. call :bp /p:ngpackages="!ax!:vswhere" /p:ngpath="!aw!" >nul
  219. )
  220. set au="!aw!\vswhere\tools\vswhere"
  221. exit /B 0
  222. :bn
  223. call :bh "vswbin: "!au!""
  224. for /f "usebackq tokens=1* delims=: " %%a in (`!au! -latest -requires Microsoft.Component.MSBuild`) do (
  225. if /i "%%a"=="installationPath" set ay=%%b
  226. if /i "%%a"=="installationVersion" set az=%%b
  227. )
  228. call :bh "vspath: !ay!"
  229. call :bh "vsver: !az!"
  230. if defined aw (
  231. if "!ag!"=="1" (
  232. call :bh "reset vswhere"
  233. rmdir /S/Q "!aw!"
  234. )
  235. )
  236. if [!az!]==[] (
  237. call :bh "VS2017+ was not found via vswhere"
  238. exit /B %am%
  239. )
  240. for /f "tokens=1,2 delims=." %%a in ("!az!") do (
  241. set az=%%a.0
  242. )
  243. set a0=!ay!\MSBuild\!az!\Bin
  244. call :bh "found path to msbuild: !a0!"
  245. if exist "!a0!\amd64" (
  246. call :bh "found /amd64"
  247. set a0=!a0!\amd64
  248. )
  249. call :bq
  250. exit /B 0
  251. :bk
  252. call :bh "trying via MSBuild tools from Visual Studio - 2015, 2013, ..."
  253. for %%v in (14.0, 12.0) do (
  254. call :br %%v Y & if [!Y!]==[1] exit /B 0
  255. )
  256. call :bh "msbvsold: unfortunately we didn't find anything."
  257. exit /B %al%
  258. :bl
  259. call :bh "trying via MSBuild tools from .NET Framework - .net 4.0, ..."
  260. for %%v in (4.0, 3.5, 2.0) do (
  261. call :br %%v Y & if [!Y!]==[1] exit /B 0
  262. )
  263. call :bh "msbnetf: unfortunately we didn't find anything."
  264. exit /B %al%
  265. :br
  266. call :bh "checking of version: %1"
  267. for /F "usebackq tokens=2* skip=2" %%a in (
  268. `reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%1" /v MSBuildToolsPath 2^> nul`
  269. ) do if exist %%b (
  270. call :bh "found: %%b"
  271. set a0=%%b
  272. call :bq
  273. set /a %2=1
  274. exit /B 0
  275. )
  276. set /a %2=0
  277. exit /B 0
  278. :bf
  279. call :bh "direct access to GetNuTool..."
  280. call :bp !an!
  281. exit /B 0
  282. :bq
  283. set a0=!a0!\MSBuild.exe
  284. if not "!ac!" == "1" (
  285. exit /B 0
  286. )
  287. set a1=!a0:Framework64=Framework!
  288. set a1=!a1:amd64=!
  289. if exist "!a1!" (
  290. call :bh "Return 32bit version of MSBuild.exe because you wanted this via -notamd64"
  291. set a0=!a1!
  292. exit /B 0
  293. )
  294. call :bh "We know that 32bit version of MSBuild.exe is important for you, but we found only this."
  295. exit /B 0
  296. :bh
  297. if "!ah!"=="1" (
  298. set a2=%1
  299. set a2=!a2:~0,-1!
  300. set a2=!a2:~1!
  301. echo.[%TIME% ] !a2!
  302. )
  303. exit /B 0
  304. :bg
  305. call :a4 %%%1%%
  306. set %1=%a3%
  307. exit /B 0
  308. :a4
  309. set "a3=%*"
  310. exit /B 0
  311. :bb
  312. setlocal enableDelayedExpansion
  313. set "a4=!%1!"
  314. if not defined a4 endlocal & set /a %2=1 & exit /B 0
  315. set a4=%a4: =%
  316. set "a4= %a4%"
  317. if [^%a4:~1,1%]==[] endlocal & set /a %2=1 & exit /B 0
  318. endlocal & set /a %2=0
  319. exit /B 0
  320. :bp
  321. setlocal disableDelayedExpansion
  322. @echo off
  323. :: GetNuTool - Executable version
  324. :: Copyright (c) 2015-2017 Denis Kuzmin [ entry.reg@gmail.com ]
  325. :: https://github.com/3F/GetNuTool
  326. set a5=gnt.core
  327. set a6="%temp%\%random%%random%%a5%"
  328. set "an=%* "
  329. set a=%an:~0,30%
  330. set a=%a:"=%
  331. if "%a:~0,8%"=="-unpack " goto bs
  332. if "%a:~0,9%"=="-msbuild " goto bt
  333. for %%v in (4.0, 14.0, 12.0, 3.5, 2.0) do (
  334. for /F "usebackq tokens=2* skip=2" %%a in (
  335. `reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%%v" /v MSBuildToolsPath 2^> nul`
  336. ) do if exist %%b (
  337. set a7="%%b\MSBuild.exe"
  338. goto bu
  339. )
  340. )
  341. echo MSBuild was not found, try: gnt -msbuild "fullpath" args 1>&2
  342. exit /B 2
  343. :bt
  344. call :bv %1
  345. shift
  346. set a7=%1
  347. call :bv %1
  348. :bu
  349. call :bw
  350. %a7% %a6% /nologo /p:wpath="%~dp0/" /v:m %an%
  351. del /Q/F %a6%
  352. exit /B 0
  353. :bv
  354. call set an=%%an:%1 ^=%%
  355. exit /B 0
  356. :bs
  357. set a6="%~dp0\%a5%"
  358. echo Generate minified version in %a6% ...
  359. :bw
  360. <nul set /P ="">%a6%
  361. <nul set /P =^<!-- GetNuTool - github.com/3F/GetNuTool --^>^<!-- Copyright (c) 2015-2017 Denis Kuzmin [ entry.reg@gmail.com ] --^>^<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"^>^<PropertyGroup^>^<ngconfig Condition="'$(ngconfig)' == ''"^>packages.config^</ngconfig^>^<ngserver Condition="'$(ngserver)' == ''"^>https://www.nuget.org/api/v2/package/^</ngserver^>^<ngpackages Condition="'$(ngpackages)' == ''"^>^</ngpackages^>^<ngpath Condition="'$(ngpath)' == ''"^>packages^</ngpath^>^</PropertyGroup^>^<Target Name="get" BeforeTargets="Build" DependsOnTargets="header"^>^<PrepareList config="$(ngconfig)" plist="$(ngpackages)" wpath="$(wpath)"^>^<Output PropertyName="plist" TaskParameter="Result"/^>^</PrepareList^>^<NGDownload plist="$(plist)" url="$(ngserver)" wpath="$(wpath)" defpath="$(ngpath)" debug="$(debug)"/^>^</Target^>^<Target Name="pack" DependsOnTargets="header"^>^<NGPack dir="$(ngin)" dout="$(ngout)" wpath="$(wpath)" vtool="$(GetNuTool)" debug="$(debug)"/^>^</Target^>^<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^>^<UsingTask TaskName="PrepareList" TaskFactory="CodeTaskFactory" AssemblyFile="$(TaskCoreDllPath)"^>^<ParameterGroup^>^<config Parame>> %a6%
  362. <nul set /P =terType="System.String" Required="true"/^>^<plist ParameterType="System.String"/^>^<wpath ParameterType="System.String"/^>^<Result ParameterType="System.String" Output="true"/^>^</ParameterGroup^>^<Task^>^<Reference Include="System.Xml"/^>^<Reference Include="System.Xml.Linq"/^>^<Using Namespace="System"/^>^<Using Namespace="System.Collections.Generic"/^>^<Using Namespace="System.IO"/^>^<Using Namespace="System.Xml.Linq"/^>^<Code Type="Fragment" Language="cs"^>^<![CDATA[if(!String.IsNullOrEmpty(plist)){Result=plist;return true;}var _err=Console.Error;Action^<string,Queue^<string^>^> h=delegate(string cfg,Queue^<string^> list){foreach(var pkg in XDocument.Load(cfg).Descendants("package")){var id=pkg.Attribute("id");var version=pkg.Attribute("version");var output=pkg.Attribute("output");if(id==null){_err.WriteLine("Some 'id' does not exist in '{0}'",cfg);return;}var link=id.Value;if(version!=null){link+="/"+version.Value;}if(output!=null){list.Enqueue(link+":"+output.Value);continue;}list.Enqueue(link);}};var ret=new Queue^<string^>();foreach(var cfg in config.Split('^|',';')){var lcfg=Path.Combine(wpath,cfg??"");if(File.Exists(lcfg)){h(lcfg,ret);}else{_err.WriteLine(".config '{0}' was not found.",lcfg);}}if(ret.Count ^< 1){_err.WriteLine("List of packages is empty. Use .config or /p:ngpackages=\"...\"\n");}else{Result=String.Join(";",ret.ToArray());}]]^>^</Code^>^</Task^>^</UsingTask^>^<UsingTask TaskName="NGDownload" TaskFactory="CodeTaskFactory" AssemblyFile="$(TaskCoreDllPath)"^>^<ParameterGroup^>^<plist ParameterType="System.String"/^>^<url Paramet>> %a6%
  363. <nul set /P =erType="System.String" Required="true"/^>^<wpath ParameterType="System.String"/^>^<defpath ParameterType="System.String"/^>^<debug ParameterType="System.Boolean"/^>^</ParameterGroup^>^<Task^>^<Reference Include="WindowsBase"/^>^<Using Namespace="System"/^>^<Using Namespace="System.IO"/^>^<Using Namespace="System.IO.Packaging"/^>^<Using Namespace="System.Net"/^>^<Code Type="Fragment" Language="cs"^>^<![CDATA[if(plist==null){return false;}var ignore=new string[]{"/_rels/","/package/","/[Content_Types].xml"};Action^<string,object^> dbg=delegate(string s,object p){if(debug){Console.WriteLine(s,p);}};Func^<string,string^> loc=delegate(string p){return Path.Combine(wpath,p??"");};Action^<string,string,string^> get=delegate(string link,string name,string path){var to=Path.GetFullPath(loc(path??name));if(Directory.Exists(to)){Console.WriteLine("`{0}` is already exists: \"{1}\"",name,to);return;}Console.Write("Getting `{0}` ... ",link);var tmp=Path.Combine(Path.GetTempPath(),Guid.NewGuid().ToString());using(var l=new WebClient()){try{l.Headers.Add("User-Agent","GetNuTool");l.UseDefaultCredentials=true;l.DownloadFile(url+link,tmp);}catch(Exception ex){Console.Error.WriteLine(ex.Message);return;}}Console.WriteLine("Extracting into \"{0}\"",to);using(var pkg=ZipPackage.Open(tmp,FileMode.Open,FileAccess.Read)){foreach(var part in pkg.GetParts()){var uri=Uri.UnescapeDataString(part.Uri.OriginalString);if(ignore.Any(x=^> uri.StartsWith(x,StringComparison.Ordinal))){continue;}var dest=Path.Combine(to,uri.TrimStart('/'));dbg("- `{0}`",uri);var dir=Path.GetDirectoryNam>> %a6%
  364. <nul set /P =e(dest);if(!Directory.Exists(dir)){Directory.CreateDirectory(dir);}using(var src=part.GetStream(FileMode.Open,FileAccess.Read))using(var target=File.OpenWrite(dest)){try{src.CopyTo(target);}catch(FileFormatException ex){dbg("[x]?crc: {0}",dest);}}}}File.Delete(tmp);};foreach(var pkg in plist.Split(';')){var ident=pkg.Split(':');var link=ident[0];var path=(ident.Length ^> 1)?ident[1]: null;var name=link.Replace('/','.');if(!String.IsNullOrEmpty(defpath)){path=Path.Combine(defpath,path??name);}get(link,name,path);}]]^>^</Code^>^</Task^>^</UsingTask^>^<UsingTask TaskName="NGPack" TaskFactory="CodeTaskFactory" AssemblyFile="$(TaskCoreDllPath)"^>^<ParameterGroup^>^<dir ParameterType="System.String" Required="true"/^>^<dout ParameterType="System.String"/^>^<wpath ParameterType="System.String"/^>^<vtool ParameterType="System.String" Required="true"/^>^<debug ParameterType="System.Boolean"/^>^</ParameterGroup^>^<Task^>^<Reference Include="System.Xml"/^>^<Reference Include="System.Xml.Linq"/^>^<Reference Include="WindowsBase"/^>^<Using Namespace="System"/^>^<Using Namespace="System.Collections.Generic"/^>^<Using Namespace="System.IO"/^>^<Using Namespace="System.Linq"/^>^<Using Namespace="System.IO.Packaging"/^>^<Using Namespace="System.Xml.Linq"/^>^<Using Namespace="System.Text.RegularExpressions"/^>^<Code Type="Fragment" Language="cs"^>^<![CDATA[var EXT_NUSPEC=".nuspec";var EXT_NUPKG=".nupkg";var TAG_META="metadata";var DEF_CONTENT_TYPE="application/octet";var MANIFEST_URL="http://schemas.microsoft.com/packaging/2010/07/manifest";var ID="id";var VER="version">> %a6%
  365. <nul set /P =;Action^<string,object^> dbg=delegate(string s,object p){if(debug){Console.WriteLine(s,p);}};var _err=Console.Error;dir=Path.Combine(wpath,dir);if(!Directory.Exists(dir)){_err.WriteLine("`{0}` was not found.",dir);return false;}dout=Path.Combine(wpath,dout??"");var nuspec=Directory.GetFiles(dir,"*"+EXT_NUSPEC,SearchOption.TopDirectoryOnly).FirstOrDefault();if(nuspec==null){_err.WriteLine("{0} was not found in `{1}`",EXT_NUSPEC,dir);return false;}Console.WriteLine("Found {0}: `{1}`",EXT_NUSPEC,nuspec);var root=XDocument.Load(nuspec).Root.Elements().FirstOrDefault(x=^> x.Name.LocalName==TAG_META);if(root==null){_err.WriteLine("{0} does not contain {1}.",nuspec,TAG_META);return false;}var metadata=new Dictionary^<string,string^>();foreach(var tag in root.Elements()){metadata[tag.Name.LocalName.ToLower()]=tag.Value;}if(metadata[ID].Length ^> 100 ^|^|!Regex.IsMatch(metadata[ID],@"^\w+([_.-]\w+)*$",RegexOptions.IgnoreCase ^| RegexOptions.ExplicitCapture)){_err.WriteLine("The format of `{0}` is not correct.",ID);return false;}var ignore=new string[]{Path.Combine(dir,"_rels"),Path.Combine(dir,"package"),Path.Combine(dir,"[Content_Types].xml")};var pout=String.Format("{0}.{1}{2}",metadata[ID],metadata[VER],EXT_NUPKG);if(!String.IsNullOrWhiteSpace(dout)){if(!Directory.Exists(dout)){Directory.CreateDirectory(dout);}pout=Path.Combine(dout,pout);}Console.WriteLine("Started packing `{0}` ...",pout);using(var pkg=Package.Open(pout,FileMode.Create)){var manifestUri=new Uri(String.Format("/{0}{1}",metadata[ID],EXT_NUSPEC),UriKind.Relative);pkg.CreateRelationship(manif>> %a6%
  366. <nul set /P =estUri,TargetMode.Internal,MANIFEST_URL);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;}dbg("- `{0}`",pUri);var escaped=String.Join("/",pUri.Split('\\','/').Select(p=^> Uri.EscapeDataString(p)));var uri=PackUriHelper.CreatePartUri(new Uri(escaped,UriKind.Relative));var part=pkg.CreatePart(uri,DEF_CONTENT_TYPE,CompressionOption.Maximum);using(var tstream=part.GetStream())using(var fs=new FileStream(file,FileMode.Open,FileAccess.Read)){fs.CopyTo(tstream);}}Func^<string,string^> getmeta=delegate(string key){return(metadata.ContainsKey(key))?metadata[key]:"";};var _p=pkg.PackageProperties;_p.Creator=getmeta("authors");_p.Description=getmeta("description");_p.Identifier=metadata[ID];_p.Version=metadata[VER];_p.Keywords=getmeta("tags");_p.Title=getmeta("title");_p.LastModifiedBy="GetNuTool v"+vtool;}]]^>^</Code^>^</Task^>^</UsingTask^>^<Target Name="Build" DependsOnTargets="get"/^>^<PropertyGroup^>^<GetNuTool^>1.6.1.10620_bde3e50^</GetNuTool^>^<wpath Condition="'$(wpath)' == ''"^>$(MSBuildProjectDirectory)^</wpath^>^</PropertyGroup^>^<Target Name="header"^>^<Message Text="%%0D%%0AGetNuTool v$(GetNuTool) - github.com/3F%%0D%%0A=========%%0D%%0A" Importance="high"/^>^</Target^>^</Project^>>> %a6%
  367. exit /B 0