WiX未定义的预处理器变量

编程入门 行业动态 更新时间:2024-10-24 16:27:50
本文介绍了WiX未定义的预处理器变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我开始使用WiX进行自动化构建以创建我的C#项目的MSI,并且遇到错误未定义的预处理变量'$(var.MyProject.TargetDir)'

I'm starting to use WiX in order to do automated builds to create msi's of my c# projects and am experiencing the error "Undefined preprocessor variable '$(var.MyProject.TargetDir)'"

我正在使用最新的WiX v3.0.5419。在我的wxs文件中,我尝试使用此网页上列出的预处理程序变量( blogs.msdn/jrock/archive/2008/01/29/complete-list-of-candle-preprocessor-variables。 aspx )

I am using the latest WiX v3.0.5419. Inside my wxs file I am trying to use pre-processor variables that are listed on this webpage (blogs.msdn/jrock/archive/2008/01/29/complete-list-of-candle-preprocessor-variables.aspx)

<Component Id="MyId" Guid="MyGuid"> <File Id="MyId" Name="MyName" KeyPath="yes" Source="$(var.MyProject.TargetDir)\MyName.dll" /> </Component>

我已将MyProject的引用添加到.wixproj中,如果我在记事本中打开它,则可以

I have added the reference for MyProject to the .wixproj and if I open it up in Notepad I can see the reference.

<ItemGroup> <ProjectReference Include="..\MyProject.csproj"> <Name>MyProject</Name> <Project>{guid}</Project> <Private>True</Private> </ProjectReference> </ItemGroup>

这是我用来创建msi的nant构建脚本。也许是因为.wixproj知道未在构建中使用的项目引用?

This is my nant build script that I use to create the msi. Maybe it's because the .wixproj knows about the project reference which isn't used in the build?

<exec basedir="${tools.wix}" managed="true" program="candle.exe"> <arg line='-out "${tools.wix.objfile}"' /> <arg value="../MySetup.wxs" /> </exec>

有人可以启发我吗?

推荐答案

您已经说过,您的nant构建脚本根本没有使用 wixproj 文件。

As you already remarked, your nant build script is not using the wixproj file at all.

您正在混合使用两种不同的方法来构建wix设置:

You are mixing two different ways to build a wix setup here:

  • 您可以使用 candle.exe 和 light.exe 命令行工具直接。这将忽略 .wixproj 文件。这就是您在nant构建脚本中所做的事情。要传递诸如 $(var.MyProject.TargetDir)之类的预处理器变量的值,请使用诸如 -dMyProject.TargetDir = c:\foo 。

  • You can use the candle.exe and light.exe command line tools directly. This ignores the .wixproj file. This is what you are doing in your nant build script. To pass values for preprocessor variables like $(var.MyProject.TargetDir), use options like -dMyProject.TargetDir=c:\foo.

    您可以编写带有votive的.wixproj文件(wix的Visual Studio附加组件)。像所有Visual Studio项目文件一样,wixproj文件实际上是一个msbuild文件,可以使用 msbuild.exe 进行构建。如果存在正确的项目引用,则msbuild任务会自动设置变量 $(var.MyProject.TargetDir)来构建wix设置。

    You can author a .wixproj file with votive (the visual studio add-on for wix). Like all visual studio project files, a wixproj file is actually a msbuild file which can be build with msbuild.exe. Variables like $(var.MyProject.TargetDir) are automatically set by the msbuild tasks for building wix setups if the correct project reference exists.

    我建议您使用< msbuild> nant任务。这样可以确保您的nant构建与通过Visual Studio手动构建设置时的效果相同。

    I recommend you build the wixproj file with the <msbuild> nant task. This ensures that your nant build does the same as when you build the setup manually from visual studio.

  • 更多推荐

    WiX未定义的预处理器变量

    本文发布于:2023-11-11 10:45:34,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1578201.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:变量   未定义   WiX

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!