0
votes

My netcoreapp2.2 project which builds successfully in local VS, but fails on Azure Pipeline.

The "script: dotnet build" task below is the default task which got added when I selected "ASP.NET Core" when creating "New Pipeline". I tried changing it to "DotNetCoreCLI@2" task, but that one fails with package incompatibility error. The same error which I was getting before adding "NuGetToolInstaller@1" task below.

YML file for this task is;

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '2.2.104'

- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '5.2.0'
    checkLatest: true

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: 'WebJobCore.sln'
    feedsToUse: 'select'

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'WebJobArtifact'
    publishLocation: 'Container'

Build Fails with log as below;

Starting: dotnet build Release
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.151.2
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
dotnet build --configuration Release
========================== Starting Command Output ===========================

  Restoring packages for /home/vsts/work/1/s/WebJobCore/WebJobCore.csproj...
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.Data.Services.Client 5.6.4 requires Microsoft.Data.OData (= 5.6.4) but version Microsoft.Data.OData 5.8.4 was resolved. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'Microsoft.Azure.ConfigurationManager 4.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'Microsoft.Azure.WebJobs.Extensions.GroupQueueTrigger 2.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'Microsoft.Data.Services.Client 5.6.4' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'Microsoft.IdentityModel.Protocol.Extensions 1.0.2.205111437' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'NLog.AzureAppendBlob 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'NLog.Extensions 1.0.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'TransientFaultHandling.Core 5.1.1209.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj : warning NU1701: Package 'windowsazure.mediaservices 4.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project. [/home/vsts/work/1/s/WebJobCore.sln]
  Generating MSBuild file /home/vsts/work/1/s/WebJobCore/obj/WebJobCore.csproj.nuget.g.props.
  Restore completed in 709.14 ms for /home/vsts/work/1/s/WebJobCore/WebJobCore.csproj.
  sed: can't read s/\(.*\)"/\1";/: No such file or directory
/home/vsts/.nuget/packages/msbuilder.thisassembly.project/0.3.4/build/MSBuilder.ThisAssembly.Project.targets(84,3): error MSB3073: The command "sed -i '' 's/\(.*\)"/\1";/' 'obj/Release/netcoreapp2.2/ThisAssembly.Project.g.cs'" exited with code 2. [/home/vsts/work/1/s/WebJobCore/WebJobCore.csproj]

Build FAILED.

"Bash exited with code '1'."
1
Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.Leo Liu-MSFT
Thanks! But now I am stuck at this stage. stackoverflow.com/questions/58360789/… Any solution for this?amsDeveloper
That be a another question, other people in the community will help you solve it, so how about this issue now? Does it still exist? If yes, you can share the latest info to me, I will keep follow.Leo Liu-MSFT
There was no way out, so I gave up on netcoreapp2.2 project and created net461 project based on Azure WebJob template. So, for me this issue is closed now.amsDeveloper

1 Answers

0
votes

Azure Pipeline - dotnet build fails with “error MSB3073: The command netcoreapp2.2/ThisAssembly.Project.g.cs' exited with code 2.”

According to the error message:

sed: can't read s/(.*)"/\1";/: No such file or directory

When you got the MSBuild error MSB3073, that means the path of the custom command line in your project is not correct. You need to check the path of that command line.

Besides, the error show that it could not found the file or directory s/\(.*\)"/\1, so, you need to make sure the path is correct in the build server. You could execute that command line in the build server directly to check if it works fine.

Hope this helps.