Add project in solution using NuGet - visual-studio

Currently I have a requirement to add multiple projects to a solution via NuGet package. I know that adding files to the solution is possible as described in this link, but I'm not able to add project in the solution. I wan't to know that it's possible or not and if possible how i achieve this. Any help will be greatly appreciated. Thanks.

This is not really possible using a single command. If you are using install.ps1 scripts, you can choose to modify the sln file in the script.
E.g If you open a sln file that has a project you can see the following
Project("{Project Guid}") = "ProjectName", "Relative path to project", "{Project Guid}"
In your install.ps1 script, you can crack open the sln and insert a similar entry for each of your projects during install.
Do note, this is probably something you will have to use nuget commandline for,
nuget install
since there is no easy UI way of installing NuGet packages to a solution in VS 2015.

Related

Project vcpkg settings missing from Visual Studio Project Properties

One of my vcxproj's (with a vcpkg.json) looks like this
And another one (with a vcpkg.json) looks like this. Note the missing option.
But I need to be able to enable the vcpkg Manifest so it can compile! I'm stuck, where did this option go? Both proj's are in the same solution. Both have vcpkg.json added to their Source Files. Notably one has a different dir structure (proj/proj.vcproj vs proj/build/proj.vcproj) so the vcpkg.json is further away
As a design note, conditionally hidden options or grayed-out options are an anti-pattern.
A vcpkg.json alone is not enough. vcpkg needs to be enabled in your proj.vcproj file.
Try the following steps:
Close the solution
Open the proj.vcproj files in a normal editor
Look for the VcpkgEnableManifest and other vcpkg properties in there.
Better still, use WinDiff or a similar DIFF tool to discover the differences between the vcproj files.
I cannot be more specific because you didn't say how you imported/integrated the vcpkg options into your project in the first place. There are many different ways to do that.
For example, I am using the vcpkg export --nuget command to export a nuget package, which I then add to my individual projects with the Visual Studio nuget package manager. This will import "vcpkg.props" from the nuget package directory. This import command adds the options you are missing. If you are using the same method, you probably forgot to add the nuget package to your other project. This way of integrating vcpkg is "per project" rather than globally, so it does not matter if the two projects are in the same solution or not.
If otoh you used the vcpkg integrate command to integrate the vcpkg globally, things will be different. In this case the import command will be inside some Microsoft.props file and the options should appear in all projects.
Okay, I found out how to fix it. I had gotten myself in a corrupted state by unloading and loading VS projects while VS was open AND while running vcpkg integrate project/install commands.
I misunderstood those commands. I thought vcpkg integrate project installed MSBuild vcpkg just for that project so I thought I had to run that for each .vcprojx.
Rather, vcpkg integrate project may be better named vcpkg integrate nuget and vcpkg integrate install could be named vcpkg integrate msbuild?
In any case, the fix was to close all instances of Visual Studio (I even uninstalled extra versions), and just run vcpkg integrate install ONCE and then reopen Visual Studio. Then it worked.

Using NuGet without .sln or .csproj files

I am currently working in a UFT project, using the VBScript language.
This project does not have a .sln or even .csproj files, because of this i am using the nuget.exe.
I want to use NuGet to manage binaries. I am already able to push a NuGet package to the repository, however I can not update or install it.
This is how my project looks like(I know its a bit different and is located on c:):
So it happens that I searshed on the internet but there are not even one project that looks like mine, most of them are done on Visual Studio.
Could you help me on how to use NuGet in a project like this one?
Thanks!

Update reference paths for all projects in a solution at once

I need to add a reference path to all projects (over 35 projects) in a solution. Doing this manually would be time consuming.
Is there a way to update/add/remove reference paths for all the projects programmatically?
I found an add-in that helps in what I need but unfortunately the add-in's download link is broken.
You could always open the csproj files in a text editor an perform a find/replace. Notepad++ has a handy replace in files feature.
Using Visual Studio PowerCommands you can copy and paste references, so it won't be as tedious, at least. It makes many other things less tedious as well.
If your reference is one the NuGet packages, you can easily use the NuGet package manager for the solution and select the installed package that you want to remove, check desired projects, then uninstall them.
for installation: first, select the desired package, check target projects, then click install.
its work for me as I have a solution with 35 projects.

Is it possible to modify VS project file during NuGet package installation?

I'd like to create a custom MSBuild task and distribute it as a NuGet package. To enable my task, the visual studio proj file should be modified.
Is it possible to add my code sections to the proj file when installing the NuGet package?
You can do this using Powershell. It is possible to unload you project, edit the project file and reload the project.
Scott Hanselman did this here: http://channel9.msdn.com/Events/MIX/MIX11/FRM09
If you find a package that does what you want, you can open the nuget package using ZIP and see the powershell scripts. Thats a good starting point to learn that stuff.
hope that helps
I think you are better off using the NuGetPowerTools package as answered in this question:
Adding a custom build step with a nuget package
This package handles all the Visual Studio automation.

Add NuGet Packages Folder to Solution File?

Nuget puts the package in my root folder(in my case my trunk folder). I am wondering is there a way to let VS 2010 know about this folder? I am using ankh svn to do my commuting so it would be really nice to have it in my solution so when I add a reference I can commit it from VS 2010 and not have to go to my trunk and manually do it.
Can this be done?
You may be interested in reading this NuGet doc:
Using NuGet without committing packages to source control
The easiest way to do this currently is by using the Working Copy Explorer (View -> Working Copy Explorer). From here you can browse your solution folder, and add the reference.
I added the idea to enhance this to the AnkhSVN feedback forum, please go vote :-)
You should consider 'don't commit packages workflow'. It is much more mature solution:
http://blog.davidebbo.com/2011/08/easy-way-to-set-up-nuget-to-restore.html
You can add the packages directory as a web project. I use TFS so the only issue is after adding a package I need to include these files to the source control but at least there visible...

Resources