Visual studio solution adding multiple projects - visual-studio-2010

I have 31 projects, each is inside a folder and i have an empty visual studio solution, is there a way to add all projects in the folder to my solution without having to add them one by one?

Assuming you have NuGet installed, you can do this via the Package Manager Console (Tools :: Library Package Manager :: Package Manager Console) using the following:
$sln = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
Get-ChildItem -Recurse *.csproj | %{ $sln.AddFromFile($_.FullName) }
Replace csproj with vbproj if you are using VB.NET.
Edit To clarify: as Dave points out, the reason this is possible via a seemingly unrelated tool is that the PMC exposes a Powershell interface with support for the Visual Studio APIs already configured, making it the simplest way to "script" against the IDE.

Related

Listing all references actually in use

In Visual Studio (Enterpris 2019) using NuGet Package Manager
is it possible to report all references used per project of the solution?
I am esp. interested in the NuGet packages and I noticed that my local repositories
get bloated with folders of older package versions.
Most of them empty with files that are ignored by git.
So a listing of all references actually in use would be helpful.
E.g. via Package Manager Console.
By Package Manager Console, it could be done with it.
You should open the whole solution on VS2019, and then open Package Manager Console, then type:
Get-Package | Select-Object Id,Version,ProjectName
It will list all nuget references and their version per project of the solution.

Nuget handling of libraries in Visual Studio 2013

We have a set of functionality that was previously in a regular dll file, but that is now in a Nuget package. Naturally, we want to pull it using Nuget instead of having to download and update the dll:s manually. All projects are handled in VS 2013, so we have access to it through the package manager.
Now, we need to go over all the projects in the source tree to update the reference to be a nuget reference instead of the old dll reference.
You can do this on a solution level using the package manager, but since there are several dozens of solutions and well over a hundred projects I'd rather not do it manually.
Is there a way to automate this? That is, to iterate through the source tree, find every .sln file and update the references in its underlying project files?
You can probably do it by writing a small C# program. Install NuGet.Core and NuGet.VisualStudio package to the program to use functions in nuget.core.dll and nuget.visualstudio.dll, plus some DTE functions.

Cannot get SpecFlow to work in Visual Studio 2010 no matter what I do!!!11

When I add a reference in a Visual Studio 2010 project via NuGet for Specflow 1.9, I cannot add any features no matter what I do. I've restarted VS, restarted my PC, created new projects, etc. Nothing I do allows me to actually use SpecFlow. I.e. when I go to Project > Add New Item, I do not see any SpecFlow files in the Add New Item dialog.
It is worth noting that I do not have the "ItemTemplates" directory that should supposedly exist in the
"C:\Program Files (x86)\TechTalk\SpecFlow\" directory.
It is also worth noting that I had Visual Studio 2012 Web Express installed, but I'm not sure why that would prevent feature files from showing up under Add > New Item in a VS 2010 project!
Any help is much appreciated.
You need to also install SpecFlow via the Visual Studio Extension Manager.
Tools > Extension Manager
Installing via Nuget only gives you the reference to the SpecFlow dlls - it doesn't install the files for feature templates etc into Visual Studio.
Try to install SpecFlow using Package Manager Console like
PM> Install-Package SpecFlow
More about Package Manager Console
Just to add to ngm's answer.
The NuGet package gives you everything you need to run SpecFlow, for example on a build server.
The VSIX gives you what you need to edit scenarios.
If I'm not mistaken, I got both SpecFlow scenario creation and running of NUnit-based tests working after installing both SpecFlow AND NUnit packages, both via NuGet and also via "Tools > Extension Manager" menu. Until I installed NUnit via "Tools > Extension Manager" I was unable to see execution and reports of any tests/scenarios.
For VS 2013, after I added SpecFlow via nuget, I wasn't able to see the templates as well. I fixed this by:
Downloading a file from
SpecFlow for Visual Studio 2013.
Click Download.
After you download the file (e.g. TechTalk.SpecFlow.Vs2013Integration.vsix), double click it and it will start the installation process.
Close VS 2013. After you start it back up again, you'll be able to see the templates.
Hope this might help other folks too.
After using the package manager to install the .dlls, you need to use tools->"Add-in Manager" to add in the Specflow templates.

How do I remove a custom tool from visual studio?

I've installed the protobuf-net ProtoBufTool custom tool into visual studio to automatically generate .cs file from protocol buffers files. I want to be able to build my project using msbuild for continuous integration and have moved over to using a python script to generate the files.
So how do you remove a custom tool from visual studio?
I've removed it from Documents\Visual Studio 2010\Templates\ItemTemplates\Visual C# which is where I installed it. I've searched for it in the registry and the GAC. I've tried removing it from the file properties in VS and it keeps coming back. I don't want to nuke my machine from orbit!
Edit: I've found the correct registry key now to disable the tool (see Clearing Custom Tool file property in Visual Studio 2010) but I'd still be interested to know if there's a better workflow for managing custom tools
May be you can try:
Tools -> Add-in Managers
Tools -> Extension Manager
"Tools -> External tools" menu can help you.
As Marc pointed out there's a perfectly good uninstaller for just this situation.

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.

Resources