[英]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.