【问题标题】:AzureDevops & dotnet pack: ##[error]No files matched the search patternAzureDevops & dotnet pack:##[错误]没有文件与搜索模式匹配
【发布时间】:2020-11-01 19:10:13
【问题描述】:

我有一个项目,我想在 Azure DevOps CI 构建中将其转换为 NuGet 包。解决方案中的相关文件如下所示:

/
    RandExp.sln
        /RandExp
            RandExp.fsproj

        /Tests
            Tests.fsproj

我有一个像这样的 azure-pipelines.yml 文件:

trigger:
- ci

pool:
  vmImage: "ubuntu-latest"

variables:
  buildConfiguration: "Release"

steps:
- task: GitVersion@5
  inputs:
    runtime: 'core'
    updateAssemblyInfo: true

- task: DotNetCoreCLI@2
  displayName: "DotNet restore"
  inputs:
    command: 'restore'
- task: DotNetCoreCLI@2
  displayName: "DotNet build $(buildConfiguration)"
  inputs:
    command: 'build'
    arguments: '--configuration $(buildConfiguration) --no-restore'
  
- task: DotNetCoreCLI@2
  displayName: "DotNet test ($(buildConfiguration))"
  inputs:
    command: test
    arguments: '--configuration $(buildConfiguration)'
    
- task: DotNetCoreCLI@2
  displayName: "DotNet pack"
  inputs:
    command: 'pack'
    nobuild: true
    versioningScheme: 'byBuildNumber'

- task: DotNetCoreCLI@2
  displayName: "DotNet push"
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
    nuGetFeedType: 'external'
    publishFeedCredentials: 'Public Nuget'

在倒数第二个任务之前一切正常:DotNet pack[error]No files matched the search pattern 出错:

Starting: DotNet pack
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version      : 2.175.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
##[error]No files matched the search pattern.
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x (3.1) SDK/Runtime along with 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions. 
Some commonly encountered changes are: 
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
Finishing: DotNet pack

我已经用这个把头撞在墙上好几个小时了;我已经尝试了所有我能想到的方法,但除了同样的错误之外,我无法从这项任务中得到任何东西,现在我放弃了。

值得一提的是,在我的机器上,我可以cd 进入我的解决方案的根目录并运行dotnet pack,它可以正常工作,生成我期望的 nupkg。

【问题讨论】:

标签: .net azure-devops f# nuget


【解决方案1】:

根据docs,您缺少此任务所需的参数

#packagesToPack: '**/*.csproj' # Required when command == Pack

【讨论】:

    【解决方案2】:

    在尝试 nuget 推送时,我在 Devops(带有 Azure Pipelines 代理池)中遇到了基本相同的问题。 packagesToPush 的建议路径:

    '$(Build.ArtifactStagingDirectory)/*.nupkg'
    

    不起作用,也不会等同于上面接受的答案(或与工件暂存目录的任何组合和

    /**/*.nupkg 
    

    通配符,带和不带单引号)。

    我单击省略号并导航到我的 nuget 文件并将文件名更改为通配符,现在它看起来像这样:

    $(System.DefaultWorkingDirectory)/MyPipelineName/drop/*.nupkg
    

    这解决了问题。我得到了“[警告]没有与搜索模式匹配的包”,但是当我更改为使用默认工作目录的路径时,这种情况就消失了。

    【讨论】:

      猜你喜欢
      • 2018-12-31
      • 2021-01-12
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      • 2015-07-07
      • 1970-01-01
      • 2017-11-26
      • 2021-02-22
      相关资源
      最近更新 更多