From 4708531f2132ab44c7bd5c8e2fa7dc5a82280a82 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Wed, 4 Jan 2017 11:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/Publish.vbs | 234 +++++++++++++++++++++++--------------------- 1 file changed, 120 insertions(+), 114 deletions(-) diff --git a/Scripts/Publish.vbs b/Scripts/Publish.vbs index 4d9f2ae5..cf2ccb31 100644 --- a/Scripts/Publish.vbs +++ b/Scripts/Publish.vbs @@ -1,115 +1,121 @@ -Option Explicit - -Dim fso, shell -Dim targetDir, targetName, extName, keyFile, destDir, solutionDir, cmd, file, assemblyDir, outDir -Dim msg(), m - -keyFile = "D:\src\Longbow\Keys\Longbow.Utility.snk" -destDir = "D:\src\Longbow\BootstrapAdmin\Publish\Web-App\WebConsole" -assemblyDir = "C:\Longbow.Utility 2005\Release" -Set shell = WScript.CreateObject("WScript.Shell") -Set fso = CreateObject("Scripting.FileSystemObject") - -If WScript.Arguments.Count > 0 Then - targetDir = WScript.Arguments(0) -End If - -If WScript.Arguments.Count > 1 Then - targetName = WScript.Arguments(1) -End If - -If WScript.Arguments.Count > 2 Then - extName = WScript.Arguments(2) -End If - -If WScript.Arguments.Count > 3 Then - solutionDir = WScript.Arguments(3) -End If - -If WScript.Arguments.Count > 4 Then - outDir = WScript.Arguments(4) -End If - -If WScript.Arguments.Count > 5 Then - If WScript.Arguments(5) = "Debug" Then - ReSignFile targetDir & targetName & extName - WScript.Echo WScript.Arguments(5) & " Mode... Quit copy AFTER Re-signed assembly" - WScript.Quit - Else - If extName = ".dll" Then - WScript.Echo WScript.Arguments(5) & " Mode... Quit copy BEFORE Re-signed assembly" - WScript.Quit - End If - End If -End If - -destDir = destdir & targetName & "\" -If NOT fso.FolderExists(destDir) then - fso.CreateFolder(destDir) -End If - -If NOT fso.FolderExists(destdir & "Original\") then - fso.CreateFolder(destdir & "Original\") -End If - -If extName = ".exe" Then - CopyFile fso, targetDir, destDir, targetName & extName & ".config", true -End If -CopyFile fso, targetDir, destdir & "Original\", targetName & extName, true - -ReDim msg(0) -msg(0) = """D:\src\Longbow\Scripts\LgbSign.bat"" """ & destdir & targetName & extName & """" - -For Each file in fso.GetFolder(targetDir).Files - If fso.GetExtensionName(file) = "dll" then - If NOT CopyFile(fso, assemblyDir, destDir, file.Name, false) Then - ReDim Preserve msg(UBound(msg)+1) - msg(UBound(msg)) = """D:\src\Longbow\Scripts\LgbSign.bat"" """ & destdir & file.Name & """" - CopyFile fso, solutionDir & GetFileName(file.Name) & "\" & outDir, destDir & "Original\", file.Name, true - ReSignFile targetdir & file.Name - Else - CopyFile fso, assemblyDir, destDir & "Original\", file.Name, true - End If - End If -Next - -ReSignFile targetDir & targetName & extName -Wscript.Echo "Ready for DotFuscator... After Dotfuscator run the following command Please!" - -For Each m in msg - Wscript.Echo m -Next - -Function CopyFile(fso, targetDir, destDir, targetName, show) - If fso.FileExists(targetDir & targetName) then - fso.CopyFile targetDir & targetName, destDir & targetName, True - Wscript.Echo targetDir & targetName & " --> " & destDir & targetName & " Copied!" - CopyFile = True - Else - If show then - Wscript.Echo "Missing " & targetDir & targetName & " Not Copied!" - end if - CopyFile = False - End If -End Function - -Function GetFileName(fileName) - Dim pos, index - index = 1 - Do - pos = index + 1 - index = InStr(pos, fileName, ".") - Loop while index > 0 - - If pos > 0 Then - GetFileName = Left(fileName, pos -2) - Else - GetFileName = fileName - End If -End Function - -Sub ReSignFile(fileName) - cmd = """%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe"" -R """ & fileName & """ " & keyFile - shell.run cmd, 0, True - WScript.Echo "Assembly '" & fileName & "' successfully re-signed" +Option Explicit + +Dim fso, shell +Dim targetDir, targetName, extName, keyFile, destDir, solutionDir, cmd, file, assemblyDir, outDir, batFile, signCmd +Dim msg(), m + +keyFile = "..\Keys\Longbow.Utility.snk" +destDir = "Publish\Web-App\WebConsole" +assemblyDir = "C:\Longbow.Utility 2005\Release" +batFile = "..\Scripts\LgbSign.bat" +signCmd = "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe" + +Set shell = WScript.CreateObject("WScript.Shell") +Set fso = CreateObject("Scripting.FileSystemObject") + +If WScript.Arguments.Count > 0 Then + targetDir = WScript.Arguments(0) +End If + +If WScript.Arguments.Count > 1 Then + targetName = WScript.Arguments(1) +End If + +If WScript.Arguments.Count > 2 Then + extName = WScript.Arguments(2) +End If + +If WScript.Arguments.Count > 3 Then + solutionDir = WScript.Arguments(3) + keyFile = solutionDir & keyFile + destDir = solutionDir & destDir + batFile = solutionDir & batFile +End If + +If WScript.Arguments.Count > 4 Then + outDir = WScript.Arguments(4) +End If + +If WScript.Arguments.Count > 5 Then + If WScript.Arguments(5) = "Debug" Then + ReSignFile targetDir & targetName & extName + WScript.Echo WScript.Arguments(5) & " Mode... Quit copy AFTER Re-signed assembly" + WScript.Quit + Else + If extName = ".dll" Then + WScript.Echo WScript.Arguments(5) & " Mode... Quit copy BEFORE Re-signed assembly" + WScript.Quit + End If + End If +End If + +destDir = destdir & targetName & "\" +If NOT fso.FolderExists(destDir) then + fso.CreateFolder(destDir) +End If + +If NOT fso.FolderExists(destdir & "Original\") then + fso.CreateFolder(destdir & "Original\") +End If + +If extName = ".exe" Then + CopyFile fso, targetDir, destDir, targetName & extName & ".config", true +End If +CopyFile fso, targetDir, destdir & "Original\", targetName & extName, true + +ReDim msg(0) +msg(0) = """" & batFile & """ """ & destdir & targetName & extName & """ """ & keyFile + +For Each file in fso.GetFolder(targetDir).Files + If fso.GetExtensionName(file) = "dll" then + If NOT CopyFile(fso, assemblyDir, destDir, file.Name, false) Then + ReDim Preserve msg(UBound(msg)+1) + msg(UBound(msg)) = """" & signCmd & """ """ & destdir & file.Name & """" + CopyFile fso, solutionDir & GetFileName(file.Name) & "\" & outDir, destDir & "Original\", file.Name, true + ReSignFile targetdir & file.Name + Else + CopyFile fso, assemblyDir, destDir & "Original\", file.Name, true + End If + End If +Next + +ReSignFile targetDir & targetName & extName +Wscript.Echo "Ready for DotFuscator... After Dotfuscator run the following command Please!" + +For Each m in msg + Wscript.Echo m +Next + +Function CopyFile(fso, targetDir, destDir, targetName, show) + If fso.FileExists(targetDir & targetName) then + fso.CopyFile targetDir & targetName, destDir & targetName, True + Wscript.Echo targetDir & targetName & " --> " & destDir & targetName & " Copied!" + CopyFile = True + Else + If show then + Wscript.Echo "Missing " & targetDir & targetName & " Not Copied!" + end if + CopyFile = False + End If +End Function + +Function GetFileName(fileName) + Dim pos, index + index = 1 + Do + pos = index + 1 + index = InStr(pos, fileName, ".") + Loop while index > 0 + + If pos > 0 Then + GetFileName = Left(fileName, pos -2) + Else + GetFileName = fileName + End If +End Function + +Sub ReSignFile(fileName) + cmd = """"& signCmd &""" -R """ & fileName & """ " & keyFile + shell.run cmd, 0, True + WScript.Echo "Assembly '" & fileName & "' successfully re-signed" End Sub \ No newline at end of file