如何为离线tfs构建任务添加nuget包

问题描述 投票:0回答:2

我有一个无法访问互联网的 TFS 构建服务器。有一个带有 Nuget Restore 步骤的构建定义。据我了解,它的配置是从目标目录文件夹中获取包:

至少所有旧包都在这个文件夹中。

我必须添加一些新包,但是当我将其添加到此文件夹构建过程时找不到它们:

2024-03-25T01:17:13.1908678Z Restoring NuGet package System.Text.Json.5.0.0.
2024-03-25T01:17:13.1908678Z Restoring NuGet package System.Text.Encodings.Web.5.0.0.
2024-03-25T01:17:13.1918682Z Restoring NuGet package System.Runtime.CompilerServices.Unsafe.5.0.0.
2024-03-25T01:17:13.1928680Z Restoring NuGet package System.Buffers.4.5.1.
2024-03-25T01:17:13.2258701Z Missing $(NuGetRestorePath)\.nuget\packages\system.text.json\5.0.0\system.text.json.nuspec
2024-03-25T01:17:13.2258701Z Missing $(NuGetRestorePath)\.nuget\packages\system.buffers\4.5.1\system.buffers.nuspec
2024-03-25T01:17:13.2268678Z Missing $(NuGetRestorePath)\.nuget\packages\microsoft.bcl.asyncinterfaces\5.0.0\microsoft.bcl.asyncinterfaces.nuspec
2024-03-25T01:17:13.2268678Z Missing $(NuGetRestorePath)\.nuget\packages\system.numerics.vectors\4.5.0\system.numerics.vectors.nuspec
2024-03-25T01:17:13.2278699Z Missing $(NuGetRestorePath)\.nuget\packages\system.text.encodings.web\5.0.0\system.text.encodings.web.nuspec
2024-03-25T01:17:13.2288692Z Missing $(NuGetRestorePath)\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\system.runtime.compilerservices.unsafe.nuspec
2024-03-25T01:17:13.2308680Z Missing $(NuGetRestorePath)\.nuget\packages\system.memory\4.5.4\system.memory.nuspec
2024-03-25T01:17:13.2318684Z Restoring NuGet package System.Threading.Tasks.Extensions.4.5.4.
2024-03-25T01:17:13.2318684Z Missing $(NuGetRestorePath)\.nuget\packages\system.threading.tasks.extensions\4.5.4\system.threading.tasks.extensions.nuspec
2024-03-25T01:19:19.3462514Z WARNING: Unable to find version '4.5.0' of package 'System.Numerics.Vectors'.
2024-03-25T01:19:19.3462514Z   $(NuGetRestorePath)\.nuget\packages\: Package 'System.Numerics.Vectors.4.5.0' is not found on source '$(NuGetRestorePath)\.nuget\packages\'.
2024-03-25T01:19:19.3462514Z   https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
2024-03-25T01:19:19.3462514Z   An error occurred while sending the request.
2024-03-25T01:19:19.3462514Z   Unable to connect to the remote server
2024-03-25T01:19:19.3462514Z   A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 13.107.246.67:443
2024-03-25T01:19:19.3462514Z 

在这种情况下我必须如何添加包?也许我必须在任何地方注册它?或者.nuspec 文件是必要的吗?如果可以的话我该怎么做?

build tfs nuget-package offline
2个回答
0
投票

是的,很可能需要 .nuspec 文件。

作为解决方案,我将包从本地计算机 C:\Users.nuget\packages\ 复制到 TFS 服务器 $(NuGetRestorePath).nuget\packages\


0
投票

Destination directory
任务中的
nuget restore
不是包源,而是
folder where the packages are installed

根据您的错误,包缺少理解路径

$(NuGetRestorePath)\.nuget\packages\
,所以您所做的就是直接将包复制到文件夹中。

要从

local
恢复,实际上您可以使用
nuget.config
。指定本地源源如下示例,将配置放在项目文件夹中。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="localsource" value="path/to/local/packages" />
  </packageSources>
</configuration>

nuget restore
任务中,您可以指定 nuget.config 作为源。

软件包将安装到指定的目标目录(c

© www.soinside.com 2019 - 2024. All rights reserved.