2012-03-23 3 views
2

Wix를 사용하여 다음 기존 IIS 구조 아래에 가상 디렉터리 foo를 만들려고합니다.wix를 사용하여 IIS의 폴더 아래에 가상 디렉터리를 만드는 방법

는 // 기본 웹 사이트 위의 코드에서/mywebapp와/편집기

는 'mywebapp와는'웹 applicatoin이며, 편집기는 그 내부가 아닌 가상 폴더입니다. 내 새 가상 디렉터리 'foo'는 비 가상 폴더 '편집기'안에 만들어야합니다.

IIS 7 및 Wix 3.5를 사용하고 있습니다.

태그를 사용하여 위 작업을 수행 할 수 있습니까? 아니면이를 수행하기 위해 사용자 지정 작업을 작성해야합니까?

미리 감사드립니다.

답변

0

마지막으로 나는 이것에 쉬운 해결책을 발견했다. webvirtualdir 요소의 alias 속성에 상대 경로를 사용할 수 있다는 것을 알게되었습니다. 그래서 나는 다음과 같은

  1. <iis:WebSite Id="My.Site" Description="Default Website"> 
        <iis:WebAddress Id="My.Web.Address" Port="12300"/> 
    </iis:WebSite> 
    
  2. 이 mywebapp와/에디터/foo는 설정 별명 webvirtualdir 요소를 추가 한 웹 사이트 요소를 사용하여 기본 웹 사이트를 참조되는 한 (웹 애플리케이션/하위 폴더/virtualdir 가상 폴더 foo는 만들 수 있습니다)

    <Directory Id="TARGETDIR" Name="SourceDir"> 
    <Directory Id="ProgramFilesFolder"> 
        <Directory Id="INSTALLLOCATION" Name="IISDemo"> 
         <Component Id="IIS.Component" Guid="{6FAD9EC7-D2B0-4471-A657-C8AF5F6F707F}" KeyPath="yes"> 
         <iis:WebVirtualDir Id="My.VirtualDir" Alias="mywebapp/editor/foo" Directory="INSTALLLOCATION" WebSite="My.Site">    
         </iis:WebVirtualDir> 
         </Component> 
        </Directory> 
        </Directory> 
    </Directory> 
    

이 솔루션은 간단한 있다는 것을 예상하지 않았다. 그러나 그 사이에 나는 동일한 것을 달성하기 위해 system.directoryservices를 사용하여 커스텀 액션을 작성했다. 그러나 이것은 더 간단하고 깔끔합니다. 같은 시나리오에 직면 한 사람에게 유용 할 수 있습니다.감사합니다

0

좋은 질문입니다.

필자는 직접적인 경험이 없지만 비슷한 도전에 직면했을 때 - 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 &amp;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 파일에서

아마도 유용 할 것입니다.

+0

답답해 주셔서 감사합니다. 쉬운 해결책을 찾았습니다. 답을 확인하십시오 ... – vinoth

관련 문제