Properties 无法将WiX属性设置为等于属性文件中的属性
我可能患有Sometimers病,但我可以发誓,上次我在WiX中浸泡脚趾时,建议有一个单独的文件来设置属性,以便在以后如果这些属性中的任何属性不是静态的,可以引用。基本上,在构建序列开始之前根据需要更新它们 所以基本上,我想:Properties 无法将WiX属性设置为等于属性文件中的属性,properties,wix,properties-file,wix4,Properties,Wix,Properties File,Wix4,我可能患有Sometimers病,但我可以发誓,上次我在WiX中浸泡脚趾时,建议有一个单独的文件来设置属性,以便在以后如果这些属性中的任何属性不是静态的,可以引用。基本上,在构建序列开始之前根据需要更新它们 所以基本上,我想: 将属性文件加载到WiX项目中(完成) 创建一个WiX属性,该属性等于该属性文件中的一个属性(已阻止) 根据需要在安装过程中引用该值(被阻止程序阻止,但如果我被#3阻止,则一旦#2被阻止,可能会帮助我) 现在,我无法生成,因为尝试错误地引用变量,出现错误,未定义的预处理器变
未定义的预处理器变量“$(var.FOO)”。
如果不尝试,它可以正常生成。我也尝试过使用sys
和env
而不是var
。我还尝试使用[FOO]
,但这似乎是字面意义上的,就像在检查构建日志时一样,TESTVAR
等于[FOO]
而不是条。我不明白为什么$(var.FOO)
不起作用。我想我误解了文件
所以我不知道我做错了什么,甚至不知道如何寻找正确的方法。我曾经遇到过这样的问题,可能会得到一些有用的答案,但它们与阻碍潜在答案的不可能性有关,比如在安装开始时尝试使用不可变的WiX属性
它只不过是一个默认的模板WiX 4项目,但我已将所有源文件包括在下面:
可变属性
酒吧
NewSetupTest.wixproj
调试
x86
3.9
75FA9A4-ddfe-44a6-8b03-2f26612b3339
2
新闻测试
包裹
$(MSBuildExtensionsPath)\WiX工具集\v4\WiX.targets
bin\$(配置)\
obj\$(配置)\
调试
假的
bin\$(配置)\
obj\$(配置)\
Product.wxs
不是(TESTVAR=“Bar”)
除了设置msbuild属性(您可以使用vars.properties),还必须在.wixproj中的
下分配Candle预处理器变量,以便在wix项目中使用它们。
这将修复未定义的预处理器变量“$(var.FOO)”
bin\$(配置)\
obj\$(配置)\
调试;FOO=$(FOO)
假的
bin\$(配置)\
obj\$(配置)\
FOO=$(FOO)
您可能希望使用FOO=$(FOO)$(DefineConstants)
如果要在其他任何位置修改该值,以避免丢失以前的值。
<?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>
<?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>
<?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>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;FOO=$(FOO)</DefineConstants>
<VerboseOutput>False</VerboseOutput>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>FOO=$(FOO)</DefineConstants>
</PropertyGroup>