I'm using Visual Studio's standard setup. During my solution build process, a DLL is modified and re-signed. I want the modified DLL to be copied to a setup that is also in the same solution so that it is installed on the target machine. The DLL should end up in the target machine's GAC.
Is there any way to do this in one build process? The DLL is modified each build.
To deploy an assembly to the target computer GAC with Web Setup project, we can drag the assemblies to Global Assembly Cache Folder(Right-click File System on Target Machine, click Add Special Folder, and then click Global Assembly Cache Folder). For more information, see http://support.microsoft.com/kb/324168
We also can try to run some scripts to register assemblies through the Gacutil Tool (http://support.microsoft.com/kb/315682) on target machine in Custom Action of Setup Project.
For the Custom Action example, see http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx
Make the install do two components using the same file.
One as a global assembly, and one as a private assembly.
These links should be helpful:
http://blogs.msdn.com/b/astebner/archive/2005/06/24/432521.aspx
And
http://msitekkie.wordpress.com/2011/02/03/installing-net-assemblies/
Hope that helps
Related
I have a legacy project in Visual Studio 2003 that was made in the past by other developers.
This project has some references added. One of them, let's say myDLL.dll. It has the properties below in VS:
Copy Local = True
Runtime Version v1.1.4322
Strong Name: True
Type: Assembly
Version: 2.1.1.30200
I build the solution and copy it in the target path in production machine.
In the target I have ensured that myDLL.dll is the same version as in the VS solution, that is, 2.1.1.30200.
When I executed the new version of the app in production machine below error is shown in my app logs:
The located assembly's manifest definition with name 'myDLL' does not
match the assembly reference.
I guess that in GAC is loaded/installed a previous version of this DLL so hence the above exception.
So, I wonder if GAC is automatically cleaned from time to time (on a regular basis) or do I need to remove manually the old DLL and install the new one?
If I need to remove the old one and install the new one in the production machine, how can I do it?
Additionally, if I go to C:\Windows\assembly in production machine I can find the DLL myDLL but the version indicated is 2.1.0.0 instead of 2.1.x.x. Why? Shouldn't it be 2.1.1.30200 (for the new one) or 2.1.1.20100 (for the old one)?
I have read a lot of posts here, like below ones:
DLL version mismatch
Working with GAC
Installing DLL in GAC
Viewing DLL in GAC
Removing DLL from GAC
What is GAC?
Other interesting links that I have found:
.NET 4 gacutil on production server
Automatically GAC an assembly after a build and include debug
info.
but I am very newbie in GAC.
Have you tried to put the myDLL.dll into the same directory where your output program is located? For web projects it is "bin" directory, for EXE just keep them together in the same folder. So it will be loaded from application directory, not from the GAC.
I would like to have a smooth and efficient installation of the solution, but what I "inherited" is very far from that, and the guy who programmed most of it has left the company.
At present I am trying to install it on a test-server, and not all the dll's land in the correct places after the installation.
Firstly, if I use log4net in a project, then I need the log4net.dll in the folder after the installation (I guess). How do I get the log4net.dll to be copied with the project dll?
Secondly, Project A expects Project C's dll to be in the GAC or so it seems when I debug in Visual Studio and check where the modules are loaded from.
I also see that this is entered in the post build event commandline of Project A:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\GacUtil.exe" -i "$(TargetPath)"
copy "$(TargetPath)" "C:\Program Files\MySolution\bin"
So how do I get Project C's dll into the GAC by way of the installation? I get an error on the Test Server because it can't load C.dll.
UPDATE WITH MORE DETAIL
After the solution has been installed with Windows Installer, a few folders are created in the parent folder such as Apps, bin, Engines, Service etc.
In the Apps folder, I have A.exe, which is looking for C.dll. However, C.dll lands up in the bin folder. As mentioned above, during execution of A.exe, it actually loads the modules of C.dll from the GAC (and on my laptop, those files are in the GAC because of the post-build event command line specified in the properties of Project C, but not in the GAC of the Test Server to which I am trying to install this solution).
So yes, I assume I could run something like this:
gacutil -i C.dll
after the installation, but it doesn't seem right.
There are two parts to your question relating to the GAC, and ensuring DLLs are copied.
GAC
Check out this link (https://msdn.microsoft.com/en-us/library/dkkx7f79%28v=vs.110%29.aspx) from MSDN on how to install into the GAC. The key thing is it must be strongly named or it will fail.
DDLs
Depending on how you are referencing Log4Net, there are a few ways to do this.
If you can add a reference in your project, make sure the property CopyLocal is set to true
If you just have the file locally, you can add it to a sub folder of your project with a symbolic link (https://support.microsoft.com/en-us/kb/306234), and then set the CopyToOutputDirectory property.
Hopefully these help you along.
I found what I was looking for!
Select the Setup project, then go to the menu "View" -> Editor -> File System.
It seems you can specify where the dlls must go, and what should be copied to the GAC during installation.
Say I have a Visual Studio Project that references a libary XYZ.dll. I am not able to distribute that dll but I know that many people have a license for it.
What can I do to connect my project to XYZ.dll on the target computer? To be more precise, I want to do the following things:
Reference XYZ.dll in a project in Visual Studio.
Distribute a compiled version of the solution/project without XYZ.dll
Let the customer, who installs my program, link the program to his copy of XYZ.dll so that the program can use it.
(This may be an easy question, but I was not able to find the answer, maybe due to wrong search terms).
If the XYZ.dll is installed with a third-party product, you may check whether it is registered in GAC.
If so, then you - in your VS project - reference the XYZ.dll pointing to it in GAC and then setting the copy local to false, so that it will not be copied to your program's bin directory and used from there.
It becomes more problematic in case the dll is not in GAC - in such case you would need to ask user for the assebly's location (or read it from registry if you know what product to search for) and then resolve this assembly dynamiccaly using that path with the use of AssemblyResolve event (https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve%28v=vs.110%29.aspx)
There is also a way in which you create a "proxy" class in your project that loads the third-party assembly dynamiccaly from the path on the customer's computer, and then create a set of proxy methods that would call loaded third -party assembly using reflection.
I dont have gacutil on the computer I have to install this assembly so can it be done instead of using gacutil?
If yes, whats the difference?
Its a .net 2.0 assembly
You can drag and drop assemblies onto the \Windows\Assembly folder in Explorer, and the assemblies will be deployed there automatically. There is no difference between the result of this method and using gacutil.
To verify before the act, a shell extension must have been installed with the .NET Framework that displays a different view of this folder when you navigate there, so you should actually see assemblies with version data etc. instead of the standard columns (in detail view).
If you dont want to use gacutil then you should create your own utility and use install the assembly by using Publish.GacInstall Method.
public void GacInstall(string AssemblyPath)
Drage and drop dll ... it might not work if gacutil isn't there as a special Windows Explorer plugin calls gacutil to install your assembly into GAC. For details please have a look on GAC - To add an assembly to the GAC, drag and drop works, but copy and paste doesn't? Why?
There is a project in c# which references few dlls that are present in the parent directory of solution. When I try to build using MSBuild in TeamCity, it fails because it cannot find the dlls. I tried providing the dlls as fixed path using Artifacts but no luck!
Could somebody please tell me if there is a way to add the reference of the dll present in parent directory in TeamCity?
Thanks.
Generally speaking MSBuild doesn't have any idea of what a solution is. MSBuild considers each project an independent entity and the files under the project folder are in its 'cone'. You are better off by staging the dlls in the project folder as a pre-build step of the project.
You should try to build your solution with MSBuild but without TeamCity. If it works check whether your dlls are being checked out during the build.
Teamcity does nothing else than invoking msbuild.exe.