wix unexpected child element 'Website'

2019-07-16 05:11发布

With the code below, everything compiles without any error. But when I run the resulting MSI, I don't see any site created in IIS:

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>
  <iis:WebSite Id='dp_service_site' Description='Default Web Site'>
    <iis:WebAddress Id="AllUnassigned" Port="80" />
  </iis:WebSite>
  .
  .
  <DirectoryRef Id='DPDIR'>
    <Component Id='dservice' DiskId='1' Guid ='21e0c49d-e9a6-4de6-894c-d0632ea45f5a'>
      <iis:WebVirtualDir Id='dp_wvd' Alias="DocumentPublisher" Directory='DPDIR'   WebSite='dp_service_site'>           
        <iis:WebApplication Id='dp_app' Name='Default Application' WebAppPool='dp_pool' Isolation='medium'>
        </iis:WebApplication>
      </iis:WebVirtualDir>          
      <iis:WebAppPool Id='dp_pool' Identity='networkService' Name='dservice' />
    </Component>
  </DirectoryRef>
  .
  .
  <Feature Id='Service' Title='Document Service' Level='1'>
    <ComponentRef Id='dservice' />
  </Feature>
</Wix>

I am getting error. I have changed the code as per you have mentioned above. I have attached the screenshot along with this

标签: wix wix3
1条回答
Animai°情兽
2楼-- · 2019-07-16 06:15

I believe the issue here is that you are not creating the WebSite within a component, so instead the installer is just trying to do a lookup for an existing website. Instead you should probably have something like this:

<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>

  .
  .
  <DirectoryRef Id='DPDIR'>
    <Component Id='dservice' DiskId='1' Guid ='21e0c49d-e9a6-4de6-894c-d0632ea45f5a'>
      <iis:WebVirtualDir Id='dp_wvd' Alias="DocumentPublisher" Directory='DPDIR'   WebSite='dp_service_site'>           
        <iis:WebApplication Id='dp_app' Name='Default Application' WebAppPool='dp_pool' Isolation='medium'>
        </iis:WebApplication>
      </iis:WebVirtualDir>          
      <iis:WebAppPool Id='dp_pool' Identity='networkService' Name='dservice' />
    </Component>
    <Component Id='website'>
      <iis:WebSite Id='dp_service_site' Description='Default Web Site' Directory='DPDIR'>
        <iis:WebAddress Id="AllUnassigned" Port="80" />
      </iis:WebSite>
    </Component>
  </DirectoryRef>
  .
  .
  <Feature Id='Service' Title='Document Service' Level='1'>
    <ComponentRef Id='dservice' />
    <ComponentRef Id'website' />
  </Feature>
</Wix>

So then the website will be created as a separate component. I believe that since you have specified a port number, if a website already exists on that port then it will modify that existing website instead of creating a new one.

UPDATE: As the error indicated, you need to add a Directory attribute to the WebSite element pointing to 'DPDIR'. I have updated my example above.

查看更多
登录 后发表回答