【问题标题】:Publish-AzureWebsiteProject Failing in Release ModePublish-AzureWebsiteProject 在发布模式下失败
【发布时间】:2018-05-30 05:30:39
【问题描述】:

我正在尝试通过使用 Publish-AzureWebsiteProject 命令并将“配置”参数提供为“发布”的 Powershell 脚本通过 TeamCity 部署 Azure Web 服务(Web API 项目)。

在调试模式下,同一项目有一个单独的 TC 构建配置成功,但是,我在发布模式下部署的新版本失败。构建项目的上一步(使用 TC 内置的“Visual Studio 解决方案”命令)成功,但到发布步骤时,它失败了,声称存在构建错误。

日志将此报告为错误:

File.cs(12,7): error CS1041: Identifier expected; 'static' is a keyword
File.cs(12,14): error CS1518: Expected class, delegate, enum, interface, or struct

它抱怨的那一行看起来像:

using static MyPackage.Extensions.ExtensionClass;

但是,我可以通过 TeamCity 在 Debug 模式下部署这个项目,我可以在 Debug 和 Release 模式下本地构建它,并且可以在 Release 模式下成功地进行本地文件发布。

有人有什么想法吗?我的第一个想法是它使用的编译工具版本与我在本地使用的不同,但它会根据构建配置而有所不同是没有意义的。

【问题讨论】:

  • 从您的陈述中删除“静态”,看看是否有帮助。
  • 我知道我可以更改代码来解决这个问题,但我想了解为什么它可以在 Debug 中发布但不能在 Release 中发布的根本原因,特别是如果这个错误再次出现在未来。

标签: c# azure teamcity azure-powershell azure-web-app-service


【解决方案1】:

如果您的包是已发布的 zip,那么您可以尝试 Kudu Rest API 的发布方式。即使最初当我使用Publish-AzureWebsiteproject 时,我也遇到了类似的问题。这是我用于成功部署的代码。

$creds = Invoke-AzureRmResourceAction -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $functionAppName/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
$username = $creds.Properties.PublishingUserName
$password = $creds.Properties.PublishingPassword
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
Write-Host -ForegroundColor Yellow `r`n"Deploying Azure Functions..."
$apiUrl = "https://" + $functionAppName +".scm.azurewebsites.net/api/zip/site/wwwroot"
$filePath = ".\PublishedOutput.zip"
$Headers = @{Authorization = ("Basic {0}" -f $base64AuthInfo)}
Invoke-RestMethod -Uri $apiUrl -Headers $Headers -Method PUT -InFile $filePath -ContentType "multipart/form-data"

【讨论】:

    猜你喜欢
    • 2011-05-21
    • 2018-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多