简体   繁体   English

Azure Pipeline构建失败

[英]Azure Pipeline build fails

I have a solution that has 3 projects in it.Two of them are .Net Standard project and one is a .Net Framework project which is Unit Test. 我有一个包含3个项目的解决方案,其中两个是.Net Standard项目,一个是.Net Framework项目,即单元测试。 I am trying to build it but I get an error. 我正在尝试构建它,但出现错误。

 C:\Program 
 Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file 'D:\a\1\s\src\TestIOC\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file 'D:\a\1\s\src\TestMvvm\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
Process 'msbuild.exe' exited with code '1'.

This is my current Azure Pipelines YAML file. 这是我当前的Azure Pipelines YAML文件。

trigger:
- master

pr:
- master

variables:
  buildConfiguration: Release
  buildPlatform: Any CPU
  coreSolution: 'src\TestMvvmCore.sln'
  coreCSProj: 'src\TestMvvm\*.csproj'
  testCSProj: 'src\TestMvvm.Tests\*.csproj'
pool:
    vmImage: vs2017-win2016

steps:

- task: NuGetToolInstaller@1
  inputs:
    versionSpec: '4.9.1'

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln, src\TestMvvm.Tests\packages.config'
    feedsToUse: 'select'

- task: MSBuild@1
  displayName: Build TestMvvm Solution
  inputs:
    solution: '$(coreSolution)'
    configuration: '$(buildConfiguration)'
    restoreNugetPackages: true

I would appreciate if someone can help me fix the error 如果有人可以帮助我修复错误,我将不胜感激

Since your project type and msbuild task would not call dotnet restore automatically, it need execute another task to call it explicitly. 由于您的项目类型和msbuild任务不会自动调用dotnet restore ,因此需要执行另一个任务来显式调用它。 You can try with execute dotnet restore task instead of nuget restore before execute msbuild xxx.sln . 您可以在执行msbuild xxx.sln之前尝试执行dotnet restore任务而不是nuget restore

In addition, you can also add /t:restore into MSBuild Argument to call dotnet restore explicitly: 此外,还可以将/t:restore添加到MSBuild参数中以显式调用dotnet restore

msbuildArguments: ‘/t:restore’

Note: In msbuild task, restoreNugetPackages has been deprecated now. 注意:在msbuild任务中, restoreNugetPackages已被弃用。 It will not work any more and you must use task to achieve restore package. 它不再起作用了,您必须使用task来获得还原包。

You have to restore your nuget package first, and you have to supply with SLN file, not with the packages.config. 您必须先还原nuget软件包,并且必须提供SLN文件,而不是packages.config。

Your NugetCommand@2 task should only restore a solution file, not restoring packages.config file. 您的NugetCommand @ 2任务应仅还原解决方案文件,而不还原packages.config文件。 Correct your YAML first. 首先更正您的YAML。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 azure devops 管道构建失败,出现错误 CS1043 - azure devops pipeline build fails on error CS1043 Azure 管道在“dotnet build”上失败,错误“命令或文件未找到” - Azure Pipeline fails on `dotnet build` with error "command or file was not found" Docker 映像构建在 Azure DevOps 发布管道中失败 - Docker image build fails in Azure DevOps release pipeline 由于Microsoft.AspNetCore程序包中的版本冲突,Azure DevOps管道构建失败 - Azure DevOps pipeline build fails due to version conflict within Microsoft.AspNetCore packages Linux Jenkins 管道 dotnet 构建作为管道失败,但不是作为自由式项目 - Linux Jenkins Pipeline dotnet build fails as Pipeline, but not as Freestyle Project Azure DevOps 为 Winforms 应用程序构建 PIpeline - Azure DevOps Build PIpeline for Winforms Application 在 Azure DevOps 上为 Service Fabric 应用程序构建管道 - Build pipeline for service fabric app on Azure devops 在 Azure Pipeline 和 Linux 上构建 .Net Framework - Build .Net Framework on Azure Pipeline and Linux Azure 管道 dotnet 未创建发布版本 - Azure Pipeline dotnet not creating release build Azure DevOps Pipeline 无法找到来自其他项目的 DLL - Azure DevOps Pipeline Fails DLL From Other Project Not Found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM