Teamcity/c# build doesn't copy my DLL to the bin folder - c#

I have a C++ wrapper DLL added to one of my projects, the proect is my "Set as startup" project.
To do this I just right clicked on the project and did "Add exisitng item" and then in the properties I have
Build Action = None
Copy to Output Directory = Copy always
The code in this project does not directly use this dll, it's used in another project that's part of the solution and I cannot add it to the References as it's not a proper .NET dll.
My TeamCity build doesn't include this dll when it builds my project and I don't know why. I changed the build script so that it just copies the dll from a location to the bin folder but that doesn't work, when I run my app I get a run time error "could not find dll" even though I can actually see it in the bin folder.
So I cannot just copy it to the bin folder, I need to tell Team City to include that dll when the project is built, as it does when I compile it from Visual Studio
So my question is how can I tell Team City to include the dll when it complies my project?
I'm using VS2010, .NET 4

Related

Visual studio: Build action=Content causes error for dll file

I am trying to build a project in C# which uses some unmanaged dll files (MSVCRT.DLL, DFORRT.DLL, ...). There is no direct reference to the MSVCRT.DLL file in the project(this file is referenced by another dll and not directly by my program)
I want this dlls to be copied to bin directory. if i set build action to Content i get this error on run time:
The procedure entry point _wcstoui64 could not be located in dynamic link library msvcrt.dll.
Which is weird. I cant use other build actions because i want my dlls to be published too(Build action=None wont cause any error but doesn't let me to publish my dlls)
If i completely remove all references to all the dlls and treat them like data files, or pictures(files that are not used in code but should be copied to the output) again i get the same error.
What is causing the problem? how can i publish my dlls?

Visual Studio DLL References - Using Relative Paths And $(ConfigurationName) To Select The Corresponding DLL?

I have 2 separate Visual Studio C# solutions. One solution contains projects that generate DLL files (class library projects) and the other solution contains projects that depend on the DLL files from the other solution.
I have two questions about adding the DLL files from the first solution as references to each of the projects in the second solution.
When I add the DLL files as references (using the Browse option) is
there a way to use relative directories so that if I move the
solutions to a different folder I won't have to update the
references? (Assuming the two solutions are always in the same
location relative to one another.)
For example: ....\Solution1\Project1\bin\Debug\Project1.dll
If I change the DLL solution's configuration from Release to Debug I
want the other solution projects to reference the DLLs in the Debug
folder and vice versa. When adding the DLL files to each project can
I use something like the Visual Studio macro $(ConfigurationName) in
the DLL file path so that, depending on whether I build in Debug or
Release mode, I use the correct DLL file?
For example:
....\Solution1\Project1\bin\$(ConfigurationName)\Project1.dll
Thank you.

Output location of project

I was looking for the output of a project as a *.dll file to add it in References, but in bin folder there where Release and Debug folders.
Is there any difrence between the output.dlls?
Where is the useable output?
please explain the folders roles.
The folders correspond to your Solution Configurations, e.g. Debug or Release. You can specify custom configurations as well, and a folder would be created for it.
Instead of referencing the .DLL file directly by browsing to it, you should reference the project that defines the .DLL. If the project is not in your solution, you can add it by right-clicking on the solution title in the Solution Explorer and choose "Add" > "Existing project...".
This will allow Visual Studio to rebuild the .DLL in case you make changes, which you can now make without leaving your other project, and automatically reference the correct version, and also reference the configuration matching your project, i.e. if your project is run in Release, it will also use the release version of the .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"

Categories

Resources