c# - 多个包与指定模式匹配 : %s. 请限制搜索模式

标签 c# azure .net-core azure-devops

我试图在 Azure DevOps 中创建发布管道。 所有部分都工作正常,但在 IIS Web 部署中出现错误。

More than one package matched with specified pattern: %s. Please restrain the search pattern.

Error

这是 Web 部署的任务。

IIS Web Deploy

我的 yml 为:

trigger:
- main

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    zipAfterPublish: true
    arguments: '--output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
  inputs:
   pathToPublish: $(Build.ArtifactStagingDirectory)
   artifactName: AspNetCoreExample

最佳答案

More than one package matched with specified pattern: %s. Please restrain the search pattern

zip 文件来自您的构建管道。如果您只需要 .zip,请将构建管道发布工件任务配置为仅使用此文件。

但是,您已通过任务 VSBuildDotNetCoreCLI:publish 发布了项目。在这种情况下,您的工件中将多一个 .zip 文件,这将导致该问题。

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2  #Move this task.
  inputs:
    command: 'publish'
    publishWebProjects: true
    zipAfterPublish: true
    arguments: '--output $(build.artifactstagingdirectory)'

要解决此问题,请移动任务 - 任务:DotNetCoreCLI@2 并确保您的 .zip 文件中只有一个包。

关于c# - 多个包与指定模式匹配 : %s. 请限制搜索模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65435877/

相关文章:

Azure SQL Server 数据库价格

azure - Azure Service Fabric 中的副本 ID 真正代表什么?

c# - 无法将类型 'System.Linq.IQueryable' 隐式转换为 'System.Data.Entity.DbSet'

c# - 来自 WebService 的未经净化的 XML,如何净化

c# - IronPython、单击一次、.NET 2.0 错误 - 有什么想法?

c# - 如何确保 typeof 和强制转换运算符在不同的加载上下文而不是默认加载上下文上运行

c# - 为什么 Span<T> 扩展方法未使用 'in' 参数修饰符实现?

c# - ASP.NET MVC Controller 生命周期

azure - Microsoft Purview - 如何删除 Business Glossary

c# - 在 Windows 和 Linux 上部署时异步 TcpClient 连接不同