【发布时间】:2020-09-22 23:02:50
【问题描述】:
当我的 Azure Pipeline 正在对存在构建后事件的项目进行构建时,我遇到了复制错误,该事件将构建的 .dll 复制到解决方案中其他位置的文件夹中。
有问题的解决方案是 ASP.NET Core(更具体地说,是 Blazor 服务器应用程序)。
它应该经历的过程是:
- 构建项目
- 构建后事件将项目 bin 文件夹中生成的 .dll 复制到同一解决方案中另一个项目的 Modules 文件夹中
.csproj 的构建后事件:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(TargetPath) $(SolutionDir)Server\MySolution.Server\Modules\" />
</Target>
这个副本在 VS 中按预期工作,但我假设这在管道中也可以正常工作,但我可以看到它已经抛出了一个错误,所以我可能缺少一些东西或者我需要一个步骤在 Pipelines 中制作以允许此复制操作成功发生。
根据我在日志上看到的内容,“复制”命令失败,但正如我提到的,这在 VS 中工作正常,但一旦 Pipelines 尝试构建,复制命令就会失败!
我的管道配置用于相关构建:
- task: DotNetCoreCLI@2
displayName: 'Build Solution'
inputs:
command: 'build'
projects: 'MySolution/MySolution.sln'
我看到的有关复制失败的具体错误:
2020-09-22T22:34:01.2727771Z /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj(36,5): error MSB3073: The command "copy /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/bin/Debug/netstandard2.1/MySolution.Theme.Material.dll /home/vsts/work/1/s/MySolution/Server\MySolution.Server\Modules\" exited with code 127.
包含错误的完整输出(为了完整性):
2020-09-22T22:33:33.5852128Z ##[section]Starting: Build Solution
2020-09-22T22:33:33.5866102Z ==============================================================================
2020-09-22T22:33:33.5866437Z Task : .NET Core
2020-09-22T22:33:33.5866800Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2020-09-22T22:33:33.5867126Z Version : 2.175.0
2020-09-22T22:33:33.5867363Z Author : Microsoft Corporation
2020-09-22T22:33:33.5867729Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2020-09-22T22:33:33.5868125Z ==============================================================================
2020-09-22T22:33:33.9961797Z Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
2020-09-22T22:33:34.0033069Z [command]/usr/bin/dotnet build /home/vsts/work/1/s/MySolution/MySolution.sln -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.175.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.175.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"
2020-09-22T22:33:34.2910272Z Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET
2020-09-22T22:33:34.2911156Z Copyright (C) Microsoft Corporation. All rights reserved.
2020-09-22T22:33:34.2911472Z
2020-09-22T22:33:35.0270052Z Determining projects to restore...
2020-09-22T22:33:39.3163149Z Restored /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material.Demo/MySolution.Theme.Material.Demo.csproj (in 195 ms).
2020-09-22T22:33:40.0504837Z Restored /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj (in 190 ms).
2020-09-22T22:33:40.0540508Z Restored /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material.Admin/MySolution.Theme.Material.Admin.csproj (in 160 ms).
2020-09-22T22:34:01.2236036Z MySolution.Theme.Material -> /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/bin/Debug/netstandard2.1/MySolution.Theme.Material.dll
2020-09-22T22:34:01.2363173Z /bin/sh: 2: /tmp/tmp2e509e5e0d8a4a0dbf2e8ff4c7235b88.exec.cmd: copy: not found
2020-09-22T22:34:01.2380595Z ##[error]MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj(36,5): Error MSB3073: The command "copy /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/bin/Debug/netstandard2.1/MySolution.Theme.Material.dll /home/vsts/work/1/s/MySolution/Server\MySolution.Server\Modules\" exited with code 127.
2020-09-22T22:34:01.2382849Z /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj(36,5): error MSB3073: The command "copy /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/bin/Debug/netstandard2.1/MySolution.Theme.Material.dll /home/vsts/work/1/s/MySolution/Server\MySolution.Server\Modules\" exited with code 127.
2020-09-22T22:34:01.2582713Z
2020-09-22T22:34:01.2583274Z Build FAILED.
2020-09-22T22:34:01.2583756Z
2020-09-22T22:34:01.2585185Z Services/Infinity/ThemeChangeSvc.cs(19,22): warning CS0414: The field 'ThemeChangeSvc.isFirst' is assigned but its value is never used [/home/vsts/work/1/s/MySolution/Shared/MySolution.Shared/MySolution.Shared.csproj]
2020-09-22T22:34:01.2587083Z /usr/share/dotnet/sdk/3.1.402/Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/home/vsts/work/1/s/MySolution/Shared/MySolution.Infrastructure/MySolution.Infrastructure.csproj]
2020-09-22T22:34:01.2588614Z /usr/share/dotnet/sdk/3.1.402/Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis.CSharp" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/home/vsts/work/1/s/MySolution/Shared/MySolution.Infrastructure/MySolution.Infrastructure.csproj]
2020-09-22T22:34:01.2590436Z _Imports.razor(20,7): warning CS0105: The using directive for 'MySolution.Shared.Dto.Account' appeared previously in this namespace [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2594561Z _Imports.razor(22,7): warning CS0105: The using directive for 'MySolution.Shared.Dto.Account' appeared previously in this namespace [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2595871Z _Imports.razor(26,7): warning CS0105: The using directive for 'MySolution.Shared.Data' appeared previously in this namespace [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2597755Z Pages/ExternalAuth/Success.razor(21,35): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2599598Z Shared/Layouts/FrontEndLayout.razor(130,35): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2601156Z Shared/Layouts/FrontEndLayout.razor(146,30): warning CS0168: The variable 'ex' is declared but never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2602997Z Pages/Account/Contact.razor(104,35): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2604537Z Pages/Account/Login.razor(276,26): warning CS0168: The variable 'ex' is declared but never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2606141Z Shared/Components/Breadcrumbs.razor(60,74): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2607637Z Pages/Account/Profile.razor(325,26): warning CS0168: The variable 'ex' is declared but never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2609316Z Pages/Account/Profile.razor(332,54): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2610765Z /usr/share/dotnet/sdk/3.1.402/Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/home/vsts/work/1/s/MySolution/Server/MySolution.Storage/MySolution.Storage.csproj]
2020-09-22T22:34:01.2612279Z /usr/share/dotnet/sdk/3.1.402/Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: Found conflicts between different versions of "Microsoft.CodeAnalysis.CSharp" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/home/vsts/work/1/s/MySolution/Server/MySolution.Storage/MySolution.Storage.csproj]
2020-09-22T22:34:01.2613833Z _Imports.razor(20,7): warning CS0105: The using directive for 'MySolution.Shared.Dto.Account' appeared previously in this namespace [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2615276Z _Imports.razor(22,7): warning CS0105: The using directive for 'MySolution.Shared.Dto.Account' appeared previously in this namespace [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2616604Z _Imports.razor(26,7): warning CS0105: The using directive for 'MySolution.Shared.Data' appeared previously in this namespace [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2618521Z Pages/ExternalAuth/Success.razor(21,35): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2620562Z Shared/Layouts/FrontEndLayout.razor(130,35): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2715254Z Shared/Layouts/FrontEndLayout.razor(146,30): warning CS0168: The variable 'ex' is declared but never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2717047Z Shared/Components/Breadcrumbs.razor(60,74): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2719017Z Pages/Account/Contact.razor(104,35): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2720552Z Pages/Account/Login.razor(276,26): warning CS0168: The variable 'ex' is declared but never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2723159Z Pages/Account/Profile.razor(325,26): warning CS0168: The variable 'ex' is declared but never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2724872Z Pages/Account/Profile.razor(332,54): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2726467Z Pages/Account/Login.razor(152,17): warning CS0414: The field 'Login.LoginSuccess' is assigned but its value is never used [/home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj]
2020-09-22T22:34:01.2727771Z /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/MySolution.Theme.Material.csproj(36,5): error MSB3073: The command "copy /home/vsts/work/1/s/MySolution/Shared/Modules/MySolution.Theme.Material/bin/Debug/netstandard2.1/MySolution.Theme.Material.dll /home/vsts/work/1/s/MySolution/Server\MySolution.Server\Modules\" exited with code 127.
2020-09-22T22:34:01.2729322Z 28 Warning(s)
2020-09-22T22:34:01.2729492Z 1 Error(s)
2020-09-22T22:34:01.2729614Z
2020-09-22T22:34:01.2729796Z Time Elapsed 00:00:26.88
2020-09-22T22:34:01.2882759Z ##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
2020-09-22T22:34:01.2888191Z 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-09-22T22:34:01.2889095Z Some commonly encountered changes are:
2020-09-22T22:34:01.2890684Z 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-09-22T22:34:01.2896528Z ##[error]Dotnet command failed with non-zero exit code on the following projects : /home/vsts/work/1/s/MySolution/MySolution.sln
2020-09-22T22:34:01.2943673Z ##[section]Finishing: Build Solution
如果需要我提供任何进一步的信息,请告诉我。
【问题讨论】:
-
这个问题也适合DevOps交流站。
标签: asp.net build azure-devops azure-pipelines post-build-event