问题 WIX 3.6安装程序 - Visual Studio 2010(HeatDirectory)


我正在为Web服务开发WIX 3.6安装程序。但是当我尝试使用HeatDirectory来获取所有必要的输出时,我遇到了一个问题,无论我尝试什么,我都会为每个收获的文件收到以下错误:

系统找不到文件'SourceDir \ Some.dll ...'


7349
2018-05-18 13:52


起源

你可以发布完整的wxs文件吗?可能你没有为Some.dll输入正确的目录... - wimh
@Wimmel,我用完整的wx更新了原帖。谢谢! - alan
@Wimmel,请记住,我说同样的问题出现在我从多个来源下载的示例项目中。 - alan
你指的是 WcfService_Project,应该是另一个文件作为片段。例如,参见 这里。在使用链接的问题 Source="PathToFile"。那 PathToFile 应指向现有文件。 - wimh
@Wimmel,这实际上是对收获的热量目录产生的wxs的引用。请看我上面的更新,我已经为你添加了wxs。旁注:我也看过你在发布之前提供的那个例子。感谢您的帮助,我非常感谢。 - alan


答案:


问题是没有HeatDirectory PreprocessorVariable属性。我通过以下添加到我的wixproj文件修复了这个问题:

<PropertyGroup>
  <DefineConstants>BasePath=%(ProjectReference.RootDir)%(ProjectReference.Directory);</DefineConstants>
</PropertyGroup>
<HeatDirectory OutputFile="%(ProjectReference.Filename).wxs" 
               DirectoryRefId="INSTALLFOLDER" 
               Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)"
               ComponentGroupName="%(ProjectReference.Filename)_Project"
               SuppressCom="true"
               SuppressFragments="true"
               SuppressRegistry="true"
               SuppressRootDirectory="true"
               AutoGenerateGuids="false"
               GenerateGuidsNow="true"
               ToolPath="$(WixToolPath)"
               Condition="'%(ProjectReference.ContentProject)'=='True'" 
               PreprocessorVariable="var.BasePath"/>

如您所见,我需要首先为本地使用定义一个常量变量。我将变量设置为等于我的WCF项目的根路径。其次,我使用该变量作为我的PreprocessorVariable。最后,我能够动态/递归地收集从MsBuild生成的文件。下一步:排除不必要的文件。我会参考这个 链接

请参阅下面的完整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>{4005592f-cc0e-41a3-8e64-33b2824e7fd9}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>MyWCF.WCF.Webservice</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>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="MyWCF.WcfService.wxs" />
    <Compile Include="IISConfig.wxs" />
    <Compile Include="InstallUi.wxs" />
    <Compile Include="Product.wxs" />
    <Compile Include="UIDialogs.wxs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\MyWCF.WcfService\MyWCF.WcfService.csproj">
      <Name>MyWCF.WcfService</Name>
      <Project>{8e528b38-2826-4793-a66d-f6ff181e1139}</Project>
      <Private>True</Private>
      <RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
      <RefTargetDir>INSTALLFOLDER</RefTargetDir>
      <ContentProject>True</ContentProject>
      <DoNotHarvest>True</DoNotHarvest>
      <PackageThisProject>True</PackageThisProject>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup>
    <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>
    <WixExtension Include="WixNetFxExtension">
      <HintPath>$(WixExtDir)\WixNetFxExtension.dll</HintPath>
      <Name>WixNetFxExtension</Name>
    </WixExtension>
  </ItemGroup>
  <ItemGroup>
    <Content Include="ConfigurationInitialize.wxi" />
  </ItemGroup>
  <Import Project="$(WixTargetsPath)" />
  <PropertyGroup>
    <PreBuildEvent />
  </PropertyGroup>
  <Target Name="BeforeBuild">
    <MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=$(Platform)" Condition="'%(ProjectReference.PackageThisProject)'=='True'" />
    <PropertyGroup>
      <DefineConstants>BasePath=%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Platform)\$(Configuration)\Package\PackageTmp\</DefineConstants>
    </PropertyGroup>
    <HeatDirectory OutputFile="%(ProjectReference.Filename).wxs" 
                   Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Platform)\$(Configuration)\Package\PackageTmp"
                   DirectoryRefId="INSTALLFOLDER"
                   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>
</Project>

12
2017-08-02 17:48



我有同样的问题,但到目前为止我还没有看到这是如何解决问题的。 DefineConstants应该替换原始的LinkerBaseInputPaths元素吗? - jpierson
@jpierson我已经更新了答案,如果这不能回答您的问题,请告诉我。 - alan
好的,谢谢你,我相信我现在都在努力。由于格式化,我在HeatDirectory元素上缺少PreprocessorVariable =“var.BasePath”属性。接下来,我必须替换我的其他WIX项目文件中的所有SourceDir引用,并引用var.BasePath,包括在我的XSLT转换中。 - jpierson
我将补充说,我仍然不确定为什么SourceDir不再适用于WIX 3.6,因为它似乎在WIX 3.5中的教程之后工作正常。 - jpierson
非常感谢Alan!我把信息放在我的博客上,我也会很快改变原来的帖子。谢谢您的帮助! - Chris Surfleet


当我从使用Wix建立一个基本网站到我们的一个生产网站时,我遇到了类似的问题。

假设您正在关注示例 保罗雷诺兹的例子 和这个 Paraesthesia的例子

如果您查看以下页面的评论 - http://blogs.planetsoftware.com.au/paul/archive/2011/02/20/creating-a-web-application-installer-with-wix-3.5-and-visual.aspx

第一条评论提到改变Paraesthesia的例子中的beforebuild方法。

        <Target Name="BeforeBuild"> 

    <MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=AnyCPU" Condition="'%(ProjectReference.WebProject)'=='True'" /> 
    <PropertyGroup> <DefineConstants Condition="'%(ProjectReference.WebProject)'=='True'"> %(ProjectReference.Name).PackageDir=%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\ </DefineConstants> </PropertyGroup> <HeatDirectory OutputFile="%(ProjectReference.Filename).wxs" Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\" DirectoryRefId="INSTALLDIR" ComponentGroupName="%(ProjectReference.Filename)_Project" AutogenerateGuids="true" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" ToolPath="$(WixToolPath)" Condition="'%(ProjectReference.WebProject)'=='True'" Transforms="%(ProjectReference.Filename).xsl" PreprocessorVariable="var.%(ProjectReference.Name).PackageDir" /> 
</Target>

我不得不删除transform属性并更改DirectoryRefId,但到目前为止一切都很好。

希望这有助于指明您正确的方向。


2
2018-06-12 12:13



感谢您的建议。当我有机会时,我会尝试这个并更新线程。 - alan
虽然这不是我的问题的解决方案,但它确实让我开始了新的方向。请看明确的答案。 - alan


更新:如果你把

<PropertyGroup>
<DefineConstants Condition="'%(ProjectReference.WebProject)'=='True'">
%(ProjectReference.Name).PackageDir=%(ProjectReference.RootDir)
%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\
</DefineConstants>

并添加:

PreprocessorVariable="var.%(ProjectReference.Name).PackageDir"

查看底部的评论。我不做改造,所以我把它遗弃了。 到HeatDirectory它应该工作,不得不在底部的proj文件。

这可能会降低我的声誉,但我觉得有趣的是 http://www.paraesthesia.com 网站,我是为一个项目工作,但是当尝试另一个项目时,它无法正常工作。
在查看输出后,它似乎采取了适当的项目为热和蜡烛,但光似乎随机取一个。在比较了这两个项目之后,我注意到工作项目将项目收集为最后列出的项目。当我将.wixproj文件中的项目移动到最后一个引用时,它工作正常。
我此时正在使用3.5.2519。我知道它是一个旧的但我们有项目需要Harvest to True并且实际上是Visual Studio中的Harvest。


0
2018-01-21 17:29



不是相关的答案。 - αƞjiβ
WIX很难理解我认为我的答案确实回答了这个问题。 - Pete Hecht


所以你的WcfService.wxs包括:

<File Id="fil0118BBA61671E80581CA9C9AA6DD3E8D" KeyPath="yes" Source="SourceDir\Some.dll" />

这指的是 SourceDir\Some.dll。此文件必须存在于编译项目的PC中。您可能需要更改路径。


-1
2018-05-19 08:48



根据我的理解,SourceDir是源.dll存在的路径的关键字。 WcfService.wxs实际上是收获的热目录的产物(WcfService.wxs是自动创建的)。问题是如何解决它。我已经更新了原来的帖子澄清。 - alan
@alan如果你在构建期间每次都运行热量,我认为你会在更新期间遇到问题,因为每次都会生成一个新的guid。你可以添加一个 参数-var 加热以指定使用什么而不是SourceDir。或者使用 -b选项 用于指定文件存储位置的灯光。 - wimh
如果我通过Visual Studio 2010 WIX安装项目构建此项,我在哪里放置此变量?你知道有什么例子吗? - alan
不,对不起,我没有 - wimh
@Wimmel你可以创建一个config.wxi文件来存储变量,然后在你的安装项目中引用该文件。您可以在此处查看有关使用配置文件的一些示例: stackoverflow.com/questions/471424/wix-tricks-and-tips - BryanJ