【问题标题】:Azure PowerShell script - Cannot validate argument on parameter 'Name'Azure PowerShell 脚本 - 无法验证参数“名称”上的参数
【发布时间】:2015-12-28 02:50:51
【问题描述】:

我在 Visual Studio Team Services 上创建了一个 CI 构建来构建我的 ASPNET 5 网站。

我按照this article中的步骤操作。

我有第一个下拉 DNX 的 PowerShell 脚本,并且项目正在通过构建步骤成功构建。

但是,Azure PowerShell 脚本步骤失败。

为了调试它,我创建了一个简单的 PSPing.ps1 脚本,其中仅包含以下内容:

Write-Host "Hello World"

构建过程的结构如下:

当我运行该进程时,我收到以下错误:

ScriptPath= C:\a\1\s\scripts\PingAuth.ps1 scriptCommand= & "C:\a\1\s\scripts\PingAuth.ps1" Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. Cannot index into a null array. Deploy Url: Website Name:

我不明白这个错误,我不明白 Deploy UrlWebsite Name 来自哪里?

【问题讨论】:

  • 投反对票,请发布导致问题的代码而不是链接。包括您尝试解决问题的内容也很有帮助。
  • 我已经包含了构建步骤的图像。我确实解释了我为尝试解决问题所做的工作 - 我创建了一个简单的 PowerShell 脚本并将其添加为第一步。

标签: powershell azure build asp.net-core azure-devops


【解决方案1】:

根据链接,PublishAspNet5Website.ps1 脚本正在寻找两个参数。 See this page 了解更多高级参数。

该脚本的第一行是param($websiteName, $packOutput),这意味着该脚本必须像这样执行PublishAspNet5Website.ps1 -websiteName {WebSite}-packOutput $(Build.SourcesDirectory)\{yourProjectName}\artifacts\bin\$(BuildConfiguration)\Publish

这些参数见第 12 步。

12. 在脚本参数输入中添加以下参数。 -websiteName {yourWebsiteName} -packOutput $(Build.SourcesDirectory){yourProjectName}\artifacts\bin\$(BuildConfiguration)\Publish

【讨论】:

  • 我从最初的 Azure PowerShell 步骤和我指向该步骤的 .ps1 脚本中删除了 param(...)。我这样做是为了在调试时尝试简化事情。如您所见,该过程后面还有第二个 PowerShell 步骤,与本文中的步骤相同。
猜你喜欢
  • 2012-08-31
  • 2021-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-29
  • 2023-02-23
  • 1970-01-01
  • 2019-06-01
相关资源
最近更新 更多