简体   繁体   English

用于TFS构建的NuGet存储库

[英]NuGet Respository for TFS Build

I am unable to find a clear answer with all my searching. 我所有的搜索都找不到清晰的答案。 We have TFS 2015 and are looking to use a custom NuGet Respository to store our internal packages. 我们拥有TFS 2015,并希望使用自定义的NuGet存储库来存储我们的内部包。

Currently they reside on physical drive on the same server as the TFS installation. 当前,它们与TFS安装位于同一服务器上的物理驱动器上。 However it constantly fails to find any of the packages. 但是,它经常找不到任何软件包。

My confusion arises here. 我的困惑在这里出现。 In order to use this directory as a Nuget repo, do we need to install additional software or generate some index.json? 为了将此目录用作Nuget存储库,我们是否需要安装其他软件或生成一些index.json? The existence of the packages in the folder doesn't suffice? 文件夹中是否存在软件包不足? I've seen a lot of articles talking about the Package Management plugin (which has a cost above 5 people) or upgrading to TFS 2017. 我已经看过很多关于Package Management插件(成本超过5人)或升级到TFS 2017的文章。

Am I correct in my understanding that simply keeping the packages in a location the server has access to and pointing to it is not sufficient? 我的理解是否正确,仅将软件包放在服务器可以访问并指向的位置是不够的?

Thanks! 谢谢!

UPDATE: 更新:

According to BehemothDan's comments below, this issue was solved by installing Nuget.Server as an application on server in IIS. 根据BehemothDan在下面的评论,此问题已通过将Nuget.Server安装为IIS中服务器上的应用程序来解决。 Just provide the TFS build process with a URL instead of a directory path everything worked great. 只需为TFS构建过程提供一个URL而不是一个目录路径,一切就可以很好地进行。 (Point the Nuget.Server to the directory) (将Nuget.Server指向目录)


Just as Daniel said "the NuGet will use that package source. Nothing to do with TFS. All the build system does is run stuff on the command line." 正如Daniel所说:“ NuGet将使用该程序包源。与TFS无关。构建系统所做的全部工作都是在命令行上运行。”

So, you just need to set the source: 因此,您只需要设置源:

  1. Create a Local feed (a nuget repository , this can be a share folder which can be accessed by the TFS.) 创建本地提要nuget存储库 ,它可以是共享文件夹,TFS可以访问该文件夹)。
  2. Download/copy the needed packages to the repo folder. 将所需的软件包下载/复制到repo文件夹。
  3. Set package source in nuget.config or directly add the source in Visual Studio. nuget.config设置包源,或在Visual Studio中直接添加源。

Thus nuget will identify the source and restore the packages automatically when you build in TFS. 因此,当您在TFS中构建时,nuget将识别源并自动还原软件包。

You can reference this article to understand that: 您可以参考本文以了解以下内容:

Creating a local NuGet repository for offline development 创建本地NuGet存储库以进行离线开发


Besides, TFS introduced the Package Management feature in TFS 2017 and later version. 此外,TFS在TFS 2017及更高版本中引入了包管理功能。

So, you can directly manage the packages in TFS if upgrade to TFS 2017 or later version. 因此,如果升级到TFS 2017或更高版本,则可以直接在TFS中管理软件包。

See Get started with NuGet Package Management in VSTS and TFS for details. 有关详细信息,请参阅VSTS和TFS中的NuGet程序包管理入门

You can also reference this article to Publish to Private NuGet Server from TFS2017 Build 您还可以参考本文以从TFS2017 Build发布到私有NuGet服务器

If your build doesn't run correctly on the TFS it means that you don't have the same structure of folders(or dependencies) on the TFS compared to your local computer. 如果您的构建无法在TFS上正确运行,则意味着与本地计算机相比,您在TFS上的文件夹(或依赖项)结构不同。 In that case, the TFS agents are trying to compile the source on the TFS and not finding the dependencies. 在那种情况下,TFS代理试图在TFS上编译源,而没有找到依赖关系。

In order to use a directory as a Nuget repo, you don't need to install anything, but sure there are a couple things you should know. 为了将目录用作Nuget存储库,您不需要安装任何东西,但是请确保您应该了解以下几点。 You have 2 ways to reference your packages: you can use Package references, using the PackageReference node, and it manages NuGet dependencies directly within project files and secondly as opposed to it, Packages.config node, which saves the configuration in a .config file. 您有2种方式来引用您的软件包:您可以使用Package引用,通过PackageReference节点,它直接在项目文件中管理NuGet依赖关系,其次,与Packages.config节点相反,它将配置保存在.config文件中。 。

在此处输入图片说明

The big deal is that PackageReference is used for .NET Core projects, so which kind of projects are you trying to build? 最重要的是,PackageReference用于.NET Core项目,那么您要尝试构建哪种项目?

.NET full framework projects support PackageReference, but currently, default to packages.config .NET完整框架项目支持PackageReference,但当前默认为packages.config

My suggestion is: -if you are dealing with a .netcore project, use PackageReference and open your solutions, and see if all your dependencies are pointing to 我的建议是:-如果您正在处理.netcore项目,请使用PackageReference并打开您的解决方案,并查看所有依赖项是否指向

%SystemDrive%\\Users\\.nuget %SystemDrive%\\ Users \\ .nuget

The same path should be on the TFS in order to compile correctly, for optimization reasons you should not move this folder to another one, so if you are in charge of the TFS monitor the space of your C drive because it can grow exponentially. 为了正确编译,TFS上应该有相同的路径,出于优化原因,您不应将此文件夹移动到另一个文件夹,因此,如果您负责TFS监视器,则C驱动器的空间可能会成倍增长。

-if you are not dealing with .NetFramework, not Core, then you should create a local repo as @Andy Li-MSFT said. -如果您不使用.NetFramework,而不是Core,则应按@Andy Li-MSFT所说创建本地存储库。 I suggest you read this answer I posted here a while ago step by step: https://stackoverflow.com/a/43791395/819153 我建议您阅读我刚才一步一步发布的答案: https : //stackoverflow.com/a/43791395/819153

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM