c# - 进程 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' 失败,退出代码 1

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

我的问题是我在.net core 2.2中创建了一个项目,问题是我尝试使用azure pipelines部署它,但是当使用dotnet Restore时它不断失败并结束构建。

它返回的错误如下:

2020-11-21T20:17:30.4639428Z ##[error]**Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1**

2020-11-21T20:17:30.4652823Z ##[error]**Packages failed to restore**

2020-11-21T20:17:30.4655465Z **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.**
 
2020-11-21T20:17:30.4656214Z Some commonly encountered changes are: 
2020-11-21T20:17:30.4657227Z 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://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2020-11-21T20:17:30.4661682Z ##[section]Finishing: dotnet restore

我尝试安装版本2.2以在恢复之前的过程中使用,我尝试使用nuget.config和global.json。我将我用过的.yml留在这里,看看是否有人可以提供我伸出一只手。

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 2.2.x'
  inputs:
    version: 2.2.x
    includePreviewVersions: true
    performMultiLevelLookup: true

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'

- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1
    checkLatest: true

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: '$(Parameters.solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: '$(Parameters.ArtifactName)'
  condition: succeededOrFailed()

最佳答案

我已经使用以下 yaml 文件对 .net core 2.2 项目进行了测试,并获得了成功的结果。

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
  - task: UseDotNet@2
    inputs:
      version: '2.2.x'
      includePreviewVersions: true
      performMultiLevelLookup: true
  - task: DotNetCoreCLI@2
    inputs:
      command: 'restore'
      projects: '**/*.csproj'

为了缩小问题范围,我建议您:

  1. 创建一个简单的 .net core 2.2 项目并推送到 DevOps,为此项目创建管道以查看是否可以重现此问题。
  2. 将项目克隆到本地,并在本地运行 dotnet restore 命令查看结果如何。

关于c# - 进程 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' 失败,退出代码 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64947880/

相关文章:

c# - 跨线程使用引用对象

c# - 将字节数组转换为 C# 中未知类型的基本类型数组

c# - 如何为 System.Core 创建外部别名?

.net - 使用 SustainSys Saml2 扩展方法 ToHttpRequestData 编译错误 "call is ambiguous"

c# - 如何在 .net 核心中使用 Openstreetmap(osm) 离线图 block 文件?

c# - 父节点内列表的序列化(集合扁平化)

c# - Azure 上的 Cyber​​Source

c# - Azure WebJob中的手动触发,末尾不输出到队列

azure - 图形 Spark 用户界面 :4040 in SSH VM

c# - 如何使一段数据可供调用堆栈下方的其他函数使用?