19

私は現在、ハッキングされたデプロイメントシステムをもう少しエレガントなもの(Octopus)で再調整することを検討しています。そうすることで、リリースビルドの実行時にVSにプロジェクトをパッケージ化させようとしています。この素晴らしいPowerShellスクリプトを作成して機能させていますが、msbuildスクリプトからEXECを実行しようとすると、VisualStudioがハングします。

最初は、シェルに物が逃げているのではないかと思ったのですが、ばかばかしく単純化したのですが、それでもフリーズします。

関連するMsBuildコードは次のとおりです。

    <PropertyGroup>
      <PowerShellExe Condition=" '$(PowerShellExe)'=='' ">
        %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
      </PowerShellExe>
    </PropertyGroup>

    <Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
      <Exec Command="$(PowerShellExe) -NonInteractive -executionpolicy Unrestricted -command get-childitem" />
    </Target>

それがすべきことは、ディレクトリリストを提供することだけです。cmd.exeからこれを呼び出すと正常に機能します。

C:\Users\smithj>%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -executionpolicy unrestricted -command dir

これを試してみてください:

msbuild Solution.sln /p:Configuration=Release

私にこれを取得します:

AfterBuild:
  "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\\tf.exe" che
  ckout Package.nuspec
  Package.nuspec

        %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
       -NonInteractive -executionpolicy Unrestricted -command dir

  Windows PowerShell
  Copyright (C) 2009 Microsoft Corporation. All rights reserved.

その後、それは永遠にハングします。どんな提案でも大歓迎です。

4

2 に答える 2

28

あなたが答えを好きになるかどうかわからない。少し遊んだ後、それはプロパティグループの拡大についてのようです。PowerShellExeの値に改行を入れます。これは正常に機能します。

<PropertyGroup>
    <PowerShellExe Condition=" '$(PowerShellExe)'=='' ">$(WINDIR)\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellExe>
  </PropertyGroup>

  <Target Name="AfterBuild">
    <Exec Command="$(PowerShellExe) -NonInteractive -executionpolicy bypass -command &quot;&amp;{get-childitem}&quot;" />
  </Target>
于 2013-01-11T11:58:30.303 に答える
0

試す:

<Exec Command='$(PowerShellExe) -NonInteractive -executionpolicy Unrestricted -command "& {Get-ChildItem}"' />
于 2013-01-11T00:01:37.287 に答える