【问题标题】:Impersonating different users during install in WiX setup在 WiX 设置中安装期间模拟不同的用户
【发布时间】:2013-04-15 03:52:26
【问题描述】:
我刚刚创建了一个 WiX v3.5 安装程序来将我的 Web 应用程序安装到 IIS7。我有自定义操作,允许用户选择他们想要的网站和应用程序池,并通过对话框命名虚拟目录。
但现在我已经进行了身份验证,但我很困惑。我正在尝试启用模拟并允许用户输入他们的模拟登录名和密码。我在我的 Visual Studion 2010 设置项目中运行良好,所以现在我需要在 WiX 中复制它。
显然,这可以根据以下问题通过 appcmd 完成:Is setting "ASP.NET Impersonation" possible using WiX 3.x with IISExtension? 但我似乎无法使其正常工作。我可以在我的 product.wxs 中添加它并将其包装在自定义操作中吗?有什么想法吗?任何帮助将不胜感激?
appcmd set config /commit:WEBROOT/section:identity /impersonate:true
【问题讨论】:
标签:
asp.net
authentication
iis-7
wix
impersonation
【解决方案1】:
您好,我自己解决了这个问题,所以如果其他人遇到同样的问题,我会在安装过程中修改我的 web.config 来解决这个问题:
为此,我将以下代码添加到我的 product.wsx 以编辑我的 web.config ,使用我分配给新对话框中文本框的属性以允许用户在安装时输入模拟用户名和密码:
<Component Id="Web.config" Guid="2ED81B77-F153-4003-9006-4770D789D4B6">
<File Id="Web.config" Name="Web.config" Source="$(var.SolutionDir)MyWebApp\Web.config" DiskId="1" KeyPath="yes" />
<util:XmlFile Id="system.webidentity" File="[INSTALLLOCATION]Web.config" Action="createElement" ElementPath="/configuration/system.web" Name="identity" Sequence="1" />
<util:XmlFile Id="system.webIdentityAttribute" Action="setValue" File="[INSTALLLOCATION]Web.config" ElementPath="/configuration/system.web/identity" Name="impersonate" Value="true" Sequence="2" />
<util:XmlFile Id="system.webIdentityAttribute2" Action="setValue" File="[INSTALLLOCATION]Web.config" ElementPath="/configuration/system.web/identity" Name="password" Value="[IMPERSONATIONUSERPASSWORD]" Sequence="3" />
<util:XmlFile Id="system.webIdentityAttribute3" Action="setValue" File="[INSTALLLOCATION]Web.config" ElementPath="/configuration/system.web/identity" Name="userName" Value="[IMPERSONATIONUSER]" Sequence="4" />
请注意,如果您使用 msbuild 和 heat 自动将文件添加到您的 Wix 项目,您必须确保您没有在此处复制您的 web.config,或者如果您是,请删除我的 web.config 您的 Target 设置。否则会出现重复错误。
<Target Name="BeforeBuild">
<MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=AnyCPU" Condition="'%(ProjectReference.PackageThisProject)'=='True'" />
<Delete Files="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\web.config">
</Delete>
<PropertyGroup>
<LinkerBaseInputPaths>%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\</LinkerBaseInputPaths>
</PropertyGroup>
<HeatDirectory OutputFile="%(ProjectReference.Filename).wxs" Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\" DirectoryRefId="INSTALLLOCATION" ComponentGroupName="%(ProjectReference.Filename)_Project" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" Condition="'%(ProjectReference.PackageThisProject)'=='True'" /> </Target>