Reputation: 7342
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. 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.
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
Upvotes: 0
Views: 1496
Reputation: 18958
Since your project type and msbuild task would not call dotnet restore
automatically, it need execute another task to call it explicitly. You can try with execute dotnet restore task instead of nuget restore
before execute msbuild xxx.sln
.
In addition, you can also add /t:restore
into MSBuild Argument to call dotnet restore
explicitly:
msbuildArguments: ‘/t:restore’
Note: In msbuild task,restoreNugetPackages
has been deprecated now. It will not work any more and you must use task to achieve restore package.
Upvotes: 3
Reputation: 4896
You have to restore your nuget package first, and you have to supply with SLN file, not with the packages.config.
Your NugetCommand@2 task should only restore a solution file, not restoring packages.config
file. Correct your YAML first.
Upvotes: 1