Azure Pipeline中NuGet Restore因临时配置文件不存在失败求助
解决Azure Pipeline自动生成NuGet配置文件不存在的Restore错误
检查NuGet工具与MSBuild 14的兼容性及安装完整性
确认Pipeline中NuGetToolInstaller任务指定的5.x/6.x版本能和MSBuild 14(对应VS2015)兼容,可在Pipeline中添加步骤执行nuget.exe --version,验证工具是否正常可用、路径是否正确。手动添加nuget.config并指定路径
在代码库根目录创建一个基础的nuget.config文件,内容示例:<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> </packageSources> </configuration>接着在Pipeline的NuGetRestore任务中显式指定该配置文件路径,覆盖自动生成的临时文件参数:
- task: NuGetCommand@2 inputs: command: 'restore' restoreSolution: '**/packages.config' configFile: '$(Build.SourcesDirectory)/nuget.config' verbosityRestore: 'Detailed'提前创建临时配置文件目录
若Azure Pipeline代理无法自动生成D:\a\1\Nuget\目录,可在NuGet Restore任务前添加PowerShell步骤手动创建:New-Item -Path D:\a\1\Nuget -ItemType Directory -Force改用MSBuild内置的Restore命令
直接使用MSBuild 14自带的Restore功能替代NuGet.exe,规避Pipeline自动添加的configFile参数冲突,执行命令示例:msbuild D:\a\1\s\x\你的项目文件.csproj /t:Restore /p:Configuration=Release /v:Detailed
内容的提问来源于stack exchange,提问作者TechStack
相关产品推荐
相关产品推荐

