azure-devops - DotNetCLI@2 包似乎忽略了配置输入

标签 azure-devops azure-pipelines nuget-package-restore dotnet-cli

下面的 YAML 片段似乎没有按预期工作。

我在使用 Windows 最新镜像运行的管道中配置了它,它尝试恢复存储库中的所有项目,而不是仅查看解决方案文件。

此外,它似乎完全忽略了 --no-restore 标志

- task: DotNetCoreCLI@2
  displayName: Package to Staging directory
  inputs:
    command: pack
    configuration: $(BUILD_CONFIGURATION)
    projects: 'support-libs.sln'
    packDirectory: $(Build.ArtifactStagingDirectory)
    nugetConfigPath: 'sf-solution/nuget.config'
    arguments: '--no-restore'
    verbosityRestore: Minimal

步骤日志中显示的命令是:

"C:\Program Files\dotnet\dotnet.exe" pack d:\a\1\s\sf-solution\SampleProject\SampleProject.csproj --output d:\a\1\a /p:Configuration=Debug --verbosity Detailed

上述项目甚至没有包含在代码段配置的 support-libs SLN 文件中。

最佳答案

The above project is not even included in the support-libs SLN file the snippet has configured

不知道为什么 DotNetCLI 任务打包该项目,该项目未包含在支持库 SLN 中。由于您没有在问题中共享项目文件结构和构建日志,因此我无法向您提供此问题的直接原因。

但作为解决方法,您可以指定特定的项目文件而不是解决方案文件。此外,您还可以通过经典编辑器查看此任务:

enter image description here

它指出要打包的csproj 或 nuspec 文件的路径

对于忽略配置输入问题,有一个选项不构建,因此,您可以将此参数添加到您的打包任务中,而不是参数--no-restore:

- task: DotNetCoreCLI@2
  displayName: 'dotnet pack'
  inputs:
    command: pack
    packagesToPack: YourProjectPath&Name.csproj
    nobuild: true

注意:在使用此包任务之前添加 DotNet 构建任务。

希望这有帮助。

关于azure-devops - DotNetCLI@2 包似乎忽略了配置输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59171961/

相关文章:

tfs - 如何在任务中标记 2 *工作日 *(或更多)的延迟?

azure - 如何从 Azure 发布管道配置 Jmeter 测试

visual-studio-code - 通过 Azure DevOps 发布 VS Code 扩展

deployment - Azure yaml 管道 "Expected mapping end"

Nuget 与 Artifactory。 key 在指定状态下无效

git - 仅在包更改时在 VSTS 中构建 Monorepo

azure-devops - Azure DevOps - 组织项目和存储库

azure - 如何将工作项(用户故事)添加到先前的迭代(冲刺)

c# - 如何设置 nuget 引用的动态路径?

asp.net-mvc - 包 'Microsoft.Net.Compilers' 的项目 PROJECT : Unable to find version 2. 0.0 的 NuGet 包还原失败