使用InstallAware部署Webservice

时间:2018-01-02 16:20:10

标签: web-services iis windows-installer iis-8 installaware

我创建了WCF Web服务并使用InstallAware创建了设置,以便我们的客户只需运行安装程序,它将在IIS中部署Web服务。我的设置在IIS中的“默认网站”下创建虚拟目录。一切正常,我的设置在“默认网站”下创建虚拟目录并指向正确的路径,但只有在设置完成之前它才会出错。以下是在IIS中创建虚拟目录的代码。

if Variable SUCCESS not Equals ERROR
    if Variable SUCCESS not Equals CANCEL
      Run Program $SUPPORTDIR$\InsertToken1.bat  (WAIT)
      Get IIS Index for Site "Default Web Site" into DEFAULTWEBSITEINDEXVAR
      Create Virtual Folder "WebService" in IIS Site #$DEFAULTWEBSITEINDEXVAR$, pointing to physical location $WWWROOTDIR$WebService
      Get System Setting IIS Anonymous User Account into INETUSR
      Set Read Permissions on File System Object "$WWWROOTDIR$\WebService" for $INETUSR$
    end
  end

调试MSI代码后,我发现后续行执行时会出现错误

Create Virtual Folder "WebService" in IIS Site #$DEFAULTWEBSITEINDEXVAR$, pointing to physical location $WWWROOTDIR$WebService

它出现以下错误

enter image description here

2 个答案:

答案 0 :(得分:1)

PowerShell命令可以满足需要。就像使用PowerShell命令创建FTP一样

您可以使用“ New-WebSite” 命令在IIS中创建一个WebSite。

  

使用powerShell创建FTP:

Import-Module WebAdministration

##CREATE FTP SITE AND SET C:\inetpub\ftproot AS HOME DIRECTORY
New-WebFtpSite -Name "FTPTmp" -Port "21" -Force
cmd /c \Windows\System32\inetsrv\appcmd set SITE "FTPTmp" "-virtualDirectoryDefaults.physicalPath:C:\Images"

## Allow SSL connections 
Set-ItemProperty "IIS:\Sites\FTPTmp" -Name ftpServer.security.ssl.controlChannelPolicy -Value 0
Set-ItemProperty "IIS:\Sites\FTPTmp" -Name ftpServer.security.ssl.dataChannelPolicy -Value 0

## Enable Basic Authentication
Set-ItemProperty "IIS:\Sites\FTPTmp" -Name ftpServer.security.authentication.basicAuthentication.enabled -Value $true

## Give Authorization to All Users and grant "read"/"write" privileges
Add-WebConfiguration "/system.ftpServer/security/authorization" -value @{accessType="Allow";roles="";permissions="Read,Write";users="*"} -PSPath IIS:\ -location "FTPTmp"

## Restart the FTP site for all changes to take effect
Restart-WebItem "IIS:\Sites\FTPTmp"

就像您也可以创建网站一样。

答案 1 :(得分:0)

我遇到了同样的问题。似乎最初没有设置WWWROOTDIR。在引用此变量之前,可以添加以下命令:

Get Folder Location WWW->WWWRoot into WWWROOTDIR