My solution(.sln) contains contains 21 projects and the nuget restore
takes a lot of time(4m and 56s).
I am trying to cache the nuget packages
for faster restore.
I've successfully cached the /.nuget/packages
and it caches correctly but when the build runs it tries to access the project.assets.json
for every project in solution and I get the following error:
error NETSDK1004: Assets file 'd:\a\1\s\src\Project\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [d:\a\1\s\src\Project\Project.csproj]
I've found from the Microsoft community support forums that I need to cache also the project.assets.json
for every project... But how? The cache task doesn't support wildcards to recursively search through each project's project.assets.json
.
Another solution would be to write 21 cache tasks with the exact path for each project, but this doesn't look right... maybe I'm doing something wrong?
I really appreciate any help you can provide!
Thanks!
EDIT here is my auzre-pipelines.yml:
trigger: none
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
configuration: Release
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
CACHE_RESTORED: 'false'
- task: UseGitVersion@5
displayName: 'Install GitVersion5'
inputs:
versionSpec: '5.x'
additionalArguments: '/output buildserver -config .\GitVersion.yml'
- task: NuGetToolInstaller@1
displayName: 'Install NuGet 5.3.x'
inputs:
versionSpec: '5.3.x'
- task: Cache@2
inputs:
key: 'v1 | nuget | "$(Agent.OS)"'
path: $(NUGET_PACKAGES)
cacheHitVar: CACHE_RESTORED
- task: NuGetCommand@2
inputs:
command: 'restore'
condition: ne(variables.CACHE_RESTORED, 'true')
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: 'a-dummy-feed'
- task: VSBuild@1
inputs:
solution: '**\*.sln'
msbuildArgs: '/t:Restore'
platform: 'any cpu'
configuration: 'Release'
clean: true
logProjectEvents: false
- task: NuGetCommand@2
displayName: 'Generate .nupkg'
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
configuration: '$(configuration)'
versioningScheme: 'byEnvVar'
versionEnvVar: 'UseGitVersion.GitVersion.NuGetVersion
- task: NuGetCommand@2
displayName: 'Push .nupkg to AzureArtifacts Feed'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'a-dummy-feed'
publishPackageMetadata: false
allowPackageConflicts: true