Ben*_*ose 1 nuget nuget-package-restore azure-devops
我似乎无法为我的DevOps构建管道找到正确的设置,以使其能够还原NuGet软件包,以便构建过程可以找到它们。
我遇到的第一个问题是默认设置将还原指向我的.sln文件,该文件导致其打印出来:
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
Run Code Online (Sandbox Code Playgroud)
这是Visual Studio 2017网站.sln文件,不包含有关NuGet的信息,也没有其他答案建议的.csproj。
我通过将其指向packages.config文件来解决了这个问题。现在,还原过程确实找到了所需的软件包,但似乎并没有将它们放在“ Visual Studio Build”构建过程可以找到它们的地方。
Error CS0246: The type or namespace name 'Nest' could not be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我查看了构建过程部分,但是找不到任何有用的信息,因为唯一的参考标记为:
不建议使用此选项。要还原NuGet软件包,请添加NuGet工具安装程序
这就是我已经在尝试做的事情。我曾尝试将NuGet还原的目标目录移动到bin其他位置,但是并没有什么不同。
恢复文件后,我缺少移动文件的步骤吗?还是在构建时需要传递一个参数来告诉它软件包文件在哪里?
Azure DevOps,使用website.sln时为“ Visual Studio Build”还原NuGet程序包吗?
您应该在构建管道中使用NuGet安装程序任务。
不建议使用“还原NuGet软件包 ”选项:
不建议使用此选项。要还原NuGet软件包,请在构建之前添加一个NuGet安装程序步骤。
因此,要解决此问题,请尝试使用NuGet安装程序任务,转到“程序包”选项卡,然后添加NuGet还原任务。
您可以指定packages.config或.sln文件来还原软件包。指定packages.config时,还需要提供Destination目录,默认值为/ packages:
After taking a look at this for a different pipeline I worked out the answer. In short it was to was to do with the packages.config and sln file locations along with the relative paths used to restore and search for the packages.
The long answer.
In the Build solution log after it gives the error for the missing files it lists all the places it's checking.
For SearchPath "{CandidateAssemblyFiles}".
For SearchPath "{HintPathFromItem}".
For SearchPath "{TargetFrameworkDirectory}".
For SearchPath "bin\Release\".
For SearchPath "{RawFileName}".
Run Code Online (Sandbox Code Playgroud)
The HintPathFromItem was most interesting as it mentions the package folder.
For SearchPath "{HintPathFromItem}".
Considered "packages\log4net.2.0.0\lib\net40-full\log4net.dll", but it didn't exist.
Run Code Online (Sandbox Code Playgroud)
With this in mind I checked where the NuGet restore was placing the packages folder and found that it was adding it at the same level as the website root. In my case by changing the destination directory to
packages
Run Code Online (Sandbox Code Playgroud)
instead of
/packages
Run Code Online (Sandbox Code Playgroud)
or
../packages
Run Code Online (Sandbox Code Playgroud)
将其上移一级到网站根目录内构建正在搜索的位置。
| 归档时间: |
|
| 查看次数: |
2627 次 |
| 最近记录: |