Monday, February 05, 2007 5:46 AM
Chris
Deploying Strongly Named Assemblies to the GAC from Visual Studio
In my last post, I listed the steps necessary to create a strong name key and to sign assemblies. I even discussed a feature of Visual Studio that permits you to share a single file across multiple projects. We shared a strong named key across three projects.
In this post I will discuss creating a setup project and deploying the strongly named assemblies to the GAC.
Creating a Setup Project
- Right-click on the solution in the Solution Explorer and select Add/New Project
- From Project Types, expand Other Project Types and select Setup and Deployment
- Select Setup Project from Templates
- Name the setup project appropriately and select OK.
- Since we are deploying our projects to the GAC, we must create a special folder. On the left tree, right-click File System on Target Machine, select Add Special Folder, then select Global Assembly Cache Folder
- Right click on the Global Assembly Cache Folder and select Add, then select Project Output…
- Select Primary Output
- Select OK
- Repeat steps 6-8 for each project in your solution that you wish to deploy to the GAC
- After completing these steps, you should notice that there are several additional assemblies that have been added to the setup project. These assemblies are dependent assemblies. Assemblies on which your assemblies depend.
- Some of these assemblies may already be in the GAC. In my example, there are several assemblies from WCF on which my projects depend.
- Build the setup project by right clicking the seup project and selecting Build
- If, like my projects, the setup wizard added dependent files that are already in the GAC, building the setup project will yield some warnings.

The warnings are telling us some files should be excluded since they are already in the GAC.
- To exclude the files on which we are receiving warnings, in the solution explorer right click on any dependent assembly that we wish to exclude. In my case I selected several files.
- Excluding the files from the setup project means that the files will not be deployed when setup is run.
Now that you've created the setup project, you can run it to install the assemblies into the Global Assembly Cache.