NuGet newbie question-
I saw repositories.config being added in NuGet packages folder.
Can anyone please guide me what is the purpose of this file?
Thank you!
It's a file that's mostly a NuGet implementation detail, and should not be dealt with directly (it may go away or change in the future).
But for reference, it contains a list of paths that point to all the packages.config in the solution. Typically there is one per project that uses NuGet.
David Ebbo's answer is from 2011, and the official advice keeps changing between versions.
Here's where we stand in 2015, for NuGet 2.7+ with the 'Automatic Package Restore' (recommended) workflow
I'm paraphrasing, but basically the advice is:
Remove packages/repositories.config from source control. We'll re-generate it anyway.
...unless it somehow breaks on your machine. Then do add it to source control.
This hint comes from the section on ignoring files in git:
# Ignore NuGet Packages
*.nupkg
# Ignore the packages folder
**/packages/*
And the important part:
[...]
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
You need to include the repositories.config file in your source repository if you are following the Automatic Package Restore work flow.
Have a look on http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages where it specifically mentions this point.
Related
I have a situation where we have multiple C# projects that use similar set of Nuget packages (ex. Newton Json, Microsoft Compilers and CodeDom, Owin, log4net, jQuery, EntityFramework etc.)
I am trying to see how we can have a shared location for all Nuget packages to reduce the footprint of those binaries in Git, having a single repo for them by centralizing them in one place.
One option I found is to use Nuget.config in each project with repositoryPath set to point at the shared location. This works great for adding/upgrading/restoring Nuget packages in the project but it is not very clean when a package gets removed from one project but is still required in a different one. Basically the package will get removed from the shared location and the change is committed to Git, then when the other project requires it, it would get restored and added back to Git. Not a perfect solution in my mind.
I have a two part question:
1. Is there a way to improve the above workflow when packages get removed?
2. What is the industry standard for handling third party libraries delivered via Nuget? Or if there is none, can you share your experience handling Nuget packages across multiple projects.
If the concern lies with the footprint/organization of the Git repository, maybe you can do a .git ignore for the dependencies folders to prevent git from committing them into the repositories. When you need to build the projects from source, just do a dotnet /nuget restore to get the dependencies from the source you configured in the Nuget.config
Not sure if it is the industry standard, but we host our own Nuget server to control the libraries that the different teams can use. Microsoft has an article on Hosting your own NuGet feeds
Hope it helps.
I'm at wits end here. I've tried everything I can find to get NuGet to restore my packages on the TFS build server and nothing seems to work. (The latest changes I checked in I got here). I have read a lot about problems with older versions of the Build Process Template, so I just changed the build to use TfvcTemplate.12.xaml and still no packages are restored. This latest change (from the link above) had me delete the NuGet.targets file and now I get an error saying:
This project references NuGet package(s) that are missing on this computer.
Enable NuGet Package Restore to download them. For more information, see
http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is
:\Builds\TFS\WebApps\src\WebApps\Main\Src\\.nuget\NuGet.targets.
Since you have tried so many solutions based on google. Which may make your environment complex and confusing.
First there are two ways to do the nuget restore MSBuild-integrated restore and Automatic restore in Visual Studio. There are totally different things.
With NuGet 2.7 and later, Visual Studio automatically restores missing
packages by default at the beginning of a build.
Since you are using NuGet 3.4, suggest you to use Automatic restore.
You could only select one way to do the restore operation. Based your error message NuGet.targets not found, maybe you haven't finished Migrating to automatic restore step. Please do it again or double check this.
You could also test the migration, do the following:
Remove the packages folder from the solution.
Open the solution in Visual Studio and start a build.
Automatic restore should download and install each dependency
package, without adding them to source control.
Do not add $(SolutionDir).nuget\nuget.exe restore -SolutionDirectory ..\ to the pre-build event on my first project in the build order . This is the old way to do the restore. Just like the way describe here.
Nuget Restore.exe was added to the 2013 (v12) templates. Since you are using the TfvcTemplate.12.xaml , you don't have to add it again.
Highly doubt you were mixing up the two ways cause your present dilemma. Suggest you follow the automatic restore process, use a clean environment, complete migration to automatic restore step , test the migration locally, make sure NuGet.exe and NuGet.targets files from .nuget folder in source control are removed, checking pending changes, check your TfvcTemplate.12.xaml Process Templates with Nuget Restore functionality. Create a new build definition with old settings and use the template. Finally trigger the build...
I am using VSTS vNext build system to build a C# solution.
Below you can see the settings for the NuGet Packager. The path to nuspec files is set to reference the .csproj files.
However this includes all .csproj files; I need to exclude test projects. Ignoring 'Core.Test.csproj' but still packaging 'Core.csproj'.
I have tried '*.csproj;-:!*test.csproj' and other combinations but have had no luck figuring this out! Does anyone know how the pattern matching works for vNext build?
**\*.csproj;-:**\*test.csproj should do it (no exclaimation point needed). If not, we may have a bug, and you should file it on GitHub.
The latest version (2.x) of the NuGet task in VSTS and TFS 2018 uses a different pattern for excluding packages. Now you use ! instead of -:.
So **\*.csproj;-:**\*.Test.csproj changes to **\*.csproj;!**\*.Test.csproj.
Full pattern matching documentation can be found here.
I'd like to be able to automatically update the assembly version off all changed projects on a TFS check-in. We'd like to do this as part of our gated check-in so that developers don't have to remember to manually update those numbers on every check-in.
My current approach would be to:
Determine what projects contains changes on check-in
Check out the AssemblyInfo.cs in each project with changes
Increment the version number in each AssemblyInfo.cs file
Begin build process
I assume there is a way to accomplish this using a combination of PowerShell and customizing the TFS build template, but have little familiarity with either. Any help on the matter would be greatly appreciated.
Use the script located here as a pre-build script in your build template.
The script will change all AssemblyInfo.cs files that are found with the build number.
How to update assembly version of your projects using PowerShell scripts. A very good guide.
The answer is bit late but you can find a good guide here , Have a look into that
I've been resorting to manually modifying my .nuspec files every time I update packages. Is there an automatic way of doing this? I'd rather not have to create an additional build step that compares both files and syncs them.
I believe MyGet does this OOB, but unfortunately I can't use MyGet for this specific package.
(FWIW, I'm using VS2015 and Xamarin Studio)
Just call the nuget pack against the csproj instead of nuspec, for example:
nuget pack X.csproj
In addition, you'll have to remove the dependencies from the nuspec, otherwise nuget will get it from there instead of from packages.config.
BTW, check the created nupkg. It may have unwanted files added to it, like, for instance, txt files, if you happen to have any in your project.
If that's the case, you'll have to invoke nuget pack with the -Exclude parameter:
nuget pack X.csproj -Exclude **.txt
I ended up creating a quick C# script (LINQPad rules) that syncs .config and .nuspec using XDocument, NuGet.Core and LINQ. If anyone's interested, I'll post it as a gist.