gpt4 book ai didi

.net命令列表包--在azure管道中格式化json

转载 作者:行者123 更新时间:2023-12-03 06:07:03 25 4
gpt4 key购买 nike

我想在托管的 Azure 管道上运行以下 dotnet 命令来生成 nuget 包列表:

dotnet list package --format json --include-transitive >/home/vsts/work/1/a/depts.json

但是,找不到该命令:

Possible reasons are:
* You misspelled a built-in dotnet command.
* You wanted to run a .NET program, but dotnet-list package --format json --include-transitive > /home/vsts/work/1/a/depts.json is not present.
* You wanted to run a global tool, but an executable prefixed with dotnet with that name could not be found in the PATH.

如果我理解 documentation正确的话,那么我需要.net core 3.1或更高版本。在管道中使用版本 2.221.0。这就是为什么我尝试安装版本 3.1.31。但是,这也行不通。

这是我的管道:

trigger:
- master

pool:
vmImage: ubuntu-latest

# install .net core sdk 6 for restore
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: 'sdk'
version: '6.0.x'
includePreviewVersions: true

# restore solution
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'nuget.config'
externalFeedCredentials: 'TelerikFeed'
displayName: Restore nuget packages

# install .net core runtime
- task: UseDotNet@2
displayName: 'Use .NET Core runtime'
inputs:
packageType: 'runtime'
version: '3.x'
installationPath: $(Agent.ToolsDirectory)/dotnet

# execute list package command
- task: DotNetCoreCLI@2
inputs:
command: 'custom'
custom: 'list package --format json --include-transitive > $(Build.ArtifactStagingDirectory)/depts.json'

# also not working
- task: Bash@3
inputs:
targetType: 'inline'
script: |
dotnet list package --format json --include-transitive > $(Build.ArtifactStagingDirectory)/depts.json

# publish file
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'

谁能告诉我我做错了什么或者我的情况是否可能?提前致谢

最佳答案

the docs for dotnet list package的顶部说它在 .NET Core 3.1 中可用。但是,这通常指的是 dotnet list package。如果您向下滚动到记录 --format 的位置,它会显示:

Available starting in .NET SDK 7.0.200.

因此,您需要使用.NET 7 SDK。

关于.net命令列表包--在azure管道中格式化json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77190424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com