在 Azure DevOps 中为 Nuget 部署安装 Mono

Install Mono for Nuget Deployment in Azure DevOps

我有一个存储库,用于构建 Nuget 包并将其部署到 Azure DevOps 中的 VSTS 源。它一直工作得很好。但是我 运行 没有空闲时间 :(

所以现在我将使用用于部署到 Azure 应用服务的 VMSS ado 代理。(Linux)

因此,我将 pool: agentname 添加到我的 yaml 中。但是,我现在在推送时遇到单声道错误。

##[error]Error: Unable to locate executable file: 'mono'. Please verify either the 
file path exists or the file can be found within a directory specified by the 
PATH environment variable. Also check the file mode to verify the file is executable.

VMSS不是我创建的,所以我不知道是否安装了mono。然而,这个代理是用来构建和部署.net core 5 应用程序的,所以???我检查了一下,我认为它没有安装(我不熟悉 Linux 命令,但我尝试了:mono、find、which and all dictate no install)。

有没有办法只为 nuget 部署(作为管道的一部分)安装单声道,或者我是否需要扰乱 VMSS?

用我使用的解决方案回答。

如果您使用 Linux 作为代理并使用 Nuget,则必须在代理机器上安装 Mono。 Nuget 在 Linux 上使用单声道。就是这样。如果您可以在 Linux 机器上安装单声道,我认为,那是另一种解决方案。我没有找到一种简单的方法来安装单声道作为工作的一部分 - 我认为无论如何这都会太重(除非它是一个检查,如果没有安装,请安装)。

相反,因为我使用的是 Azure DevOps,所以我使用 dotnet cli 将包推送到提要,这与 Nuget 版本几乎完全相同(唯一的变化是任务)

- task: DotNetCoreCLI@2
  displayName: 'Push'
  inputs:
    command: 'push'
    packagesToPush:'$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: 'internal'
    feedsToUse: 'select'
    vstsFeed: 'your feed'
    publishVstsFeed: 'your feed'
    allowPackageConflicts: true

我回来了!