我正在为Web服务开发WIX 3.6安装程序。但是当我尝试使用HeatDirectory来获取所有必要的输出时,我遇到了一个问题,无论我尝试什么,我都会收到每个收获文件的以下错误:
系统找不到文件'SourceDir \ Some.dll ...'
错误发生在WcfService.wxs中;奇怪的是,WcfService.wxs是由我的项目文件(下面)中的heatdirectory部分自动创建的。 如果它必须知道它们首先要创建WcfService.wxs,它怎么能说它找不到这些.dll?这些错误甚至在我下载和构建时出现WIX示例项目(原样)来自我读过的任何一个教程。
目标:尽可能多地自动化.dll包含(即利用收获来处理依赖项目等)
我正在运行Win 7 64位,项目是.NET 4.
Product.wxs:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="CompleteInstall" Language="1033" Version="1.0.0.0" Manufacturer="Technologies" UpgradeCode="b2ae6aa5-263f-4f9a-a250-8599a7f2cb03">
<Package InstallerVersion="200" Compressed="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="CommonDir1" Name="Common Directory 1">
<Directory Id="CommonDir2" Name="Common Directory 2">
<Directory Id="INSTALLFOLDER" Name="Install Directory"/>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="CompleteInstall" Level="1">
<ComponentGroupRef Id="WcfService_Project" />
</Feature>
<Property Id="WIXUI_INSTALLDIR">INSTALLFOLDER</Property>
<UIRef Id="WixUI_InstallDir" />
</Product>
</Wix>
项目文件:
<Target Name="BeforeBuild">
<MSBuild Projects="%(ProjectReference.FullPath)" Targets="Build" Properties="Configuration=$(Configuration);Platform=x86" Condition="'%(ProjectReference.ContentProject)'=='True'" />
<PropertyGroup>
<LinkerBaseInputPaths>%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Platform)\$(Configuration)\</LinkerBaseInputPaths>
</PropertyGroup>
<HeatDirectory OutputFile="%(ProjectReference.Filename)-temp.xml"
Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)bin\$(Platform)\$(Configuration)\"
DirectoryRefId="INSTALLFOLDER"
ComponentGroupName="%(ProjectReference.Filename)_Project"
SuppressCom="true"
SuppressFragments="true"
SuppressRegistry="true"
SuppressRootDirectory="true"
AutoGenerateGuids="false"
GenerateGuidsNow="true"
ToolPath="$(WixToolPath)"
Condition="'%(ProjectReference.ContentProject)'=='True'" />
<XslTransformation XmlInputPaths="%(ProjectReference.Filename)-temp.xml"
XslInputPath="XslTransform.xslt"
OutputPaths="%(ProjectReference.Filename).wxs"
Condition="'%(ProjectReference.ContentProject)'=='True'" />
</Target>
WcfService.wxs:
<?xml version="1.0" encoding="utf-8"?><Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmpE6EBA3D8D6D4DB0C93E73200C78DCC51" Guid="{C88B5CF9-8807-45DF-AA6F-732437B74BB6}">
<File Id="fil0118BBA61671E80581CA9C9AA6DD3E8D" KeyPath="yes" Source="SourceDir\Some.dll" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="WcfService_Project">
<ComponentRef Id="cmpE6EBA3D8D6D4DB0C93E73200C78DCC51" />
</ComponentGroup>
</Fragment>
</Wix>
答案 0 :(得分:12)
问题是没有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生成的文件。下一步:排除不必要的文件。我将参考此link。
见下面我完整的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>
答案 1 :(得分:2)
当我从使用Wix建立一个基本网站到我们的一个生产网站时,我遇到了类似的问题。
假设您正在关注示例Paul Reynolds' example和此Paraesthesia's example
如果您查看以下页面的评论 - 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 :(得分:0)
更新:如果你把
<PropertyGroup>
<DefineConstants Condition="'%(ProjectReference.WebProject)'=='True'">
%(ProjectReference.Name).PackageDir=%(ProjectReference.RootDir)
%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\
</DefineConstants>
并添加:
PreprocessorVariable="var.%(ProjectReference.Name).PackageDir"
See the comment towards the bottom。我不做改造,所以我把它遗弃了。 对于HeatDirectory它应该工作,必须在底部有proj文件。
这可能会降低我的声誉,但我觉得有趣的是http://www.paraesthesia.com网站,我是在为一个项目工作,但在尝试另一个项目时,它不起作用。
在查看输出后,它似乎采取了适当的项目为热和蜡烛,但光似乎随机取一个。在比较了这两个项目之后,我注意到工作项目将项目收集为最后列出的项目。当我将.wixproj文件中的项目移动到最后一个引用时,它起作用了。
我此时正在使用3.5.2519。我知道它是一个旧的但我们有项目需要Harvest to True并且实际上是Visual Studio中的Harvest。
答案 3 :(得分:-1)
所以你的WcfService.wxs包括:
<File Id="fil0118BBA61671E80581CA9C9AA6DD3E8D" KeyPath="yes" Source="SourceDir\Some.dll" />
这是指SourceDir\Some.dll
。此文件必须存在于编译项目的PC中。您可能需要更改路径。