我可能患有 Sometimers 病,但我可以发誓上次在 WiX 中使用脚趾时,建议有一个单独的文件用于设置稍后引用的属性,如果这些属性中的任何一个不意味着是静态的。基本上,在构建序列开始之前根据需要更新它们。
所以基本上,我正在尝试:
- 将属性文件加载到 WiX 项目中(完成)
- 创建一个与该属性文件中的一个属性相等的 WiX 属性(已阻止)
- 根据需要在安装序列期间引用该值(被阻止程序阻止,但是如果我被#3阻止,一旦#2被解除阻止,这可能会对我有所帮助)
现在,由于尝试使用错误错误地引用变量,我无法构建,Undefined preprocessor variable '$(var.FOO)'.
它在不尝试时构建得很好。我试过用sys
andenv
而不是var
too。我也尝试过使用[FOO]
,但这似乎是按字面意思处理的,就像在检查构建日志时一样,TESTVAR
等于[FOO]
而不是Bar
. 我不明白为什么$(var.FOO)
没有工作。我想我误解了这份文件。
所以我不确定我做错了什么,甚至不确定如何寻找正确的方法来做这件事。我遇到了一些可能会导致有用答案的问题,但它们与阻碍潜在答案的可能性有关,例如在安装开始时尝试使用不可变的 WiX 属性作为可变的。
它只不过是一个默认模板 WiX 4 项目,但我在下面包含了我的所有源文件:
变量属性
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<FOO>Bar</FOO>
</PropertyGroup>
</Project>
NewSetupTest.wixproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="vars.properties" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.9</ProductVersion>
<ProjectGuid>75fa9a4b-ddfe-44a6-8b03-2f26612b3339</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>NewSetupTest</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\WiX Toolset\v4\wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
<VerboseOutput>False</VerboseOutput>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<Content Include="vars.properties" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" Exists('$(WixTargetsPath)') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" !Exists('$(WixTargetsPath)') ">
<Error Text="The WiX Toolset v4 build tools must be installed to build this project. To download the WiX Toolset v4, see http://wixtoolset.org/releases/" />
</Target>
<!--
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="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
产品.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Product Id="7E5959E4-664D-4D24-9B45-BA2697CA303B"
Name="NewSetupTest"
Language="1033"
Version="1.0.0.3"
Manufacturer="ACME"
UpgradeCode="A38ABDBE-2D5F-450D-97EE-19C5A018101B">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" Platform="x64" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes"/>
<MediaTemplate />
<Feature Id="ProductFeature"
Title="NewSetupTest"
Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR"
Name="SourceDir">
<Directory Id="ProgramFilesFolder64">
<Directory Id="INSTALLFOLDER"
Name="NewSetupTest" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Property Id="TESTVAR" Secure="yes" Value="$(var.FOO)" />
<ComponentGroup Id="ProductComponents"
Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
<InstallExecuteSequence>
<ScheduleReboot After="InstallFinalize">NOT (TESTVAR = "Bar")</ScheduleReboot>
</InstallExecuteSequence>
</Fragment>
</Wix>