我有MSBuild和Powershell的问题。有一个PS脚本,我想要在MSBuild exec-Task中执行。从MSBuild Exec运行powershell脚本的异常任务
问题:直接从CMD运行脚本,但在MSBuild内运行脚本时出现错误。
这里的MSBuild脚本:
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup>
<PathToSvnClient>C:\Program Files (x86)\CollabNet\Subversion Client</PathToSvnClient>
</PropertyGroup>
<ItemGroup>
<!-- set Folder to Svn Repository for svn info command-->
<SvnFolder Include="$(MSBuildProjectDirectory)\.."/>
</ItemGroup>
<Target Name="SvnInfo">
<!-- get SVN Revision and Repository Path -->
<SvnInfo LocalPath="%(SvnFolder.FullPath)" ToolPath="$(PathToSvnClient)">
<Output TaskParameter="Revision" PropertyName="Revision" />
<Output TaskParameter="RepositoryPath" PropertyName="RepositoryPath" />
</SvnInfo>
</Target>
<Target Name="SetProductVersion" DependsOnTargets="SvnInfo">
<Exec Command="powershell -file "Scripts\SetSth.ps1" -PARAM "$(PathToSth)" -SVNID $(Revision) -SVNFOLDER "$(RepositoryPath)"" LogStandardErrorAsError="true" ContinueOnError="false"/>
</Target>
命令正好执行相同的方式,在CMD,但我从PowerShell脚本异常的SVNFOLDER PARAM 。
所执行的命令如下:
powershell -file "Scripts\SetSth.ps1" -PARAM "C:\abc\cde" -SVNID 1234
-SVNFOLDER "https://domain/svn/rep/branches/xy%20(Build%2012)"
因此,从CMD它的工作原理,从内部的MSBuild没有。我不知道为什么。我希望你有个想法。
谢谢您的回答。但脚本开始,然后引发异常。所以它是。其他。目前我正在查看SVNFOLDER路径的“%20”。我假设MSBuild将其替换为一个项目?! – BoBBuilder 2011-02-06 13:51:42