PowerShell Script in PostBuild

前端 未结 2 919
小蘑菇
小蘑菇 2020-12-30 03:17

Continuous Integration

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,

相关标签:
2条回答
  • 2020-12-30 03:38

    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)

    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.

    0 讨论(0)
  • 2020-12-30 03:39

    Looks like your problem is how relative paths are resolved. Relative paths are resolved based on the current location (stored in $pwd) and not based on the location of the script. So if you launched the script from C:\, it definitely would not work.

    I would suggest you calculate the paths based on an argument (like Peter Seale shows), or grab the actual location of the script from:

    $MyInvocation.MyCommand.Path
    
    0 讨论(0)
提交回复
热议问题