产生问题施加的清单到一个威克斯使用mt.exe MSI(Issue applying a manif

2019-10-17 14:15发布

我想一个维克斯产生的MSI创建一个exe文件,将立即在运行安装程序显示UAC提示申请清单。 不幸的是,我在我的建筑项目安装收到以下错误:

Values of attribute "level" not equal in different manifest snippets. mt.exe

我需要提升的执行,以允许InstallUISequence期间运行具有管理员权限的自定义操作(查找IIS应用程序池和Web应用程序)。 我使用的Windows 8的Visual Studio 2012。

下面是我的wixproj文件,该文件显示了我的引导程序设置:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>3.5</ProductVersion>
    <ProjectGuid>{d51029e8-4a79-4812-96e1-bf6b600d5d34}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>WixInstallerExampleWebInstaller</OutputName>
    <OutputType>Package</OutputType>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
    <DefineConstants>Debug</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="IisSettingsDlg.wxs" />
    <Compile Include="Product.wxs" />
    <Compile Include="UserInterface.wxs" />
    <Compile Include="WixInstallerExampleWeb.wxs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\WixInstallerExampleWeb\WixInstallerExampleWeb.csproj">
      <Name>WixInstallerExampleWeb</Name>
      <Project>{d23a374d-764c-40ba-b566-4d7c55319236}</Project>
      <Private>True</Private>
      <DoNotHarvest>True</DoNotHarvest>
      <RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
      <RefTargetDir>INSTALLLOCATION</RefTargetDir>
      <PackageThisProject>True</PackageThisProject>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup>
    <WixExtension Include="WixUtilExtension">
      <HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
      <Name>WixUtilExtension</Name>
    </WixExtension>
    <WixExtension Include="WixNetFxExtension">
      <HintPath>$(WixExtDir)\WixNetFxExtension.dll</HintPath>
      <Name>WixNetFxExtension</Name>
    </WixExtension>
    <WixExtension Include="WixIIsExtension">
      <HintPath>$(WixExtDir)\WixIIsExtension.dll</HintPath>
      <Name>WixIIsExtension</Name>
    </WixExtension>
    <WixExtension Include="WixUIExtension">
      <HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
      <Name>WixUIExtension</Name>
    </WixExtension>
  </ItemGroup>
  <ItemGroup>
    <Content Include="EULA.rtf" />
    <Content Include="IisManager.CA.dll" />
    <Content Include="uac.manifest" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperFile Include="Microsoft.Windows.Installer.3.1" >
      <ProductName>Windows Installer 3.1</ProductName>
    </BootstrapperFile>
  </ItemGroup>

  <Import Project="$(WixTargetsPath)" />
  <Target Name="Bootstrapper"
        Inputs="$(OutDir)$(TargetFileName)"
        Outputs="$(OutDir)\Setup.exe"
        Condition=" '$(OutputType)'=='package' " >
    <GenerateBootstrapper ApplicationName="application name"
                          ApplicationFile="$(TargetFileName)"
                          BootstrapperItems="@(BootstrapperFile)"
                          ComponentsLocation="Relative"
                          OutputPath="$(OutputPath)"
                          Culture="en-US"
                          Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper" />
  </Target>
  <Target Name="PatchSetupExe" DependsOnTargets="Bootstrapper">
    <Exec Command='"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin\mt.exe" -manifest "$(ProjectDir)uac.manifest" -updateresource:"$(ProjectDir)$(OutputPath)Setup.exe;#1"' IgnoreExitCode='false' />    
  </Target>
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets" />

  <PropertyGroup>
    <BuildDependsOn>$(BuildDependsOn);Bootstrapper;PatchSetupExe</BuildDependsOn>
  </PropertyGroup>
  <Target Name="BeforeBuild">
    <MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=AnyCPU" Condition="'%(ProjectReference.PackageThisProject)'=='True'" />
    <Copy SourceFiles="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\TransformWebConfig\transformed\web.config" OverwriteReadOnlyFiles="true" DestinationFolder="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\" Condition="'%(ProjectReference.PackageThisProject)'=='True'" />
    <PropertyGroup>
      <LinkerBaseInputPaths>%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\</LinkerBaseInputPaths>
      <DefineConstants>BasePath=%(ProjectReference.RootDir)%(ProjectReference.Directory);</DefineConstants>
    </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'" PreprocessorVariable="var.BasePath" />
  </Target>
  <PropertyGroup>
    <PreBuildEvent />
  </PropertyGroup>
  <PropertyGroup>
    <PostBuildEvent />
  </PropertyGroup>
  <!--
    To modify your build process, add your task inside one of the targets below and uncomment it.
    Other similar extension points exist, see Wix.targets.

    <Target Name="AfterBuild">
    </Target>
    -->
</Project>

这里是我想申请我的清单文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="Setup" type="win32" />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

Answer 1:

我找到了一个解决方案。 下载资源黑客 。 打开生成的可执行文件和浏览它,直到你找到你的清单文件。 您可以在UI直接写给编辑它,或者你可以编写脚本它的命令行:

ResHacker.exe -modify old.exe,new.exe,manifestToUse.manifest,ROOTNODE,SUBNODE*

*这些节点与资源(舱单)你要更新相应的路径 - 这是资源黑客UI在树中的路径。



Answer 2:

另一个哈克是修改维克斯的burn.exe的清单信息。 但是,这似乎是一个非常糟糕的解决方案,我不知道是否有任何副作用。 但在我的情况下,我可以解决这个问题,那是因为在我的构建过程中使用我的源代码控制版本系统内的WiX的二进制文件(不是WiX的设置),然后将不会影响我的机器上的任何其他WiX的项目。

我用视觉Studio's资源编辑器编辑burn.exe的清单。



文章来源: Issue applying a manifest to a wix generated msi using mt.exe