无法将 WiX 属性设置为等于属性文件中的属性

2024-01-05

我可能患有“有时会得病”,但我可以发誓,上次我涉足 WiX 时,建议有一个单独的文件来设置属性,以便以后引用(如果这些属性中的任何一个不是本意的)是静态的。基本上,在构建序列开始之前根据需要更新它们。

所以基本上,我正在尝试:

  1. 将属性文件加载到 WiX 项目中(完成)
  2. 创建一个 WiX 属性,该属性等于该属性文件中的属性之一(已阻止)
  3. 在根据需要安装的过程中引用该值(被阻止程序阻止,但this https://stackoverflow.com/questions/30668723/wix-toolset-how-to-set-a-property如果我被#3 阻止,一旦#2 被解除阻止,也许可以帮助我)

现在,由于尝试错误地引用变量而出现错误,我无法构建,Undefined preprocessor variable '$(var.FOO)'.当不尝试时它构建得很好。我尝试过使用sys and env代替var也。我也尝试使用[FOO]但这似乎是按字面意思处理的,就像在检查构建日志时一样,TESTVAR等于[FOO]代替Bar。我不明白为什么$(var.FOO)没工作。我想我误解了this http://wixtoolset.org/documentation/manual/v3/overview/preprocessor.html文档。

所以我不确定我做错了什么,甚至不知道如何寻找正确的方法来做到这一点。我曾经跑过一些问题 https://stackoverflow.com/questions/12052457/wix-property-from-a-custom-action-into-a-wix-variable这可能会带来有用的答案,但它们与阻碍潜在答案的不可能性有关,例如在安装开始时尝试使用不可变的 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>

新安装测试.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>

除了设置 msbuild 属性(您的 vars.properties)之外,您还必须在 .wixproj 下分配 Candle 预处理器变量<DefineConstants>以便它们可以在您的 wix 项目中使用。 这应该可以解决你的问题Undefined preprocessor variable '$(var.FOO)'

<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法将 WiX 属性设置为等于属性文件中的属性 的相关文章

随机推荐

  • 使用 dplyr 和 lazyeval 进行编程

    我在以保留非标准评估的方式重构 dplyr 时遇到问题 假设我想创建一个始终选择和重命名的函数 library lazyeval library dplyr df lt data frame a c 1 2 3 f c 4 5 6 lm c
  • if 语句过多

    我有一些话题要讨论 我有一段代码 24ifs elifs Operation是我自己的类 代表的功能类似于Enum https docs python org 3 library enum html 这是代码片段 if operation
  • Android:调用 onStop() 时“java.lang.IllegalArgumentException:服务未注册”

    我有一个需要长时间运行的应用程序Service 我需要确保当用户离开时Activity the Service stops 因此我实施了onStop 关闭服务 这是代码 Override protected void onStop supe
  • ButterKnife 中 R2.java 中的最后一个字段

    这是一个扩展Android 为什么我们需要使用 R2 而不是 R 和 butterknife https stackoverflow com questions 42362062 android why do we need to use
  • C++ 二进制转十进制

    所以我知道有一种方法可以使用 bitset 库将 Dec 转换为二进制 但是您可以使用 bitset 库将二进制转换为十进制吗 或者你必须手动完成 bitset lt 8 gt bin x number 可以 但它应该是一个字符串 std
  • 在线程中创建的 DatabaseWrapper 对象只能在同一线程中使用。”当尝试使用 celery 插入数据库时

    我正在使用 celery 从 csv 读取数据并将其上传到 Postgres celery 任务正在工作 我认为 但是 django 抛出错误 我正在获取一个文件 将其转换为 pandas 删除 2 列 然后转换为 numpy 并传递给 c
  • 无法将图像上传到 Django 项目,获取 Form 对象没有属性“保存”

    我正在尝试通过模板输入的文件上传图像文件 我已遵循所有说明 但在附加文件并单击提交时出现此错误 AttributeError PicUpForm object has no attribute save 因此我的图像没有上传到指定的目录 并
  • iPad/iPhone双击问题

    我有一个非常相似的问题iPad iPhone 悬停问题导致用户双击链接 https stackoverflow com questions 3038898 ipad iphone hover problem causes the user
  • solr tomcat UTF-8

    我在 tomcat 中有一个 solr 设置 并且使用 jdbc 从数据库导入数据 但是当我在导入数据后使用非 unicode 字符时 发送查询时它无法识别结果中的查询 对于带有 solr 的 Tomcat 的 UTF 8 支持 您可能需要
  • Spring Web 应用程序中配置文件的处理

    我曾多次遇到同样的问题 我想了解其他人对这个问题的看法 假设我们将 Spring 应用程序打包为 war文件 我们想运行它几种环境 开发 测试 预生产 生产 等 为了访问应用程序所需的基础设施 数据库 网络服务等 我们将访问信息存储在配置文
  • 在 C# 中将 Httpheader 添加到 selenium chrome webdriver

    我的 C 代码看起来像这样 用于创建 chrome Web 驱动程序 我想将自定义 HTTP 标头添加到我的所有 http 请求中 例如 用户代理 Android var service ChromeDriverService Create
  • jQuery 删除所有元素,直到找到 id='whatever'

    需要删除从开始标签到下一个标签的所有代码 我试过这个 page1 remove 但这只会删除标签之间的内容 我不知道 page1 和 page2 标记之间还有什么 因为代码是根据页面上表单元素的类型动态添加的 div div div div
  • nmap 和 print(nm.csv()) 需要帮助打印到 csv.file

    我需要您帮助处理 nmap 脚本并将输出打印到 csv 文件 当我运行脚本并完成它时print nm csv 我得到了以下显示的结果 这是我想要的第一名 host hostname hostname type protocol port n
  • Fat Free Framework (F3):自定义 404 页面(和其他错误)

    如何处理 404 自定义页面 以及可能的其他错误 我只是尝试在路由部分添加 GET codes WebController gt error 我的 Class WebController 处理错误的地方 对于 404 我解决了 部分 实际上
  • 如何从 UIScrollView 窃取触摸?

    今天 在我的创作时间里 我做了一些相当全面的研究 了解如何从 UIScrollView 窃取触摸并将它们立即发送到特定的子视图 同时保持滚动视图其余部分的默认行为 考虑在 UITableView 中包含 UIPickerView 默认行为是
  • 在 ember-cli 中导入自定义库

    I have web app and Ember app在 iframe 中 我想从中导入自定义库web app to ember app就像全局变量一样 库看起来像具有功能的对象 var helpers helper1 function
  • 抓取非 RSS 页面以生成提要

    我想抓取一个定期更新的页面 添加与以前的结构完全相同的新文章 以生成 RSS 提要 我可以编写代码来轻松分析页面 但是如何模拟 ping 即页面更新时我的 php 脚本如何知道 它必须是一个 cron 作业吗 我知道可能是一个重复的问题 但
  • Django:如何使用参数重定向

    提交表单后 我想重定向到传递一个 flag True 的特定视图 以便激活弹出窗口 例如 def view1 request if request method POST form Form request POST if form is
  • Java中通过忽略开始行和结束行的一部分来扫描HBase行

    我的 HBase 行如下 ABC A1 20160101 ABC A2 20160102 ABC A3 20160103 XYZ A9 20160201 从我的Java代码中我知道第一部分ABC和最后一部分20160101 我没办法得到中间
  • 无法将 WiX 属性设置为等于属性文件中的属性

    我可能患有 有时会得病 但我可以发誓 上次我涉足 WiX 时 建议有一个单独的文件来设置属性 以便以后引用 如果这些属性中的任何一个不是本意的 是静态的 基本上 在构建序列开始之前根据需要更新它们 所以基本上 我正在尝试 将属性文件加载到