我需要调用exec并构建一个wix安装项目。
目前,我的TFSbuild.proj中有以下内容
<PropertyGroup>
<WebRoot>$(DropLocation)\Latest\x86\Release\_PublishedWebsites\Web</WebRoot>
<DBRoot>$(DropLocation)\Latest\x86\Release\Database</DBRoot>
</PropertyGroup>
<PropertyGroup>
<Msbuildexe>"msbuild"</Msbuildexe>
<Configuration>"/p:Configuration:"Release""</Configuration>
<DefineConstants>" /p:DefineConstants:"WebRoot=$(WebRoot);DBRoot=$(DBRoot)""</DefineConstants>
<WixSolution>"$(MSBuildProjectDirectory)\Setup\Setup.sln"</WixSolution>
</PropertyGroup>
<Message Text="Bulding setup solution" />
<Message Text="$(Msbuildexe) $(Configuration) $(DefineConstants) $(WixSolution)" />
<Exec Command="$(Msbuildexe) $(Configuration) $(DefineConstants) $(WixSolution)" />我尽量简单地尝试,这样我就不会混淆“应该在哪里”。
“/p:DefineConstants:"WebRoot=\server\drops\app\Installer Build\Latest\x86\Release_PublishedWebsites\Web;DBRoot=\server\drops\app\Installer
\x86\Release\数据库”"f:\builds\app\Installer Build\BuildType\Setup\Setup.sln“
我在日志中得到以下错误
‘msbuild’不被识别为内部或外部命令,
可操作的程序或批处理文件。f:\builds\app\Installer Build\BuildType\TFSBuild.proj(538,5):error MSB3073:命令“msbuild”/p:Configuration:“/p:Configuration”“MSB3073\最新\x86\Release\Database”"f:\builds\app\Installer Build\BuildType\Setup\Setup.sln“与代码9009一起退出。
我不确定这是由于不能从命令行调用msbuild命令,还是因为“问题”。如果是因为我不能从命令行调用msbuild,那么如何引用它,是否有指向它的属性?
发布于 2011-06-29 05:20:19
首先,您不需要大多数引号,特别是当您使用的路径不包含空格时,但我会将其简化为这样,允许在路径中为$(WebRoot)、$(DbRoot)和$(MSBuildProjectDirectory)留出空格:
<PropertyGroup>
<WebRoot>$(DropLocation)\Latest\x86\Release\_PublishedWebsites\Web</WebRoot>
<DBRoot>$(DropLocation)\Latest\x86\Release\Database</DBRoot>
</PropertyGroup>
<PropertyGroup>
<MsbuildExe>{still-needs-a-path-to}\msbuild</MsbuildExe>
<Configuration>/p:Configuration:Release</Configuration>
<DefineConstants>/p:DefineConstants:"WebRoot=$(WebRoot);DBRoot=$(DBRoot)"</DefineConstants>
<WixSolution>"$(MSBuildProjectDirectory)\Setup\Setup.sln"</WixSolution>
</PropertyGroup>
<Message
Text="Bulding setup solution"
/>
<Message
Text="$(MsbuildExe) $(Configuration) $(DefineConstants) $(WixSolution)"
/>
<Exec
Command="$(MsbuildExe) $(Configuration) $(DefineConstants) $(WixSolution)"
/>但是,您仍然无法使用此方法执行MSBuild,因为没有指定到MSBuild的路径。它通常在$(WINDIR)\Framework\Microsoft.Net\v4.0.30319文件夹中找到。有几种方法可以直接对其进行编码,依赖于环境变量(必须以某种方式设置),使用预定义的$(MSBuildBinPath),或者使用MSBuild注册表语法从注册表中提取它,如下所示:
$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0\MSBuildToolsPath)但是,还不清楚为什么要使用Exec而不是仅仅使用MSBuild任务来运行MSBuild。将Exec行更改为:
<MSBuild
Project="$(WixSolution)"
Properties="$(DefineConstants)"
/>移除声明并更改为:
<DefineConstants>Configuration=$(Configuration);WebRoot=$(WebRoot);DBRoot=$(DBRoot)</DefineConstants>发布于 2011-06-29 15:26:42
根据我的评论,我建议您尝试使用MSBuild任务而不是Exec
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="BuildWiXSolution">
<!-- Include the custom build targets installed with WiX -->
<Import Project="$(MSBuildExtensionsPath)\Wix\Wix.targets"/>
<PropertyGroup>
<WebRoot>$(DropLocation)\Latest\x86\Release\_PublishedWebsites\Web</WebRoot>
<DBRoot>$(DropLocation)\Latest\x86\Release\Database</DBRoot>
</PropertyGroup>
<ItemGroup>
<WiXSolution Include="$(MSBuildProjectDirectory)\Setup\Setup.sln">
<Properties>Configuration=Release</Properties>
<AdditionalProperties>WebRoot=$(WebRoot);DBRoot=$(DBRoot)</AdditionalProperties>
</WiXSolution>
</ItemGroup>
<Target Name="BuildWiXSolution">
<MSBuild Projects="@(WiXSolution)" />
</Target>
</Project>它允许您将配置属性和附加属性与您的Wix解决方案一起保存。
https://stackoverflow.com/questions/6515859
复制相似问题