进程"C:\hostedtoolcache\windows\dotnet\dotnet.exe"失败,退出代码为 1



我的问题是我在.net core 2.2中创建了一个项目,问题是我试图用azure管道部署它,但在使用dotnet restore时,它连续失败并结束了构建。

它返回的错误如下:

2020-11-21T20:17:30.4639428Z ##[error]**Error: The process 'C:hostedtoolcachewindowsdotnetdotnet.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命令以查看结果

最新更新