繁体   English   中英

如何在MSI中包含Web应用程序文件夹

[英]How to include Web Application folder inside MSI

我正在尝试使用VS2010和WIX进行Web应用程序安装,它可以正常工作,但是我要改进的唯一事情是,当您构建安装项目时,它将Web应用程序输出放置在bin文件夹内的单独文件夹中,因此如果要在服务器上安装该Web,则需要复制msi文件+ Web应用程序文件夹。

有什么方法可以建立安装项目以将该文件夹包含在msi包中?

这是我的.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.7</ProductVersion>
      <ProjectGuid>{7bc848bd-4069-429e-847e-4f964a148362}</ProjectGuid>
      <SchemaVersion>2.0</SchemaVersion>
      <OutputName>Tgw.WebClient.Goodyear.Setup</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>
      <SccProjectName>SAK</SccProjectName>
      <SccProvider>SAK</SccProvider>
      <SccAuxPath>SAK</SccAuxPath>
      <SccLocalPath>SAK</SccLocalPath>
    </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="MainConfiguration.wxs" />
      <Compile Include="Tgw.WebClient.Standalone.Web.wxs" />
      <Compile Include="WIXUI_Screens.wxs" />
    </ItemGroup>
    <ItemGroup>
      <EmbeddedResource Include="Resources\Strings.wxl" />
    </ItemGroup>
    <ItemGroup>
      <ProjectReference Include="..\..\Standalone\Source\Tgw.WebClient.Standalone.Web\Tgw.WebClient.Standalone.Web.csproj">
        <Name>Tgw.WebClient.Standalone.Web</Name>
        <Project>{f50a4ff0-6878-4a27-bce7-4956d1ae27db}</Project>
        <Private>True</Private>
        <DoNotHarvest>True</DoNotHarvest>
        <RefProjectOutputGroups>
        </RefProjectOutputGroups>
        <RefTargetDir>TARGETINSTALLDIRECTORY</RefTargetDir>
        <WebProject>True</WebProject>
      </ProjectReference>
    </ItemGroup>
    <ItemGroup>
      <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="WixUtilExtension">
        <HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
        <Name>WixUtilExtension</Name>
      </WixExtension>
      <WixExtension Include="WixUIExtension">
        <HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
        <Name>WixUIExtension</Name>
      </WixExtension>
    </ItemGroup>
    <ItemGroup>
      <Content Include="Configuration\Conditions.wxi" />
      <Content Include="Configuration\Settings.wxi" />
      <Content Include="Resources\CommanderApp_32.ico" />
      <Content Include="Scripts\CreateWebApplicationConfigFiles.ps1" />
    </ItemGroup>
    <ItemGroup>
      <Folder Include="Configuration" />
      <Folder Include="Scripts" />
      <Folder Include="Resources" />
    </ItemGroup>
    <Import Project="$(WixTargetsPath)" />
    <!--
      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.-->
    <Import Project="$(WixTargetsPath)" />
    <Target Name="BeforeBuild">
      <MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=AnyCPU" Condition="'%(ProjectReference.WebProject)'=='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="TARGETINSTALLDIRECTORY" ComponentGroupName="%(ProjectReference.Filename)_Project" AutogenerateGuids="true" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" Condition="'%(ProjectReference.WebProject)'=='True'" PreprocessorVariable="var.BasePath" />
    </Target>
  </Project>

这是我的.wsx自动生成的一部分:

  <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="TARGETINSTALLDIRECTORY">
            <Component Id="cmp975763C4E1B3C939E4CD1957234F6BAC" Guid="*">
                <File Id="filAB034261C737C6286CB0722DB3566B4F" KeyPath="yes" Source="$(var.BasePath)\About.aspx" />
            </Component>
            <Component Id="cmp0ADE3CAB02CA0E4E0C08810D00C09DEB" Guid="*">
                <File Id="fil2CF0D37E848154468D37906E1D0B2FB8" KeyPath="yes" Source="$(var.BasePath)\AspWebStart.aspx" />
            </Component>            
            </Directory>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="Tgw.WebClient.Standalone.Web_Project">
            <ComponentRef Id="cmp975763C4E1B3C939E4CD1957234F6BAC" />
            <ComponentRef Id="cmp0ADE3CAB02CA0E4E0C08810D00C09DEB" />               
        </ComponentGroup>
    </Fragment>
</Wix>

没有看到Tgw.WebClient.Standalone.Web.wxs文件的内容,我不能肯定地说,但这是您问题最有可能的答案! :)

如果您是指Web应用程序的内容文件,例如html,cshtml,aspx,jpg等,则可以选择几种方法。

手动将.wxs文件中的所有文件作为组件包括在内:

<Component>
    <File Id="ContentFile1"
          Name="index.html"
          Source="$(var.Tgw.WebClient.Standalone.Web.ProjectDir)\index.html" />
</Component>

显然,如果您拥有大型网站,这样做将非常耗时。

使用命令行工具Heat来收获所有内容文件并为您创建.wxs,然后可以将其静态包含。 这样的好处是您可以快速但容易地调整上面的组件。

最后,您可以编辑wixproj文件并包含HeatDirectory元素。 然后,这将在每个构建中收获您的内容,因此将自动包含任何新文件。 如果需要,您还可以使用xslt修改此输出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM