WIX Heat.exe命令参数-var不接受空格吗? [英] WIX Heat.exe command parameter -var does not accept spaces?

查看:181
本文介绍了WIX Heat.exe命令参数-var不接受空格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此WIX命令,该命令使用所有不变路径,并且不需要系统环境(与本示例不同,

I have this WIX command that uses all invariant paths and it doesn't need a system environment (unlike this example http://weblogs.sqlteam.com/mladenp/archive/2010/02/23/WiX-3-Tutorial-Generating-filedirectory-fragments-with-Heat.exe.aspx):

"%wix%bin\heat.exe" dir "$(SolutionDir)Web\obj\$(Configuration)\Package" 
                    -cg PACKAGEFILES -gg -g1 -sreg -srd -dr DEPLOYFOLDER 
                    -var wix.PackageSource="$(SolutionDir)Web\obj\$(Configuration)\Package"
                    -out "$(SolutionDir)WebInstaller\PackageFragment.wxs"

它很好用,除了在我们的构建服务器上,其中解决方案路径中有空格并且会引发此错误:

It works great, except on our build server where the solution path has a space in it and this error is thrown:

heat.exe错误HEAT5057:开关'-var'不允许在值中包含空格.请从值中删除空格:wix.PackageSource = C:\ Build \ Builds 1 \ 26e27895ae75b7cb \ CADPortal \ src \ trunk \ Web \ obj \ Debug \ Package

heat.exe error HEAT5057: The switch '-var' does not allow the spaces from the value. Please remove the spaces in from the value: wix.PackageSource=C:\Build\Builds 1\26e27895ae75b7cb\CADPortal\src\trunk\Web\obj\Debug\Package

我无法更改路径,我认为也没必要.

I can't change the path and it shouldn't be necessary anyway in my opinion.

我的问题是: 我该如何解决? (我什至不知道为什么WIX在带空格的引用路径/字符串var上造成麻烦)

My question is: How do I solve this? (I don't even get why WIX is making trouble over a quoted path/string var with a space)

推荐答案

因此,我最终编写了一些构建事件代码,该代码将必要的定义插入到Heat生成的文件的顶部,但位于开始的WIX标记下.就个人而言,我是否开始质疑WIX的功能,如果您需要进行这种恶作剧/黑客攻击.

So I ended up coding some build event code that inserts the necessary definition into the Heat generated file at the top, but under the starting WIX tag. Personally I'm starting to question the power of WIX if you need to do this kind of shenanigans/hacks.

无论如何,这是我完整的构建事件代码,适合需要它的任何人. (它还会找到MSBuild.exe的不变路径,并创建一个Web程序包.)

Anyway this is my full build event code for anyone that needs it. (It also finds an invariant path for MSBuild.exe and creates a web package.)

echo off

set THEME_REGKEY=HKLM\Software\Microsoft\MSBuild\4.0
set THEME_REGVAL=MSBuildOverrideTasksPath

REM Check for presence of key first.
reg query %THEME_REGKEY% /v %THEME_REGVAL% 2>nul || (echo No theme name present! & exit /b 1)

REM query the value. pipe it through findstr in order to find the matching line that has the value. only grab token 3 and the remainder of the line. %%b is what we are interested in here.
set THEME_NAME=
for /f "tokens=2,*" %%a in ('reg query %THEME_REGKEY% /v %THEME_REGVAL% ^| findstr %THEME_REGVAL%') do (
    set THEME_NAME=%%b
)

REM Possibly no value set
if not defined THEME_NAME (echo No theme name present! & exit /b 1)

REM replace any spaces with +
set THEME_NAME=%THEME_NAME: =+%

if errorlevel 1 goto BuildEventFailed
%THEME_NAME%MSBuild  "$(SolutionDir)Web\Web.csproj" /t:Build;Package /p:Configuration=$(Configuration)
if errorlevel 1 goto BuildEventFailed

"%wix%bin\heat.exe" dir "$(SolutionDir)Web\obj\$(Configuration)\Package" -cg PACKAGEFILES -gg -g1 -sreg -srd -dr DEPLOYFOLDER -var var.PackageSource -out "$(SolutionDir)WebInstaller\PackageFragment.wxs"

REM FUNC "HeatFix" - This inserts the var. definition in top of the heat generated fragment:
 MOVE /Y "$(SolutionDir)WebInstaller\PackageFragment.wxs" temp.txt
(
  FOR /F "tokens=*" %%A IN (temp.txt) DO (
    ECHO %%A
    IF "%%A" EQU "<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">" (
      ECHO ^<^?define PackageSource^=^"$(SolutionDir)Web\obj\$(Configuration)\Package^"^?^>
    )
  )
) > "$(SolutionDir)WebInstaller\temp.txt"
move /Y "$(SolutionDir)WebInstaller\temp.txt" "$(SolutionDir)WebInstaller\PackageFragment.wxs"
REM END FUNC "HeatFix"

goto BuildEventOK
:BuildEventFailed
echo POSTBUILDSTEP for $(ProjectName) FAILED
exit 1
:BuildEventOK
echo POSTBUILDSTEP for $(ProjectName) COMPLETED OK

这篇关于WIX Heat.exe命令参数-var不接受空格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆