错误:C:\Program Files\dotnet\dotnet.exe 失败,返回码:1
Posted
技术标签:
【中文标题】错误:C:\\Program Files\\dotnet\\dotnet.exe 失败,返回码:1【英文标题】:Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1错误:C:\Program Files\dotnet\dotnet.exe 失败,返回码:1 【发布时间】:2019-05-10 22:28:08 【问题描述】:使用 vsts 构建应用程序。但是在恢复时不断出错。在本地机器上一切运行良好。 vsts 恢复时出错。
这是构建配置。
Global.Json 文件
"sdk":
"version": "2.1.401"
部分参考
https://github.com/NuGet/Home/issues/5941 https://github.com/Microsoft/azure-pipelines-tasks/issues/2747
2018-12-10T01:28:18.4482197Z ##[section]Starting: Restore
2018-12-10T01:28:18.4488549Z ==============================================================================
2018-12-10T01:28:18.4488635Z Task : .NET Core
2018-12-10T01:28:18.4488675Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-12-10T01:28:18.4488739Z Version : 2.144.3
2018-12-10T01:28:18.4488777Z Author : Microsoft Corporation
2018-12-10T01:28:18.4488819Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
2018-12-10T01:28:18.4488876Z ==============================================================================
2018-12-10T01:28:19.2733888Z [command]C:\Windows\system32\chcp.com 65001
2018-12-10T01:28:19.3329111Z Active code page: 65001
2018-12-10T01:28:19.3370119Z SYSTEMVSSCONNECTION exists true
2018-12-10T01:28:19.6492379Z SYSTEMVSSCONNECTION exists true
2018-12-10T01:28:21.5520856Z SYSTEMVSSCONNECTION exists true
2018-12-10T01:28:21.6026525Z Saving NuGet.config to a temporary config file.
2018-12-10T01:28:21.6079287Z Saving NuGet.config to a temporary config file.
2018-12-10T01:28:21.6215729Z [command]"C:\Program Files\dotnet\dotnet.exe" restore D:\a\1\s\src\PlayTimeX.EntityFrameworkCore\PlayTimeX.EntityFrameworkCore.csproj --configfile D:\a\1\Nuget\tempNuGet_4943.config --verbosity Detailed
2018-12-10T01:28:23.2436898Z
2018-12-10T01:28:23.2463203Z Welcome to .NET Core!
2018-12-10T01:28:23.2463656Z ---------------------
2018-12-10T01:28:23.2463901Z Learn more about .NET Core: https://aka.ms/dotnet-docs
2018-12-10T01:28:23.2464089Z Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
2018-12-10T01:28:23.2464228Z
2018-12-10T01:28:23.2464387Z Telemetry
2018-12-10T01:28:23.2464527Z ---------
2018-12-10T01:28:23.2464693Z The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
2018-12-10T01:28:23.2465258Z
2018-12-10T01:28:23.2465414Z Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
2018-12-10T01:28:23.2467775Z
2018-12-10T01:28:23.2468200Z Configuring...
2018-12-10T01:28:23.2468355Z --------------
2018-12-10T01:28:23.2468512Z A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
2018-12-10T01:30:44.0527286Z Decompressing .......... 140247 ms
2018-12-10T01:31:54.5844020Z Expanding .........System.AggregateException: One or more errors occurred. (One or more errors occurred. (The process cannot access the file 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.design\2.1.1\tools\Microsoft.AspNetCore.Razor.Language.dll' because it is being used by another process.)) (The process cannot access the file 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.design\2.1.1\tools\Microsoft.AspNetCore.Razor.Language.dll' because it is being used by another process.) ---> System.IO.IOException: The process cannot access the file 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.design\2.1.1\tools\Microsoft.AspNetCore.Razor.Language.dll' because it is being used by another process.
2018-12-10T01:31:54.5845003Z at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
2018-12-10T01:31:54.5846397Z at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
2018-12-10T01:31:54.5846507Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
2018-12-10T01:31:54.5846616Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
2018-12-10T01:31:54.5847830Z at System.IO.File.Create(String path)
2018-12-10T01:31:54.5847905Z at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
2018-12-10T01:31:54.5847954Z at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
2018-12-10T01:31:54.5848005Z at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
2018-12-10T01:31:54.5848080Z at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
2018-12-10T01:31:54.5848126Z at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
2018-12-10T01:31:54.5848172Z at System.Linq.Parallel.SpoolingTaskBase.Work()
2018-12-10T01:31:54.5848243Z at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
2018-12-10T01:31:54.5848289Z at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o)
2018-12-10T01:31:54.5848361Z at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
2018-12-10T01:31:54.5848433Z --- End of stack trace from previous location where exception was thrown ---
2018-12-10T01:31:54.5848480Z at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
2018-12-10T01:31:54.5848525Z --- End of inner exception stack trace ---
2018-12-10T01:31:54.5849173Z at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
2018-12-10T01:31:54.5849236Z at System.Linq.Parallel.SpoolingTask.SpoolForAll[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, TaskScheduler taskScheduler)
2018-12-10T01:31:54.5849312Z at System.Linq.Parallel.MergeExecutor`1.Execute()
2018-12-10T01:31:54.5849373Z at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
2018-12-10T01:31:54.5850294Z at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
2018-12-10T01:31:54.5850360Z at System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
2018-12-10T01:31:54.5850415Z at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
2018-12-10T01:31:54.5850493Z at System.Linq.Parallel.ListQueryResults`1.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
2018-12-10T01:31:54.5850547Z at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
2018-12-10T01:31:54.5850611Z at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
2018-12-10T01:31:54.5850708Z at System.Linq.Parallel.ForAllOperator`1.RunSynchronously()
2018-12-10T01:31:54.5850757Z at System.Linq.ParallelEnumerable.ForAll[TSource](ParallelQuery`1 source, Action`1 action)
2018-12-10T01:31:54.5850808Z at Microsoft.DotNet.Archive.IndexedArchive.Extract(String compressedArchivePath, String outputDirectory, IProgress`1 progress)
2018-12-10T01:31:54.5850883Z at Microsoft.DotNet.Configurer.NuGetPackagesArchiver.ExtractArchive(String archiveDestination)
2018-12-10T01:31:54.5850929Z at Microsoft.DotNet.Configurer.NuGetCachePrimer.PrimeCache()
2018-12-10T01:31:54.5850975Z at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
2018-12-10T01:31:54.5851067Z at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, Boolean hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider)
2018-12-10T01:31:54.5851452Z at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
2018-12-10T01:31:54.5851529Z at Microsoft.DotNet.Cli.Program.Main(String[] args)
2018-12-10T01:31:54.5851594Z ---> (Inner Exception #0) System.IO.IOException: The process cannot access the file 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.design\2.1.1\tools\Microsoft.AspNetCore.Razor.Language.dll' because it is being used by another process.
2018-12-10T01:31:54.5851672Z at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
2018-12-10T01:31:54.5851723Z at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
2018-12-10T01:31:54.5851774Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
2018-12-10T01:31:54.5851865Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
2018-12-10T01:31:54.5851910Z at System.IO.File.Create(String path)
2018-12-10T01:31:54.5851980Z at Microsoft.DotNet.Archive.IndexedArchive.CopyOperation.Execute()
2018-12-10T01:31:54.5852027Z at Microsoft.DotNet.Archive.IndexedArchive.ExtractOperation.DoOperation()
2018-12-10T01:31:54.5852076Z at Microsoft.DotNet.Archive.IndexedArchive.<>c__DisplayClass19_1.<Extract>b__0(ExtractOperation extractOperation)
2018-12-10T01:31:54.5852153Z at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
2018-12-10T01:31:54.5852200Z at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
2018-12-10T01:31:54.5852245Z at System.Linq.Parallel.SpoolingTaskBase.Work()
2018-12-10T01:31:54.5852317Z at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
2018-12-10T01:31:54.5852449Z at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o)
2018-12-10T01:31:54.5852500Z at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
2018-12-10T01:31:54.5852666Z --- End of stack trace from previous location where exception was thrown ---
2018-12-10T01:31:54.5852716Z at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---
2018-12-10T01:31:54.5852747Z
2018-12-10T01:31:54.6054617Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2018-12-10T01:31:54.6070722Z ##[error]Packages failed to restore
2018-12-10T01:31:54.6122378Z ##[section]Finishing: Restore
【问题讨论】:
从您的日志中:"进程无法访问文件 'C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.design\2.1.1\tools\Microsoft .AspNetCore.Razor.Language.dll',因为它正被另一个进程使用。” 进程中没有并行作业运行。我检查了几次。有时它会完美运行,有时会出错。 您是使用托管代理还是您自己的代理进行构建? 我正在使用 Hosted VS2017 我认为我们曾经遇到过类似的问题,因为我们在失败步骤之前帮助了dotnet build-server shutdown
【参考方案1】:
在构建管道中隐式添加了 SDK 2.1.401。
【讨论】:
谢谢,它对我有用。要明确设置 SDK 的版本,请编辑任务“使用 .NET Core sdk”:只需取消选中“使用全局 json”,就会出现一个文本框,输入所需的 SDK 版本。 这也对我有用,必须添加名为“使用 .NET Core”的任务并指定版本 x.x.x,它解决了我的问题。必须包括完整版本或最新版本的 x。未选择 Visual Studio 版本。【参考方案2】:我遇到了类似的问题
2020-01-30T19:51:47.2936604Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2020-01-30T19:51:47.2961087Z ##[error]Packages failed to restore
通常,我将 Nuget.Config 文件设置为从我的公司 nuget 存储库中提取作为第一手段,将 nuget.org 作为第二手段。 . .在这种情况下,不允许 nuget.org 通过我们的防火墙并导致错误。
在我的 nuget.config 文件中注释掉 nuget.org 引用解决了这个问题。
<packageSources>
<add key="Company NuGet" value="https://nexus.somecompany.com/service/local/nuget/nuget/" />
<!--<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" /> -->
</packageSources>
【讨论】:
以上是关于错误:C:\Program Files\dotnet\dotnet.exe 失败,返回码:1的主要内容,如果未能解决你的问题,请参考以下文章
错误:C:\Program Files\dotnet\dotnet.exe 失败,返回码:1
吉普错误!堆栈错误:`C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe`
节点 Nodemon 错误:找不到模块 'C:\Program Files\Git\node_modules\nodemon\bin\nodemon.js'
为啥 MSBuild 在 C:\ 中查找 Microsoft.Cpp.Default.props 而不是 c:\Program Files (x86)\MSBuild? (错误 MSB4019)
元数据管理器中存在错误。 实例化来自文件“\?C:Program FilesMicrosoft SQL ServerMSAS11.MSSQLSERVEROLAPDataTfs_Anal
npm 安装错误`not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:`