【问题标题】:Publishing ASP.Net Core app to Azure silently fails in command line在命令行中以静默方式将 ASP.Net Core 应用程序发布到 Azure 失败
【发布时间】:2017-03-15 04:27:41
【问题描述】:

我正在尝试将 dotnet 核心应用程序发布到 Azure。我创建了一个发布配置文件并使用 Visual Studio 一切正常。但由于我想设置持续部署,我需要使用命令行运行部署。

official documentation 非常有助于确定[ProfileName].ps1 是最佳攻击计划。

但是它没有提供如何使用它的线索。 首先我在没有参数的情况下运行它并得到了这个错误:

Production-publish.ps1 : The term 'Production-publish.ps1' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ Production-publish.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Production-publish.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

接下来我添加了需要的参数:

.\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml'

运行没有错误但没有做任何事情!

如何通过 Powershell 进行 Azure 部署?

【问题讨论】:

    标签: asp.net asp.net-core azure-web-app-service web-deployment continuous-deployment


    【解决方案1】:

    通过publish-module.psm1 进行调试以找出为什么没有部署任何内容后,我注意到该命令需要提供更多参数。方法如下:

    .\Production-publish -packOutput 'C:\code\my-dotnetcore-proj\publish' -pubProfilePath 'Production.pubxml' -publishProperties @{
        'username' = '%PublishProfile.Username%'
        'Password' = '%PublishProfile.Password%'
        'AllowUntrustedCertificate' = false
        'AuthType' = 'Basic'}
    

    您显然必须替换 %PublishProfile.Username%%PublishProfile.Password% 并可能修改 Production-publishProduction.pubxml

    请注意,只有 Password 参数是必需的(考虑到 .pubxml 文件中提供了 UserName)

    实际上,我最终写了一篇关于如何使用 TeamCity 编译和部署 asp.net 核心站点的博客文章: How to deploy ASP.NET Core sites using Teamcity to Azure/IIS … or just command line

    【讨论】:

      猜你喜欢
      • 2017-12-08
      • 1970-01-01
      • 2017-07-02
      • 2021-01-19
      • 1970-01-01
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多