Copy DLLs dependancy files to Main project - visual-studio

I have a visual studio solution (microsoft visual studio professional 2017) with a main project, that uses classes from a DLL project in the same solution.
The DLL is a "class Library (.NET framework).
Main project is (for my preliminary investigations) a console app. Future versions will be a WPF. I think that the problem appears on all applications that use DLLs that use other DLLs.
The DLL uses other DLLs from a Nuget package. In this case: SQLite. I want to hide to my main project that my DLL uses Sqlite. That makes it possible to change it in future versions to a different database, or maybe use entity framework to access the data.
So my main project only knows that it uses the DLL in the same solution. It does not know that this DLL uses other DLLs.
Problem: These other DLLS are not copied to my main application folder.
This has been asked before: Copying a DLL's dependencies in Visual Studio
The answer says that you should use classes from the Sqlite to make sure the DLLs are copied. That is just what I wanted to prevent: users of my DLL should not have to know that this DLL uses SQLite
That question is 11 years old.
I wonder if Visual Studio has now a better solution for this.

A method to solve the problem was given in Install and manage packages in Visual Studio using the NuGet Package Manager. It is not ideal, the main project still needs to know that the other projects use certain Nuget packages, but at least you don't have to edit the .csproj files, nor type command lines
MySolution
MyMainProject. Refers to MyDll
MyDll. Uses Nuget packages
In Visual Studio. Menu - Tools - Nuget Package Manager
The window that opens shows the installed Nuget packages. If you click on them, you can see on the right the projects that use these packages.
For all installed packages that your main program complains that it is missing at run time, check the box near MyMainProject. At the bottom click Install.
Alas, I'd rather have something in project MyDll that tells everyone who uses this DLL that they also need these Nuget packages. But for the time being I'll use this method.
Will check again in 11 years if there is any improvement.

Related

Correct way to set up .net5 library projects with project dependencies in dev, but separate nuget packages when published

Suppose I am building two class libraries in a single solution in visual stuido. The projects are called "Core" and "Extensions".
Extensions depends upon Core.
I would like to publish these as separate nuget packages for other developers to consume, because while the Core package would always be used, the extensions package just provides some optional functionality.
When I am developing the solution in visual studio, however, it is much simpler for me to set a project dependency from Extension to Core. Otherwise (in a naive approach), building the whole solution would require the following steps:
In visual studio, commit and push Core.
Wait for the CI server to build Core and publish the nuget package to our internal feed.
In visual studio, manage nuget packages for the Extensions project.
Connect to the internal nuget feed
Get the updated Core nuget package.
This approach would work, but is obviously very tedious.
The main difficulty I have been encountering while researching how to do this is that the way all of these things interact has been changing quite rapidly over the past few years, with sdk vs non sdk style projects, nuget pack vs dotnet pack vs msbuild pack, and so on and so forth.
Perhaps the most relevant, most recent answer appears in this question How do I create an individual nuget package for each project in a solution, with project references converted to nuget dependencies? however the answer is now quite old, and is for a dot net framework style project (using packages.config), not a .net5 project.
So, can anyone provide up to date advice on how to correctly accomplish the following:
In a visual studio solution with multiple .net5 class library projects, have dependencies set up as project dependencies at dev-time, but convert each project to its own nuget package with the equivalent package dependencies at publish time.

Add references Visual Studio 2010 (NuGet)

I am trying to use some references in Visual Studio, I have installed NuGet to use some libraries.
Is there a way to use only part of the package installed with NuGet? For example, if I am using TeklaOpenApi and the following .dll files are installed with this package:
TeklaModel
TeklaDialog
TeklaDrawing
Use for example just TeklaModel, could I do this using NuGet?
Is there a way to use only part of the package installed with NuGet?
I am afraid that you cannot get what you want. It is designed by nuget package. Usually, when the nuget package contains other dlls which means they are probably depended on a master DLL, or used at runtime.
All of them play an important role in this nuget, so we cannot easily remove them.
Although we can use Assembly Reference format(Right-click on References-->Add Reference--> choose one Dll) to reference the specific dll, but there is a risk that if the DLL depends on other corresponding DLL, an error will be reported. So we don't recommend it.
The best way is to install the whole nuget package with all the related dlls.
Hope it could help you.

Is there a better method than Solution Folders for referenced DLLs in TFS?

We've just switched from SVN to TFS 2013, and I'm trying to set up a new gated build.
The project I'm currently working on has a couple of "referenced assemblies": DLL's it's dependent on which are fixed in place and don't have a nuget reference. As soon as I tried to compile my new build, it failed complaining it couldn't find these DLLs.
I assumed the answer was to include them in the solution somewhere. Which is fine, except that using solution folders appears to be a flaky, error-prone and rather rubbish way to fix things, as per Storing referenced Dlls in visual studio solution folder
However, that dates from 2011. Are there any better and more reliable ways of achieving this?
Don't discount the nuget option so quickly :) If there is no publicly available nuget package available you can wrap your assemblies in your own nuget package using the nuget package explorer:
https://npe.codeplex.com
Does the fact that you mention nuget mean you're already using nuget for other references? If so mdkes sensd to stick with it. Also are these reference assemblies third party or built internally?

Installing assemblies to special folders like VS PrivateAssemblies in NuGet package

We are going to publish one of our commercial components, a .NET grid control, as a NuGet package. The product is separated into 2 DLLs - one is the core functionality, and the other is the design-time support assembly. The core assembly can be redistributed as a "normal" DLL and can be placed into any location. But to make the whole product work properly in VS IDE, the design-time part should be installed into a special folder like the Visual Studio PrivateAssemblies folder or into any folder with a special registry key that points to it. Do NuGet packages allow us to do this?
You need to use Chocolatey packages for a run-time dependency like this. NuGet packages are [designed for] for build-time dependencies only.
See http://chocolatey.org/ - Chocolatey uses NuGet under the hood, but has a different focus. You'd probably use NuGet for the "anywhere" DLLs, and a separate Chocolatey package for the VS designer support.

.dll reference, SSIS packages and class library project

I have a visual Studion solution in which different SSIS packages are included along with class library project for custom component. The class library project has post build event which copies the .dll file into GAC and into PipelineComponent(C:\Program Files (x86)\Microsoft SQL Server\110\DTS\PipelineComponents). Now, when i open the visual studio solution and try to build class library project second time, it gives me an error possibly because the .dll file is already locked by visual studio which is used by other SSIS packages.
Now, how can i tell visual studio to not lock the .dll file? I tried to unload the SSIS packages, but it didn't work.
Please note that i want my class library project and SSIS packages in one solution.
You have a solution. Your solution contains 2 projects: one is a .NET class library project while the other is an SSIS project.
The problem you are running into is that you cannot overwrite the dll in the Pipeline Components folder as it is in use by the SSIS project. I ran into the same issue when I was developing custom components. I can't remember if it's the SSIS Toolbox that puts the lock on the file or a package actually using the component that locks it. I also don't recall what my final resolution was but I tried a variety of things.
My resolution
Exclude the SSIS project from your solution. You can either do this permanently by removing it from the solution or temporarily by unloading the project during your build phase. Ultimately, I went this route and created a separate solution with the SSIS project in it. This allowed me to unload the project in the other VS instance whenever I needed to redeploy the DLL. It also empowered me to put breakpoints in the SSIS project which allowed me to attach the VS debugger of the .NET and then debug into my custom component. Maybe they've fixed that since the 2005 days but at that point, you were stuck using 2 instances of VS to debug into your package.

Resources