Sharing my dll libraries across projects in VS2010 - visual-studio-2010

What is the best way to share dll libraries between projects, through VS2010? For example we have made a generic helper library that is useful in everything. However, we need more than one library to be included (which is a separate project in TFS) so branching is not suitable.
We are using Team Foundation Server 2010 for source control. Is there maybe a simple way to integrate these libraries into a new project, so the new project can come "fully buffed" very fast?
What we do now is go through each project, build them, store the dll files, add a new project then throw them in the Bin folder, which is tedious work when you have many libraries.

Have you thought about hosting your own NuGet feed? I use a pre-build script for NuGet for each of my projects which downloads packages for me before the project is built, and, I assume, keeps them up to date.

I don't think that there is some TFS-based solution for sharing binaries between projects. However you can use NuGet to do it for you. Create nuget package for each project (you can create TFS build definition to do it automatically) and publish it to network share. Than add this share as NuGet feed.

Related

Difference between adding a Reference and adding a Nuget package to a project in Visual Studio

I have a VS (2015) project. I see there's a "References" section in the Solution Explorer view of my project that includes things like System.Core. I'm assuming these are .dlls that have been added to the project?
I can also right-click on the project file (again in the Solution Explorer) and select the option to "Manage NuGet Packages". I know the NuGet allows me to add external code to my project (e.g. external .dlls and associated files).
What's the difference between adding a reference to my project and adding a .nupkg to my project? Is it just that .nupkg can contain a whole bunch of other things aside from a .dll (e.g. documentation)? Why would I use one or the other?
What's the difference between adding a reference to my project and
adding a .nupkg to my project?
NuGet essentially does not differ from manually adding references, and ultimately adds references to the project. It is a tool that automatically adds assemblies to us and manages them, effectively improving the efficiency of our development projects.
For more details, you can check the document about nuget:
Put simply, a NuGet package is a single ZIP file with the .nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number. Developers with code to share create packages and publish them to a public or private host. Package consumers obtain those packages from suitable hosts, add them to their projects, and then call a package's functionality in their project code. NuGet itself then handles all of the intermediate details.
Because NuGet supports private hosts alongside the public nuget.org host, you can use NuGet packages to share code that's exclusive to an organization or a work group. You can also use NuGet packages as a convenient way to factor your own code for use in nothing but your own projects. In short, a NuGet package is a shareable unit of code, but does not require nor imply any particular means of sharing.
.
Is it just that .nupkg can contain a whole bunch of other things aside
from a .dll (e.g. documentation)?
Yes, NuGet package could include specify files in the package.
Why would I use one or the other?
Nuget provides several additional benefits:
it automatically configures your projects by adding references to the
necessary assemblies, creating and adding project files (e.g.
configuration), etc.
it provides package updates
it does all of this very conveniently
I'm sure that once you use it, you'll realize that it has many benefits.
Check Why use NuGet for more details.
Hope this helps.

Project Locations in Visual Studio 2015

I have an ASP.NET Core app that will be using some class library projects e.g. domain, repositories, etc.
These class libraries will also be used in another cloud app that runs as a worker role which is why I want to keep them separate and their development should follow its own course and not necessarily depend on the ASP.NET Core app.
With that said, the ASP.NET Core project should be aware of any changes made to the class library projects which is why I want to link them to the solution for the ASP.NET project.
What's the best way to structure these project folders? Currently my folder structure is as follows:
My Projects Folder
--- MyAspNetCoreProject (Has its own solution)
--- MyBackendProject (Has its own solution which contains the following projects)
----- DomainProject
----- RepositoriesProject
When I try to "Add Existing Project" to link my backend projects to my ASP.NET Core project, I get the following message:
The project that you are attempting to add to source control may cause
other source control users to have difficulty opening this solution or
getting newer versions of it. To avoid this problem, add the project
from a location below the binding root of the other source controlled
projects in the solution.
You'll need to move the referenced project under the same solution. If you do want separate solutions you can't link as a project -- before .NET Core you could link the assembly(s) instead.
One problem of trying to link projects under other solutions is that other users may not have a copy of all the necessary solutions and may be installed in different locations from other users. The solution needs to keep track of where the assemblies are built.
If you build the library as a NuGet package then linking the reference is easy.
Your options become
Move all projects under the same solution
Keep separate solutions and publish your library as a (private) NuGet package

VS2012 Solution Open scripting or automation

I need to copy standard component DLLs into a standard folder defined in every VS2012 project when the project is opened. We're not allowed to store DLLs in Subversion so I need to reload this folder every time a developer opens the project/solution. I'm looking for an automation solution that will pull DLLs from a centralized location and copy them into the developer's solution. I looked at Visual Studio Extensions but it seems like an awful lot of work just to copy a couple of files. Are there any other hooks in VS2012 (and hopefully VS2010) where I can code simple PowerShell scripts to copy these files?
It turns out AntHillPro has it's own functionality for storing common DLLs and loading them into folders in your Solution before building. It's not as elegant as an MSBuild pre-build task but it fits in with the model followed by our Java builds with some slight tweaking.
Why you just do no use Nuget? Adding nuget reference and enable nuget restore on build will do exactly what you need. You can create nuget repository as shared folder.

Can WiX source refer to NuGet packages from another projects in solution?

I have a solution with two projects:
.NET application
WiX setup project.
I know, that it is possible to refer to project output in WiX source ($(var.WindowsFormsApplication1.TargetFileName)).
Now I've added a NuGet package reference to my .NET application. So, I want to bring NuGet package content into my setup.
Is there any way to do this instead of adding files manually?
I don't believe there is any linkage. I know what nuget is but I haven't used it much because it's more about brining your .NET dependencies into scope then software distribution. Depending on how nuget lays the files down you might be able to do something like $(var.SomeProject.TargetDir)nuget_fetched.dll.
This is assuming that SomeProject uses nuget in such a way that the references are copied locally and available in the Outdir of the project.
I wrote a Resharper live template to cut out a lot of the typing involved in adding the files, but essentially I've just added the files manually. Creating a Wix component per nuget package keep things neat.

specify dll locations in VS

I have about 15 projects in a solution, and all of them have some broken third-party dll references. How do I configure VS to look for dlls in one specific directory? I am trying to compile and link my project, but it doesn't work because projects have broken references to existing third-party dlls. My solution consists of C# class library projects and an ASP.NET web site.
If they are project references (and they probably should be), you should not need to (unles you have moved the projects)
Otherwise, create a third-party Lib folder (under source control) at the solution root folder, place your third-party DLLs in it and reference from there.
If you need to fix up references, download and install VSCommands 2010 which has a very useful copy and paste references feature (among others). [Fix up for one project, and then simply copy and paste to other projects. Failing that, you would need to manually edit the .proj files, using Powershell for instance.]
You go from one project to the other and update the references to point to the new location.
If this is a third party DLL, you can record a macro the first time you do this and replay it for each project.

Resources