.net core Azure Pipeline-dotnet构建失败,返回“0”;错误MSB3073:命令netcoreapp2.2/ThisAssembly.Project.g.cs';已退出,代码为2。”;

.net core Azure Pipeline-dotnet构建失败,返回“0”;错误MSB3073:命令netcoreapp2.2/ThisAssembly.Project.g.cs';已退出,代码为2。”;,.net-core,azure-devops,azure-pipelines,azure-pipelines-build-task,azure-pipelines-release-task,.net Core,Azure Devops,Azure Pipelines,Azure Pipelines Build Task,Azure Pipelines Release Task,我的netcoreapp2.2项目在本地VS中成功构建,但在Azure管道上失败 下面的“script:dotnet build”任务是在创建“新管道”时选择“ASP.NET核心”时添加的默认任务。 我试着把它改成“DotNetCoreCLI@2任务,但该任务失败,出现包不兼容错误。我在添加“”之前遇到的相同错误NuGetToolInstaller@1“任务如下 此任务的YML文件为 # ASP.NET Core # Build and test ASP.NET Core projects ta

我的netcoreapp2.2项目在本地VS中成功构建,但在Azure管道上失败

下面的“script:dotnet build”任务是在创建“新管道”时选择“ASP.NET核心”时添加的默认任务。 我试着把它改成“DotNetCoreCLI@2任务,但该任务失败,出现包不兼容错误。我在添加“”之前遇到的相同错误NuGetToolInstaller@1“任务如下

此任务的YML文件为

# 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'
构建失败,日志如下

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'."
Azure管道-dotnet生成失败,错误为“错误MSB3073:命令netcoreapp2.2/ThisAssembly.Project.g.cs已退出,代码为2。”

根据错误消息:

sed:无法读取s/(.*)“/\1”/:没有这样的文件或目录

出现MSBuild错误MSB3073时,表示项目中自定义命令行的路径不正确。您需要检查该命令行的路径

此外,错误显示找不到文件或目录
s/\(.*\)“/\1
,因此,您需要确保生成服务器中的路径正确。您可以直接在生成服务器中执行该命令行,以检查其是否正常工作


希望这有帮助。

谢谢。但是,我的项目中没有这样的自定义命令。@amsDeveloper,它应该存在于您忽略的某个地方,否则,将不会有这样的错误消息。请仔细检查您是否在项目中设置了任何bat/bash命令行或生成事件。只需签入以查看提供的信息是否有用。请让我们知道你是否需要进一步的帮助。谢谢!但现在我被困在这个阶段。有什么解决办法吗?这是另一个问题,社区中的其他人会帮助你解决它,那么现在这个问题如何?它是否仍然存在?如果有,你可以将最新信息分享给我,我会继续关注。没有出路,所以我放弃了netco重新部署了2.2项目,并基于Azure WebJob模板创建了net461项目。因此,对我来说,这个问题现在已经解决了。