我一直在浏览数十个网站,以帮助我使用MsDeploy将Web服务部署到IIS。 我需要创建应用程序,修改应用程序池并启用协议,并更新appSetting(包含连接字符串,不要问我原因)。
我可以做所有这些,除了应用好的应用程序池。
这是我添加到项目中的parameters.xml文件:
<parameters>
<parameter tags="IisApp" defaultValue="Default Web Site/MyWebService" name="IIS Web Application Name">
<parameterEntry match="@defaultValue" scope="IisApp" kind="ProviderPath"/>
<parameterEntry match="@defaultValue" scope="setAcl" kind="ProviderPath"/>
</parameter>
<parameter name="Configuration Connection String" defaultValue="Some real Connection String in there" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/appSettings/add[@key='ConfigurationSQLConnectionString']/@value" />
</parameter>
<parameter name="Application Pool" defaultValue="MyOwnAppPool" description="Application pool for this site">
<parameterEntry kind="DeploymentObjectAttribute" scope="application" match="/application/@applicationPool" />
</parameter>
</parameters>
这是我生成包的方式:
MsBuild MyWebService.csproj /T:Package /P:PackageLocation="c:\somewhere\package.zip" /P:IncludeAppPool=true /P:IncludeIisSettings=true
这是生成的archive.xml文件:
<sitemanifest MSDeploy.ObjectResolver.dirPath="Microsoft.Web.Deployment.DirPathObjectResolver" MSDeploy.ObjectResolver.filePath="Microsoft.Web.Deployment.FilePathObjectResolver">
<appHostConfig path="Default Web Site/MyWebService" MSDeploy.path="2" MSDeploy.MSDeployLinkName="Child1" MSDeploy.MSDeployKeyAttributeName="path" MSDeploy.MSDeployProviderOptions="some stuff">
<application path="/MyWebService" MSDeploy.path="2" applicationPool="DefaultAppPool" MSDeploy.applicationPool="1" enabledProtocols="http" MSDeploy.enabledProtocols="1" serviceAutoStartEnabled="false" MSDeploy.serviceAutoStartEnabled="1" serviceAutoStartProvider="" MSDeploy.serviceAutoStartProvider="1" MSDeploy.MSDeployLinkName="PathElement" MSDeploy.MSDeployKeyAttributeName="path">
<virtualDirectoryDefaults path="" MSDeploy.path="1" physicalPath="" MSDeploy.physicalPath="9" userName="" MSDeploy.userName="1" password="" MSDeploy.password="1" logonMethod="ClearText" MSDeploy.logonMethod="1" allowSubDirConfig="true" MSDeploy.allowSubDirConfig="1" MSDeploy.MSDeployLinkName="virtualDirectoryDefaults" />
<virtualDirectory path="/" MSDeploy.path="2" physicalPath="C:\somewhere\MyWebService" MSDeploy.physicalPath="8" userName="" MSDeploy.userName="1" password="" MSDeploy.password="1" logonMethod="ClearText" MSDeploy.logonMethod="1" allowSubDirConfig="true" MSDeploy.allowSubDirConfig="1" MSDeploy.MSDeployKeyAttributeName="path" />
</application>
</appHostConfig>
<contentPath path="C:\somewhere\MyWebService\obj\Debug\Package\PackageTmp" MSDeploy.path="2" MSDeploy.MSDeployLinkName="Child2" MSDeploy.MSDeployKeyAttributeName="path" MSDeploy.MSDeployProviderOptions="some other stuff">
<MSDeploy.dirPath path="C:\somewhere\MyWebSerivce\obj\Debug\Package\PackageTmp" MSDeploy.MSDeployLinkName="contentPath" />
</contentPath>
<setAcl path="C:\somewhere\MyWebService\obj\Debug\Package\PackageTmp" MSDeploy.path="2" isDest="AA==" MSDeploy.isDest.Type="Microsoft.Web.Deployment.DeploymentObjectBooleanAttributeValue" setAclUser="" MSDeploy.setAclUser="1" setAclAccess="Read" MSDeploy.setAclAccess="1" MSDeploy.MSDeployLinkName="Child3" MSDeploy.MSDeployKeyAttributeName="path" MSDeploy.MSDeployProviderOptions="still some stuff" />
<setAcl path="C:\somewhere\MyWebService\obj\Debug\Package\PackageTmp" MSDeploy.path="2" isDest="AA==" MSDeploy.isDest.Type="Microsoft.Web.Deployment.DeploymentObjectBooleanAttributeValue" setAclUser="anonymousAuthenticationUser" MSDeploy.setAclUser="1" setAclAccess="Read" MSDeploy.setAclAccess="1" MSDeploy.MSDeployLinkName="Child4" MSDeploy.MSDeployKeyAttributeName="path" MSDeploy.MSDeployProviderOptions="final stuff I guess" />
</sitemanifest>
这是生成的parameters.xml:
<parameters>
<parameter name="IIS Web Application Name" defaultValue="Default Web Site/MyWebService" tags="IisApp">
<parameterEntry kind="ProviderPath" scope="AppHostConfig" match="^Default\ Web\ Site/MyWebService$" />
<parameterEntry kind="ProviderPath" scope="contentPath" match="^C:\\somewhere\\MyWebService\\obj\\Debug\\Package\\PackageTmp$" />
<parameterEntry kind="ProviderPath" scope="setAcl" match="^C:\\somewhere\\MyWebService\\obj\\Debug\\Package\\PackageTmp$" />
<parameterEntry kind="ProviderPath" scope="IisApp" match="@defaultValue" />
<parameterEntry kind="ProviderPath" scope="setAcl" match="@defaultValue" />
</parameter>
<parameter name="IIS Web Application Pool Name" defaultValue="DefaultAppPool">
<parameterEntry kind="DeploymentObjectAttribute" scope="application" match="application[@applicationPool='DefaultAppPool']/@applicationPool" />
</parameter>
<parameter name="IisVirtualDirectoryPhysicalPath" defaultValue="C:\somewhere\MyWebService" tags="PhysicalPath">
<parameterEntry kind="DestinationVirtualDirectory" scope=".*" match="^C:\\somewhere\\MyWebService$" />
</parameter>
<parameter name="Configuration Connection String" defaultValue="Some real Connection String in there">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/appSettings/add[@key='ConfigurationSQLConnectionString']/@value" />
</parameter>
<parameter name="Application Pool" description="Application pool for this site" defaultValue="MyOwnAppPool">
<parameterEntry kind="DeploymentObjectAttribute" scope="application" match="/application/@applicationPool" />
</parameter>
</parameters>
最后,这是我启动部署程序包的命令:
msdeploy.exe -verb:sync -allowUntrusted -enableLink:AppPoolExtension -source:package="c:\somewhere\Package.zip" -dest:auto,computerName="https://destinationserver:8172/MsDeploy.axd?site=WebSite_Deployment",userName="destinationserver\deploymentUser",password="shouldKeepItSecret",authType="basic" -setParam:name="IIS Web Application Name",value="WebSite_Deployment/MyWebService" -setParam:name="Configuration Connection String",value="The Real Connection String" -setParam:name="Application Pool",value="FinalAppPool" -setParam:name="IIS Web Application Pool Name",value="FinalAppPool" -verbose
我得到以下日志:
Verbose: Parameter entry 'IIS Web Application Pool Name/1' is applicable to 'sitemanifest/appHostConfig[@path='Default Web Site/MyWebService']/application[@path='/MyWebService']' because of its scope.
Verbose: Parameter entry 'Application Pool/1' is applicable to 'sitemanifest/appHostConfig[@path='Default Web Site/MyWebService']/application[@path='/MyWebService']' because of its scope.
但最后,应用程序池设置为 DefaultAppPool (而不是 FinalAppPool ,如预期的那样)。我首先想到msdeploy采用参数“IIS Web应用程序池名称”的默认应用程序池值。但它始终采用DefaultAppPool。 我只是不明白为什么。
如您所见,我正在使用非管理员帐户进行基本身份验证。我已经在destinationServer上激活了管理委派服务,将contentPath,iisApp和setAcl委托给当前用户,并将createApp和appHostConfig委托给WDeployConfigWriter。
我添加参数“应用程序池”的事实是because I found this here。 但即使我只保留这两个参数中的一个(应用程序池和IIS Web应用程序池名称),第二个也始终在archive.xml中,因为msbuild包参数IncludeIisSettings = true。结果是相同的。
只要应用程序池确实由msdeploy设置,它似乎不是一个正确的问题。只是它没有采用提供的应用程序池。
我们在启用协议方面也存在类似的问题。
对不起,但我想要详尽无遗。
答案 0 :(得分:0)
不知道你是如何部署的,但也许你可以使用那里提到的脚本(带有postSync参数):
.net WebDeploy is there any way to run command/script on the target machine after deploy
在此脚本中,您可以使用appcmd执行所需的一切: