2016-03-31 6 views
0

私は、コンテナをドッキングウィンドウするasp.netのWebアプリケーションを公開するscott hanselman's exampleを使用しています。公開ボタンをクリックした後にVisual Studioでスクリプトをデバッグする方法はありますか?

ありPowerShellスクリプトは自動的に拡張子によって生成されたプロジェクト内にあるが、私はそれをよく理解していません。だから私はそれをデバッグするためにブレークポイントを設定したい。公開ボタンを右クリックしてスクリプトが実行されていると思います。スクリプトには350行しかないので、ここに関数をすべてポストする必要はありません。

  #Requires –Version 3.0 

     <# 
     .DESCRIPTION 
      Publish an application to Docker container 
      Please visit http://go.microsoft.com/fwlink/?LinkID=529706 to learn more about the scirpt 

     .EXAMPLE 
      & '.\contoso-Docker-publish.ps1' -packOutput $env:USERPROFILE\AppData\Local\Temp\PublishTemp -pubxmlFile '.\contoso-Docker.pubxml' 

     .EXAMPLE 
      $publishProperties = @{ "SiteUrlToLaunchAfterPublish"="http://contoso.cloudapp.net/Home"; } 
      & '.\contoso-Docker-publish.ps1' $publishProperties $env:USERPROFILE\AppData\Local\Temp\PublishTemp '.\contoso-Docker.pubxml' 
     #> 

     [cmdletbinding(SupportsShouldProcess = $true)] 
     param($publishProperties, $packOutput, $pubxmlFile) 

     <# 
      Core publish functions 
     #> 

     function Publish-AspNetDocker { 
      [cmdletbinding(SupportsShouldProcess = $true)] 
      param(
       [Parameter(Mandatory = $true, Position = 0)] 
       [AllowNull()] 
       $publishProperties, 
       [Parameter(Mandatory = $true, Position = 1)] 
       $packOutput, 
       [Parameter(Mandatory = $false, Position = 2)] 
       $pubxmlFile 
      ) 
      process { 

       # Merge publish properties from $publishProperties and $pubxmlFile. The value from $publishProperties will be taken if conflict. 
       if ($pubxmlFile -and (Test-Path $pubxmlFile)) { 
        if(!$publishProperties) { 
         $publishProperties = @{} 
        } 
        ([xml](Get-Content $pubxmlFile)).SelectNodes(("/*/*/*")) | % { 
         if (!$publishProperties.ContainsKey($_.Name)) { $publishProperties.Add($_.Name, $_.InnerText) } 
        } 
       } 

       if (!$publishProperties) { 
        throw 'publishProperties is empty and pubxmlFile is not valid, cannot publish' 
       } 

       # Trim the trailing '\' to avoid quoting issue 
       $packOutput = $packOutput.TrimEnd('\') 
       $profileName = (Split-Path $PSCommandPath -Leaf).Replace('-publish.ps1', '') 

       # Search for current publish profile and publish script in the package output directory 
       $profile = Get-ChildItem -Path $packOutput -Filter "$profileName.pubxml" -Recurse | Where { Test-Path (Join-Path $_.Directory.FullName "$profileName-publish.ps1") } | Select -First 1 
       if (!$profile) { 
        throw 'cannot find current publish profile {0}.pubxml in the package output location {1}' -f $profileName, $packOutput 
       } 
       $dockerfileBasePath = $profile.DirectoryName 

       # Find the correct Dockerfile 
       $dockerfileRelPath = $publishProperties["DockerfileRelativePath"] 
       $dockerfilePath = (Resolve-Path (Join-Path $dockerfileBasePath $dockerfileRelPath)).Path 

       # Work around a Docker build command bug docker issue #13898 
       $dockerfilePath = '{0}{1}' -f $packOutput, $dockerfilePath.Substring($packOutput.Length) 

       # Publish the application to a Docker container 
       Publish-DockerContainerApp $publishProperties $packOutput $dockerfilePath 
      } 
     } 

ただし、ブレークポイントではまったく停止しませんでした。どのようにデバッグするのですか?

答えて

0

それを行うための方法があります。 Visual StudioにPowerShellプロジェクトを追加するには、VS用のPowerShellツールを使用する必要があります。プロジェクトを右クリックし、引数を設定します。

関連する問題