Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

visual studio - Issue applying a manifest to a wix generated msi using mt.exe

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)MicrosoftWiXv3.xWix.targets</WixTargetsPath>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)MicrosoftWiXv3.xWix.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="..WixInstallerExampleWebWixInstallerExampleWeb.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 SDKsWindowsv8.0ABootstrapper" />
  </Target>
  <Target Name="PatchSetupExe" DependsOnTargets="Bootstrapper">
    <Exec Command='"C:Program Files (x86)Microsoft SDKsWindowsv7.1Ainmt.exe" -manifest "$(ProjectDir)uac.manifest" -updateresource:"$(ProjectDir)$(OutputPath)Setup.exe;#1"' IgnoreExitCode='false' />    
  </Target>
  <Import Project="$(MSBuildExtensionsPath)MicrosoftWiXv3.xWix.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	ransformedweb.config" OverwriteReadOnlyFiles="true" DestinationFolder="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj$(Configuration)PackagePackageTmp" Condition="'%(ProjectReference.PackageThisProject)'=='True'" />
    <PropertyGroup>
      <LinkerBaseInputPaths>%(ProjectReference.RootDir)%(ProjectReference.Directory)obj$(Configuration)PackagePackageTmp</LinkerBaseInputPaths>
      <DefineConstants>BasePath=%(ProjectReference.RootDir)%(ProjectReference.Directory);</DefineConstants>
    </PropertyGroup>
    <HeatDirectory OutputFile="%(ProjectReference.Filename).wxs" Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj$(Configuration)PackagePackageTmp" 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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...