我有一个要用MSBuild运行的power外壳脚本。脚本本身可以工作,我可以使用命令行传递path变量;但是,当我尝试通过MSbuild传递变量时,我在path中得到错误。
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="C:\Program Files (x86)\MSBuild\PowershellTask\Powershell.targets"/>
<Target Name="Minify">
<PropertyGroup>
<FilePath>\Scripts</FilePath>
<OutputPath>\MinifiedJS</OutputPath>
</PropertyGroup>
<Exec Command= "powershell.exe -command "&.\MinifyCSS.ps1'$(FilePath)''$(OutputPath)'}"" />如何将路径传递到MSBuild中。/Scripts和/MinifiedJS上的上述代码错误。下面是错误:
powershell.exe -command "&{.\MinifyCSS.ps1'/Scripts''/MinifiedJS'}“术语'.\MinifyCSS.ps1/Scripts'/MinifiedJS‘无法识别为cmdlet、函数、脚本文件或可操作程序的名称。请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。第1行: char:41 +&{.\MinifyCSS.ps1‘/脚本’‘/MinifiedJS’<<<< }+ CategoryInfo : ObjectNotFound:(.\MinifyCSS.ps1/脚本‘/MinifiedJS:String) [],CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
我还尝试将它们放在引号中,并使用.\ prior。
有什么建议吗?
发布于 2013-01-29 02:13:47
尝试:
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="C:\Program Files (x86)\MSBuild\PowershellTask\Powershell.targets"/>
<Target Name="Minify">
<PropertyGroup>
<FilePath>\Scripts</FilePath>
<OutputPath>\MinifiedJS</OutputPath>
</PropertyGroup>
<Exec Command="powershell.exe .\MinifyCSS.ps1 Scripts MinifiedJS" />
</Target>
</Project>https://stackoverflow.com/questions/14565217
复制相似问题