0
votes

I'm trying to apply a manifest to a WiX generated msi to create an exe that will immediately display a UAC prompt upon running the installer. Unfortunately I'm getting the following error upon building my installer project:

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

I need to elevate the execution to allow custom actions that run during InstallUISequence to have admin privileges (to look up IIS app pools and web apps). I'm using Visual Studio 2012 on Windows 8.

Below is my wixproj file which shows my bootstrapper setup:

<?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>

And here is my manifest file I'm trying to apply:

<?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>
2

2 Answers

0
votes

I found one solution. Download Resource Hacker. Open your resulting executable file and browse it until you find your manifest file. You can edit it diretly in UI or you can script it in command line:

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

*Those NODEs are the path corresponding with resource (manifest) you are trying to update - it is the path in tree in Resource Hacker UI.

-1
votes

Another Hack is to modify the manifest information of the burn.exe of WiX. But this seems to be a very bad solution and I am not sure if there are any side effects. But in my case I could solve it that way because in my build process I use the WiX binaries (not the WiX setup) within my source control version system which then will not affect any other WiX projects on my machine.

I used Visual Studio´s Resource Editor to edit the manifest of burn.exe.