How to include DLLs to published application? - c#

In my solution I reference DLLs file from Libs folder. When I publishe application they don't copy to published folder. Is there anyway to make them to be copied too?

You should put your DLLs in the Bin folder.
The publisher will copy that folder.

In addition to Slaks I would say, in order to have DLL in bin or
Set CopyLocal property if linked reference to True.
Or
Use postbuild event to achieve the same.

Related

VS2013: never put bin directory in source control, but it caused build fail

I'm new in Visual Studio 2013 (C#). I know in general it should be avoid putting bin directory in source control. However, in my bin directory, there are lots of dll files. Without this dlls, I can't build my project.
I thought maybe I should create a directory, such as 'lib' to store the dlls. But the fact is NuGet always put dll into the bin directory. Should I manually move the dll from bin to lib?
All I want is to simply put all source codes, resource files and dll files to source control (git). Then my team-mates can pull the project then build it in their machine.
edit on 1/4/2015: provide further details
For example, I installed log4net thru NuGet. After finished, I found 3 new files existed in bin directory:
log4net.dll
log4net.xml
log4net.dll.refresh
I tried to remove bin directory from my project, then rebuild my project, and hope to see that a new bin directory would be built and all dll/pdb/etc files would come back. But unfortunately it didn't happen.
In my understanding, the ideal process would be:
add reference/install package, then certain config info would be recorded and according files would be installed to bin directory;
when build, according lib files would be referenced from bin, if such files not found, VS would get the reference info from some place other than bin and download them again. So that's one of the reasons why we don't need to put bin into source control.
However, I found that's not true in my project.
Actually according to the official .gitignore, I found bin directory as build results is filtered ([Bb]in/). That is to say, even VS knows such directory should be ignored.
Maybe some wrong setting within my project?

adding a references folder to a project VS2012

I have two dll files which should be always in the bin/debug folder at runtime, I can add one of them as a reference, but the other one gives an error about that it is not being accessible, but whenever I added to the bin/debug file manually it works fine.
What I want to do now is I created a Lib folder which contains the two dll files, but I want to the whole folder as a reference so whenever the project runs the folder is directly linked.
Any suggestions?
Although you can't reference a directory, you can reference a project - I suspect this is what you want. That should also resolve itself as you update the binaries.
If you just want to have another file being copied to the bin folder of your project, add the file to your project, go to properties set Copy to Output Directory to Copy Always
Have you tried setting "Copy local" for this dlls to true?
I think what you want to do is add the the two dlls to your solution as content, and then set both to copy to output directory set to true. You can do this by looking at the properties of the included dll.

Placing dlls in bin directory after successfull build

I was working on a project , I needed to add a folder inside my application which consists some usefull dlls
under properties of my dll , I have changed the Copy to output directory field to copy always
On successfull build of my project I am getting the bin folder as :
After building the project I found out that my dll is placed inside DLL folder
but I do not want such folder , I want it to be inside the bin folder only , how can I achieve that.
simply delete the dll folder in both vs and the windows folder, then add them as references for your project and set there properties to copy always
you still may copy them manually the first time to make sure everything is going just fine
IF the project has a reference to the DLL already VS will copy the dll to the bin folder.

how to set the folder of destination when I use local copy?

I have a project in Visual Studio 2010 and in this project I have a "lib" foleder in which I have the external dll that I need. In this case, the libraries of SQLite.
Well, I can set hte reference to the principal dlls, SQLite.dll and SQLite.Linq.dll. In this case, the dll are copy in the main folder of the application.
However, I need also the SQLiteinterop.dll. I have tried to add a reference to this dll, but I get the error that it is not a valid COM component. So the way that I find to copy the dll is marked as local copy in the properties of the dll that is in the "lib" folder.
However, this copies the dll in a subfolder "lib" in the main application folder and I need to copy in the main folder.
Is there any way to set in visual studio where to copy each dll?
Thanks.
I would suggest using a Build Event, retrievable in the Properties of the Project.
Here you can make a Post-build event which copies the file to the Build folder.
Something like:
copy /Y "$(SolutionDir)lib\$(ProjectName)\sqllitefile.dll" "$(TargetDir)\$(ProjectName)\sqllitefile.dll"

Nuget dlls are in /packages folder, when promoting to production should we change to /bin?

It seems nuget packages get stored in our applications /packages folder.
I got confused as I couldn't see the dll's in /bin (which is the folder we use to promote to production).
Should I just change the path in the references to /bin and copy local = true?
Just want to confirm as I'm confused why it went to /packages.
No. If you are using bin as your output directory for the build, you shouldn't reference anything from it. You should have a separate location where you can reference your DLLs. When a project builds, it will copy all of its necessary DLLs/EXEs to the /bin folder. When you do a clean, those assemblies get deleted.
Using /bin also could cause issues with your build modes (Debug/Release), how can you be sure you're referencing the right ones when they get all mixed up.
That separate location seems like it might be your /packages directory, although more information would be needed to be sure.
When I have to do this, I create a 'lib' folder on the project root, put 3rd party or pre-built assemblies there, and reference them from there. Copy local=true will copy them to the /bin folder where I run (or copy) the program from. If I'm working on a suite of programs, 'lib' would be some shared location all my programs can pull from.
Yes, setting copy local to "true" would be the right way to go with it.
If you dont want the package to be extracted at the ..\Packages folder and want it in a centralized location - say at the root of you source control or common lib folder, you can add the respository path in the nuget.config file. More details here # http://docs.nuget.org/docs/release-notes/nuget-2.1#Specify_%e2%80%98packages%e2%80%99_Folder_Location

Categories

Resources