简体   繁体   中英

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.

Currently they reside on physical drive on the same server as the TFS installation. 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? 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.

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. Just provide the TFS build process with a URL instead of a directory path everything worked great. (Point the Nuget.Server to the directory)


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."

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.)
  2. Download/copy the needed packages to the repo folder.
  3. Set package source in nuget.config or directly add the source in Visual Studio.

Thus nuget will identify the source and restore the packages automatically when you build in TFS.

You can reference this article to understand that:

Creating a local NuGet repository for offline development


Besides, TFS introduced the Package Management feature in TFS 2017 and later version.

So, you can directly manage the packages in TFS if upgrade to TFS 2017 or later version.

See Get started with NuGet Package Management in VSTS and TFS for details.

You can also reference this article to Publish to Private NuGet Server from TFS2017 Build

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. In that case, the TFS agents are trying to compile the source on the TFS and not finding the dependencies.

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. 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.

在此处输入图片说明

The big deal is that PackageReference is used for .NET Core projects, so which kind of projects are you trying to build?

.NET full framework projects support PackageReference, but currently, default to 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

%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.

-if you are not dealing with .NetFramework, not Core, then you should create a local repo as @Andy Li-MSFT said. I suggest you read this answer I posted here a while ago step by step: https://stackoverflow.com/a/43791395/819153

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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