Installing a Nuget Package in an .sqlproj - visual-studio

I want to install a nuget package (ReportGenerator) to help collate coverage reports across various projects in a solution in Azure. Some of these projects are SQL projects with unit tests undertaken with TsqlT. However I need to add a refernce to ReportGenerator in the test sqlProj projects.
Nuget package manager doesnt seem supported;
is there anyway I can add this package as a reference?

Related

How to create a Nuget package from Unit Test project

I have a useful extension for Xunit which I use through various .NET 3.1 projects. I want to build a NuGet package to easily distribute it.
But when I add a Xunit dependency to my Visual Studio project it is immediately marked as Unit Test project and stops generating .nupkg file (I have "Generate NuGet package on build" checked in the project settings).
Can anyone help me?
I ended up deleting unnecessary dependencies like "Microsoft.NET.Test.Sdk" after that my project stopped being a unit test project. Then I switched Xunit dependency to xunit.extensibility.core which is supposed to be used especially for extensions.
Finally, Visual Studion successfully generated .nupkg file on build

How can I add NuGet packages to one project in my solution and share those packages with all of my other projects in the solution?

I'm working in Visual Studio with a solution that has several projects. Many of these projects all use the same NuGet packages. Every time I need to update the packages I have to go manage the package for the entire solution then select the check box for every project and update them.
Is there no way for me to add the NuGet packages into a single class library project and then just reference that project from the other projects that need the packages? This seemed to work when I was dealing with .net standard class library projects but not with .net framework. When I do this, the Nuget package assemblies are not available.
My goal with this would be to only have to update the packages in one project which would basically take care of it for all of the other projects in the solution that are using those packages.

Is there a way to view which package source an installed NuGet package is from, in Visual Studio?

In Visual Studio's NuGet Package Manager, you can view which NuGet packages have been installed in a solution by clicking the "Installed" tab in the package manager.
However, in situations where the same package is in multiple NuGet Package Sources, it would be useful to see which package source a particular NuGet package has come from. Is there a way to see this in the NuGet Package Manager, or any where else in VS?
Edit:
Copying in my comment below for clarification:
I'm creating a project using a preexisting one as a model. Both projects will need to reference the same Nuget packages, so I open up the model project in Visual Studio, open the Nuget Package Manager, and look at its installed packages. The model project has "PackageA" installed. I open the new project, open the Nuget Package Manager for it, and Browse for "PackageA". I notice that "PackageA" is available in multiple Package Sources. (These are internal to my company, not nuget,org) In my new project, I'd like to install "PackageA" from the same Package Source as the model project
Is there a way to view which package source an installed NuGet package is from, in Visual Studio?
The simple answer is No. That is because the information about which NuGet packages have been installed in a solution by in the "Installed" tab in the package manager is based on the packages.config file. There are only package ID, version, targetFramework options in that file, so we could get the NuGet Package Sources info in the package manager based on the Packages.config.
Besides, when we use NuGet to manage our packages, NuGet will download the packages from the NuGet Package Sources and set those packages into the Packages folder in the solution folder. What we have to do next are related to the packages in the Packages folder rather than NuGet Package Sources (except NuGet restore, Restore just download the packages from NuGet Package Sources). So we could not find the package source only be based on a package which has been downloaded already without package source info in the Package.config.
What`s more, when we use NuGet to download the packages, NuGet will search the NuGet Package Sources one by one to download, NuGet could not be smart to store the Package Sources where each package download from.
I'd like to install "PackageA" from the same Package Source as the model project
To resolve this question, you can open the Packages folder, copy "PackagesA", set it to the NuGet Package Source which you want to use, then install "PackageA" from that Package Source, you will get the same package as the model project.
You asked for it! It just took 4.5 years.
Now (.NET 6 tooling) you do have a way to configure packages sources which is also called package source mapping:
https://www.youtube.com/watch?v=G6P38Dn69Ro
https://devblogs.microsoft.com/nuget/introducing-package-source-mapping/

TeamCity Nuget feed viewing

So maybe I'm a little bit confused about how a nuget server works and the specifics of nugets in general.
I am setting up octopus deploy and TeamCity for my company and have run into a bit of a snag. I am trying to set up a deployment where I deploy a website and a service in the same release, however, Octopus can't seem to find the nuget package. It throws the following error:
Could not find any packages with ID 'PackageName' in the feed 'octopus://'
I am able to see the package when I test the feed in octopus, and I verified that I am using the correct ID in teamcity. Basically what I've been trying to research is how I can view all of my nugets in the feed. Is that a thing? I am using TeamCity as the Nuget server and I know with octopus you can view all packages that have been pushed to its repository. Am I able to view all packages in the TeamCity Nuget server? I want to verify that my package is there.
In order for Octopus to be able to publish the package, it needs it to be set to build an OctoPack.
To get this working, use the NuGet package manager for the project in question and add a reference to 'OctoPack'.
Bear in mind that if you have a Visual Studio solution containing several packages and you want several of these to be deployable packages you will have to add OctoPack to each project you want as a deployable package.
Include Octopack in the project to build the nuget package.
Use this parameter with MSBuild to automatically push the package to the destination nuget gallery after the build is complete.
/p:OctoPackPublishPackageToHttp=http://my-nuget-server/api/v2/package

How do I integrate NuGet into my Bamboo Build Plan?

Our build plans for Sitecore (.Net) websites are currently using Bamboo as the build plan master for continuous integration process. Bamboo supports building a .Net project, and that .Net project contains references to several Sitecore binaries.
I have used NuGet as an artifact repository, mostly because that seemed to be the one most people were using.
So, now that I have a nuget repository, am hosting my own feed, and have added the Nuget package to my project (I just installed the package of binaries I created), what more do I need to do?
Should the build call out something special, or am I done? I guess I'm just nervous that bamboo isn't talking directly to my repository....
In the closest analogy I have, namely a Maven/Archiva combo, the maven plan specifically references the artifacts in archiva, pulling the correct version as needed. Does NuGet do this?
Since there have been some new developments in the NuGet package restore approach, I thought I'd post an update on this topic. We're using Visual Studio 2012. I wanted to be able to run MSBuild and make sure that it would first restore NuGet packages without setting "Package restore" to true in the config. Here's what I did (inspired by https://stackoverflow.com/a/23935892/414376):
Upgraded NuGet in my solution to a version later than 2.7 (2.8.3 in my case; this seems like an optional step)
Installed NuGet.exe on the build server
Added NuGet.exe to my remote agent so that it could be run as a command from Bamboo
Added the NuGet command to my build plan with argument restore (so that the command will be nuget restore); I've placed it right before my MSV Build task.
That was all I needed to get this to work properly according to the latest guidelines.
Nuget 1.4+ supports "Package restore" which embeds a call to an MsBuild task in the project file. When the packages are not available it will automatically restore them while building the project.
I'm sure this is old news, but my packages are in \packages. No amount of "dotnet restore" would work, until I explicitly mentioned the packages folder.
dotnet restore --packages .\packages
restored them!
VS2019. just in case it's version specific.

Resources