我正在使用scott hanselman's example将asp.net Web应用程序发布到docker容器。
项目内部有一个自动生成的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 :(得分:0)
有办法做到这一点。将PowerShell项目添加到Visual Studio,您必须使用VS的PowerShell工具。右键单击项目并设置参数。