我一直致力于PowerShell脚本,以简化我们的开发过程.我打算将它作为一个后期构建活动来运行,但我遇到了一些麻烦.
在PowerShell提示符下,以下内容非常有用:
PS C:\> ./example.ps1
Run Code Online (Sandbox Code Playgroud)
但是,尝试从cmd.exe
以下运行时:
C:\> powershell -command "&\"C:\path to script\example.ps1\""
Run Code Online (Sandbox Code Playgroud)
脚本执行但我从PowerShell返回了一轮错误,主要包括resolve-path
函数的路径解析错误:
Resolve-Path:找不到路径'C:\ Documents and Settings\bdunbar\My Documents\Visual Studio 2008\Projects\CgmFamilyComm\FamilyComm\iirf\cms\isapirewrite4.dl l',因为它不存在.在C:\ Documents and Settings\bdunbar\My Documents\Visual Studio 2008\Projects\C gmFamilyComm\scripts\cms.ps1:4 char:27 + $ iirfpath =(resolve-path <<<< ../iirf/cms /isapirewrite4.dll).path,
Resolve-Path:找不到路径'C:\ Documents and Settings\bdunbar\My Documents\Visual Studio 2008\Projects\CgmFamilyComm\FamilyComm\familycomm',因为它不存在.在C:\ Documents and Settings\bdunbar\My Documents\Visual Studio 2008\Projects\C gmFamilyComm\scripts\cms.ps1:5 char:27 + $ vdirpath =(resolve-path <<<< ../familycomm).路径
有办法解决这个问题吗?这可能是一个运行resolve-path
下的问题cmd.exe
?
我已经能够改变一些事情来解决正在发生的错误,但我仍然收到来自powershell命令提示符的完全正常的错误.我无法弄清楚有什么区别.
Pet*_*ale 26
我过去做过这项工作(如有兴趣,请参阅http://sharepointpdficon.codeplex.com/SourceControl/changeset/view/13092#300544):
C:\ WINDOWS\system32\windowspowershell\v1.0\powershell.exe -NoLogo -NonInteractive -Command.'$(ProjectDir)Deployment\PostBuildScript.ps1'-ProjectDir:'$(ProjectDir)' - ConfigurationName:'$(ConfigurationName )'-TargetDir:'$(TargetDir)'-TargetFileName:'$(TargetFileName)'-TargetName:'$(TargetName)
然后将这些参数放在构建后脚本的第一行(如果您认为可以使用它们):
param($ProjectDir, $ConfigurationName, $TargetDir, $TargetFileName)
另外我应该指出,我目前没有使用它.我确实喜欢使用它作为快速暂存器来重新加载测试数据以运行集成测试.
归档时间: |
|
查看次数: |
12831 次 |
最近记录: |