Add NuGet package (ie. xunit.runner.console) at solution level - visual-studio

I need a NuGet (example xunit.runner.console) to run UT from command line.
Right now in one of project I have added xunit.runner.console as dependency so it is downloaded, path is known and I can use it in my build script.
This Project was removed and build-script is broken now. I will need to add it to another project, but the same situation can occur again (or other reasons).
I there a way to download this package but don't link it with concrete project?

You can install the nuget cli and then get the package needed using the build script. So, to answer your question, you can just use it in the build script and fetch the package before starting to build your project.

Related

install chocolatey redis packages for VisualStudio on build

When we download git project and click build button in VS, it restores nuget packages and then compile. always cool.
Just like that, I'd like to install Redis locally before compile because my project unit test job requires Redis.
I found Redis-64 in nuget but I don't know why it does not install properly. It displays "Redis-64 is already installed" but it's not.
There is Chocolately nuget package and Redis for chocolatey. It looks promising to utilize them.
To achieve my goal, it would be required to (1) check installation of chocolately first, and then (2) download redis-64, and then (3) execute redis-server.exe before compile process (could be placed at the Pre-build event command in .csproj property).
I want to know how to check Redis chocolatey installation and rest of other steps in VS. Would you please teach me how to achieve to do that?
I could be way off the mark here, but the redis package that you are referring to, i.e. from NuGet should only include the assemblies that you could then consume within your application. If you actually want to have the Redis application installed, you would want to install the Redis application from Chocolatey.org, which you can find here.
In terms of getting Chocolatey etc installed as part of your build process, you might want to take a look at the build script for ChocolateGUI. As part of it's build, which is executed on AppVeyor, it checks for Chocolatey, and if it isn't there, installs it, and all required applications.
For what you want, I think you need to include:
choco install redis
Within your build script, and this will give you the redis-server.exe that you are looking for.
I installed the redis-64 NuGet package and it just worked for me. It is an unusual package in that it doesn't associate itself with any Visual Studio project, but rather it is referenced from a solution-level packages.config.
To use the Redis server in my integration test, I start the server with this code:
Process.Start(new ProcessStartInfo(Path.Combine(Directory.GetDirectories(#"..\..\..\packages", "Redis-64.*").Single(), "redis-server.exe"), "--bind 127.0.0.1") {
WindowStyle = ProcessWindowStyle.Hidden
});

Package Restore drops pending zero, installing package does not

We have an internal NuGet feed, one of the packages is EPPlus.3.1.3.0.nupkg. Inside the package, EPPlus.nuspec file contains <version>3.1.3.0</version> and the file under package\services\metadata\core-properties\contains <version>3.1.3.0</version>.
In the package browser, it's listed as Version: 3.1.3.0. When installing this package, it is placed under packages\EPPlus.3.1.3.0. The .csproj file contains <HintPath>..\packages\EPPlus.3.1.3.0\lib\net20\EPPlus.dll</HintPath>.
When restoring the package, it's instead restored under packages\EPPlus.3.1.3. This causes the build to fail. Removing and reinstalling the package makes the build work again.
What's causing this issue?
The official NuGet repository also hosts this package, but it uses version 3.1.3 instead of 3.1.3.0
Package restore checks all your feeds in a certain order, which can be set under Options -> NuGet Package Manager -> Package Sources by clicking arrow buttons. If the official repository is listed above your internal feed, it will instead try to restore the package from there.
So while theoretically both packages should hold the same version, the project will indeed fail to build. I've raised a bug report here.

Download nuget and execute in a TeamCity build step

I'm have command line tool built as a NuGet by TeamCity.
My problem is that I would like to use the tool in a build step within the same TeamCity server and the execute the command line tool as part of the step.
The easiest way would be to just compile the command line tool and create an artifact without creating a NuGet and then take an artifact dependency in the other build process and execute the command.
But I would like to know if it's possible to do the same with a NuGet package so I can reuse the tool for other purposes?
Update
After some more testing with TeamCity I think the main issue is that the "NuGet Installer" runner requires a solution file. I can do what I want with a powershell task:
# install the latest package
%teamcity.agent.tools.dir%\NuGet.CommandLine.2.7.1.nupkg\tools\NuGet.exe install octospike-migrator -o tools -excludeversion -source %teamcity.nuget.feed.server%
# run the command line tool
.\tools\octospike-migrator\lib\Octospike.Command.exe
The build step above is working a intended but I have the feeling that the default runner "Nuget Installer" should be able to handle this?
I'm running TC7 so it might be working in TC8
Assuming the package is referenced in your solution and you have enable missing package restore enabled, the package will be downloaded and unpacked into your solution. The executable will go into a known location (whatever directory you've specified for the package). You should then be able to access the executable as you would any other resource.
If you need flexibility in regards to where and how the resources are unpacked (e.g., if they need to go in a directory outside of the project), you can build this as a Tools package in NuGet.
In TeamCity, the complexity will be reduced if you break this process into separate tasks.

Nuget Clean Package Remove/Install

I'd like to remove an entire nuget package, and cleanly install it in my project again.
Sadly, for some reason it skips removing files that have been "modified", and then skips putting them in the project on reinstall, because they already exist.
Is there any flag i can set to unconditionally remove every single trace of a nuget package, alternatively overwrite all existing files?
Thanks.
Unfortunately at the moment, NuGet does not do what you want. During the uninstall process, NuGet will only delete content files if they have not been modified. And as you've noticed, the update process will not update files that were modified either.
The Uninstall-Package command does have a -Force option, but that is to "force" uninstall even if there are other packages that depend on this one.
We can certainly file this as an issue and perhaps incorporate it into a future version.
Another option would be to create a PowerShell script that will enumerate a package's contents, then allow you to delete all the content files. I'll see if there is a simple way to do this.
BTW: Perhaps you can figure out a better way to extend the existing content file other than modifying it directly. Especially since you're losing your changes when the package is updated.
You can now do what you want! (finally)
You need to first update to the latest NuGet (I think this feature was added around April 2013). Do this by going to Tools > Extensions and Updates and click on Updates to update nuget.
Then the -FileConflictAction parameter will allow you to overwrite files.
Install-Package Microsoft.jQuery.Unobtrusive.Validation -Version 2.0.30506.0 -FileConflictAction Overwrite
(PowerShell Command Reference for Install-Package)
The NuGet Version 1.6 HAS a remove package function!
http://docs.nuget.org/docs/release-notes/nuget-1.6
if the update of the extension fails (signatur missmatch), just uninstall and reinstall. this is a known problem.
I think this happened to me a few times. Go to the packages.config file that should be the root directory of your project and remove the insurgent (in your case the line with the package: SignalR). This will tell NuGet that the package was never installed.
Now you will be able to reinstall it through the repository, then uninstall it so everything is back to the way it was before you got into this mess. I am unsure how it is occurring.

How to check a makefile for dependencies?

I'm trying to install something with the following command:
make world
It takes a long time, and usually it ends up with an error saying that I'm missing some kind of package. I found out what the package is, install it, and run the thing again, only to find out after a long time that I'm missing another package. Is there a way to find out all the packages I need to install without having to go through this process?
This is generally what the configure script does. If the project you're building doesn't have one, you should write one.
The best way to deal with dependencies is with a package manager such as:
On Ubuntu: apt-get
On Red Hat / Fedora: yum
On Mac OS X: port
On Windows: cygwin
If you install software with a package manager, it will automatically fetch, download, and install any dependencies as necessary. These package managers support a huge number of popular open source projects, but not all projects are supported. Some of these package managers support creating custom package repositories, which allows them to be used for dependency management in-house, as well.
Unfortunately, there is no general way to get all the library dependencies of a Makefile (short of grepping for "lib", ".so", and "-l" which may give you spurious results); however, if you are installing an open source project, chances are that it is supported by a package manager on your system.

Resources