我的解决方案(.sln)包含21个项目,nuget restore
花费大量时间(4m和56s)。
我正在尝试缓存nuget packages
,以便更快地恢复。
我已经成功缓存了/.nuget/packages
,并且正确缓存了,但是当生成运行时,它尝试访问解决方案中每个项目的project.assets.json
,但出现以下错误: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]
我从Microsoft社区支持论坛中发现,我还需要为每个项目都缓存project.assets.json
。但是如何呢?缓存任务不支持通配符来递归搜索每个项目的project.assets.json
。
另一种解决方案是为每个项目编写21个具有正确路径的缓存任务,但这看起来不正确……也许我做错了吗?
非常感谢您能提供的任何帮助!
谢谢!
编辑这里是我的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