1

我刚刚创建了一个 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
4

1 回答 1

2

嗨,我自己设法让这个工作,所以如果其他人有同样的问题,我通过在安装过程中修改我的 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>
于 2013-04-23T13:41:36.423 回答