Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 过程';C:\hostedtoolcache\windows\dotnet\dotnet.exe';失败,退出代码为1_C#_Azure_.net Core_Azure Devops_Azure Pipelines - Fatal编程技术网

C# 过程';C:\hostedtoolcache\windows\dotnet\dotnet.exe';失败,退出代码为1

C# 过程';C:\hostedtoolcache\windows\dotnet\dotnet.exe';失败,退出代码为1,c#,azure,.net-core,azure-devops,azure-pipelines,C#,Azure,.net Core,Azure Devops,Azure Pipelines,我的问题是,我有一个在.net core 2.2中创建的项目,问题是我试图用azure管道部署它,但在使用dotnet还原时,它会不断失败并结束构建 它返回的错误如下: 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 ##[

我的问题是,我有一个在.net core 2.2中创建的项目,问题是我试图用azure管道部署它,但在使用dotnet还原时,它会不断失败并结束构建

它返回的错误如下:

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://docs.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

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文件对一个.NETCore2.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'
为了缩小问题的范围,我建议您:

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

  • 我用你们的管道在最小的解决方案上测试它,它是有效的。你能试着做同样的事情吗?你检查过我的回答了吗?有帮助吗?