좋은 질문입니다.
필자는 직접적인 경험이 없지만 비슷한 도전에 직면했을 때 - WiX를 사용하여 특정 가상 디렉터리에 IIS 확장으로 ISAPI를 설치합니다. - Javascript로 구현 된 사용자 지정 동작을 사용하고 케이스, VBScript. 필자는 WiX에 필요한 일부 기능이 있다는 것을 알았지 만 정확한 정보를 찾는 것이 어려웠으며 모든 IIS 관리 기능이 WiX를 통해 노출되는 것은 아닙니다. 또한 모든 IIS Admin 작업이 Javascript에 노출되는 것은 아니지만 믿을 수 있습니다. 한 경우 WMI 인터페이스에는 VBArray가 필요합니다. !! !!
또한 IIS WMI (프로그래밍) 인터페이스에만 의존하기보다는 사용자 지정 작업 내에서 코드가 실제 작업을 수행하기 위해 APPCMD.exe를 호출하는 경우가 있습니다. 만약 당신이 사전 req IIS7 그러면 당신은 이것을해야합니다. appcmd를 사용하여 vdir 또는 app을 만드는 것은 매우 간단합니다 (appcmd add app
또는 appcmd add vdir
). 가장 어려운 부분은 필자가 필요로하는 Javascript 및 WiX 코드를 둘러싼 것입니다. 여기 내가 어떻게 그랬어.
<InstallExecuteSequence>
...
<!-- configure extension if we need it -->
<Custom Action="CA.AddExtension" After="InstallFiles">NOT Installed AND &F.Binary = 3</Custom>
...
</InstallExecuteSequence>
후 별도의 customactions.wxs 파일있다 :
function RunAppCmd(command, deleteOutput) {
deleteOutput = deleteOutput || false;
LogMessage("RunAppCmd("+command+") ENTER");
var shell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tmpdir = fso.GetSpecialFolder(SpecialFolders.TemporaryFolder);
var tmpFileName = fso.BuildPath(tmpdir, fso.GetTempName());
var windir = fso.GetSpecialFolder(SpecialFolders.WindowsFolder);
var appcmd = fso.BuildPath(windir,"system32\\inetsrv\\appcmd.exe") + " " + command;
LogMessage("shell.Run("+appcmd+")");
// use cmd.exe to redirect the output
var rc = shell.Run("%comspec% /c " + appcmd + "> " + tmpFileName, WindowStyle.Hidden, true);
LogMessage("shell.Run rc = " + rc);
if (deleteOutput) {
fso.DeleteFile(tmpFileName);
}
return {
rc : rc,
outputfile : (deleteOutput) ? null : tmpFileName
};
}
// GetWebSites_Appcmd()
//
// Gets website info using Appcmd.exe, only on IIS7+ .
//
// This fn always returns site state info with each record.
//
function GetWebSites_Appcmd() {
var ParseOneLine = function(oneLine) {
// split the string: capture quoted strings, or a string surrounded
// by parens, or lastly, tokens separated by spaces,
var tokens = oneLine.match(/"[^"]+"|\(.+\)|[^ ]+/g);
// split the 3rd string: it is a set of properties separated by colons
var props = tokens[2].slice(1,-1);
var t2 = props.match(/\w+:.+?(?=,\w+:|$)/g);
var bindingsString = t2[1];
//say(bindingsString);
var ix1 = bindingsString.indexOf(':');
var t3 = bindingsString.substring(ix1+1).split(',');
var bindings = {};
for (var i=0; i<t3.length; i++) {
var split = t3[i].split('/');
var obj = {};
if (split[0] == "net.tcp") {
var p2 = split[1].split(':');
obj.port = p2[0];
}
else if (split[0] == "net.pipe") {
var p3 = split[1].split(':');
obj.other = p3[0];
}
else if (split[0] == "http") {
var p4 = split[1].split(':');
obj.ip = p4[0];
if (p4[1]) {
obj.port = p4[1];
}
obj.hostname = "";
}
else {
var p5 = split[1].split(':');
obj.hostname = p5[0];
if (p5[1]) {
obj.port = p5[1];
}
}
bindings[split[0]] = obj;
}
// return the object describing the website
return {
id : t2[0].split(':')[1],
name : "W3SVC/" + t2[0].split(':')[1],
description : tokens[1].slice(1,-1),
bindings : bindings,
state : t2[2].split(':')[1] // started or not
};
};
LogMessage("GetWebSites_Appcmd() ENTER");
var r = RunAppCmd("list sites");
if (r.rc !== 0) {
// 0x80004005 == E_FAIL
throw new Exception("ApplicationException", "exec appcmd.exe returned nonzero rc ("+r.rc+")", 0x80004005);
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var textStream = fso.OpenTextFile(r.outputfile, OpenMode.ForReading);
var sites = [];
// Read from the file and parse the results.
while (!textStream.AtEndOfStream) {
var oneLine = textStream.ReadLine();
var line = ParseOneLine(oneLine);
LogMessage(" site: " + line.name);
sites.push(line);
}
textStream.Close();
fso.DeleteFile(r.outputfile);
LogMessage("GetWebSites_Appcmd() EXIT");
return sites;
}
: 다음
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Binary Id="B.JavaScript" SourceFile="CustomActions.js" />
<Binary Id="B.VBScript" SourceFile="MoreCustomActions.vbs" />
<CustomAction Id="CA.EnumerateWebSites"
BinaryKey="B.JavaScript"
JScriptCall="EnumerateWebSites_CA"
Execute="immediate"
Return="check" />
<CustomAction Id="CA.AddExtension"
BinaryKey="B.VBScript"
VBScriptCall="AddExtension_CA"
Execute="immediate"
Return="check" />
....
그리고
이 자바 스크립트는이처럼 보였다는 주 product.wxs 파일에서
아마도 유용 할 것입니다.
답답해 주셔서 감사합니다. 쉬운 해결책을 찾았습니다. 답을 확인하십시오 ... – vinoth