I am getting copy errors when my Azure Pipeline is doing a build on projects where a post-build event is present which copies the built .dll into a folder elsewhere in the solution.
The solution in question is ASP.NET Core (more specifically, a Blazor Server App).
The process it should go through is:
The post-build event from the .csproj:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(TargetPath) $(SolutionDir)Server\MySolution.Server\Modules\" />
</Target>
This copy works as expected in VS, but I have made the assumption this will work fine in Pipelines too but I can see it has thrown an error on it, so there is probably something I am missing or a step I need to make in Pipelines to allow this copy action to occur successfully.
It is failing on the "copy" command based on from what I can see on the logs, but as I mentioned this works fine in VS but as soon as Pipelines attempts the build, the copy command fails!
My Pipelines config for the build in question:
- task: DotNetCoreCLI@2
displayName: 'Build Solution'
inputs:
command: 'build'
projects: 'MySolution/MySolution.sln'
The specific error I am seeing about the copy failing:
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.
The full output containing the error (for completeness):
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://learn.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://learn.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
Any further info required from me please let me know.
Your build agent is running Linux (paths use /
and there's the /home
directory). Linux doesn't have the command copy
. It works in VS because you are using Windows.
2020-09-22T22:34:01.2363173Z /bin/sh: 2: tmp/tmp2e509e5e0d8a4a0dbf2e8ff4c7235b88.exec.cmd: copy: not found
Either run your build on a Windows agent or use the built-in Copy
task of MSBuild:
<Target Name="CopyAfterBuild" AfterTargets="PostBuildEvent">
<Copy
SourceFiles="$(TargetPath)"
DestinationFolder="$(SolutionDir)Server\MySolution.Server\Modules\"
/>
</Target>