PostBuild中的PowerShell脚本 [英] PowerShell Script in PostBuild

查看:117
本文介绍了PostBuild中的PowerShell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用PowerShell脚本来简化开发流程。

I have been working on a PowerShell script to keep our development process streamlined. I was planning on running it as a post-build event, but I'm having some trouble.

在PowerShell提示符下,以下工作非常奇妙:

From the PowerShell prompt, the following works wonderfully:

PS C:\> ./example.ps1

但是,当尝试从 cmd运行时。 exe 如下:

C:\> powershell -command "&\"C:\path to script\example.ps1\""

脚本执行,但我从PowerShell返回一轮错误,主要包括 resolve-path 函数中的路径解析错误:

The script executes but I get a round of errors back from PowerShell, consisting mostly of path resolution errors from the resolve-path function:


Resolve-Path:找不到路径'C:\Documents和Settings\bdunbar\ My Documents
\Visual Studio 2008\Projects \CgmFamilyComm\FamilyComm\iirf\cms\isapirewrite4.dl
l',因为它不存在。
在C:\Documents和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 : Cannot find path 'C:\Documents and Settings\bdunbar\My Documents \Visual Studio 2008\Projects\CgmFamilyComm\FamilyComm\iirf\cms\isapirewrite4.dl l' because it does not exist. At 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,

解析路径:找不到路径'C:\Documents和Settings\bdunbar \ My Documents
\Visual Studio 2008 \Projects\CgmFamilyComm\FamilyComm\familycomm,因为它做了
es不存在。
在C:\Documents和Settings\bdunbar\ My Documents \Visual Studio 2008 \Projects\C
gmFamilyComm\scripts\cms.ps1:5 char:27
+ $ vdirpath =(resolve-path<<<< ... / familycomm).path

Resolve-Path : Cannot find path 'C:\Documents and Settings\bdunbar\My Documents \Visual Studio 2008\Projects\CgmFamilyComm\FamilyComm\familycomm' because it do es not exist. At C:\Documents and Settings\bdunbar\My Documents\Visual Studio 2008\Projects\C gmFamilyComm\scripts\cms.ps1:5 char:27 + $vdirpath = (resolve-path <<<< ../familycomm).path

一种解决这个问题的方法?可能是在 cmd.exe 下运行 resolve-path 的问题?

Is there a way to work around this? Could it be an issue with running resolve-path under cmd.exe?

我已经能够改变事情,以解决发生的错误,但我仍然收到错误,从powershell命令提示符。我不知道有什么区别。

I've been able to change things to get around the errors that are occurring, but I still receive errors that work perfectly fine from the powershell command prompt. I can't figure out what the difference is.

推荐答案

我已经做了这个工作在过去=http://sharepointpdficon.codeplex.com/SourceControl/changeset/view/13092#300544 =nofollow noreferrer> http://sharepointpdficon.codeplex.com/SourceControl/changeset/view/13092#300544 a>如果感兴趣):

I've made this work in the past (see http://sharepointpdficon.codeplex.com/SourceControl/changeset/view/13092#300544 if interested):


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)

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)

您的后构建脚本的行(如果您认为您可以使用它们):

Then throw these parameters in the first line of your post-build script (if you think you may be able to use them):

param($ ProjectDir,$ ConfigurationName,$ TargetDir,$ TargetFileName)

我还要指出,我目前不使用这个。我喜欢使用它作为一个快速暂存器重新加载测试数据运行集成测试。

Also I should point out, I am not using this presently. I did like using it as a quick scratchpad to reload test data for running integration tests.

这篇关于PostBuild中的PowerShell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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