Ever wanted to deploy multiple versions of an assembly to the GAC as part of a SharePoint 2010 solution package? Visual Studio 2010 makes it easy to GAC a single assembly version but will throw an error similar to the one below if you try to package a project with multiple versions of a dll, in this case AjaxControlToolkit.dll.
Both "Contoso.SharePoint" and "Contoso.SharePoint" contain a file that deploys to the same Package location: AjaxControlToolkit.dll.
The solution is simple and this post walks through it step-by-step.
We start with no AjaxControlToolkit.dll versions in the GAC.
Next, we are going to create a new SharePoint 2010 project in Visual Studio 2010 (or you can use an existing project).
Make sure that “Deploy as farm solution” option is selected.
Then double-click the Package.package in the Solution Explorer and click Advanced in the lower-left corner.
Press Add and select the “Add Existing Assembly…” option, browse to the location of one version of the assembly – in my case 3 different versions are stored in subfolders under the AjaxControlToolkit parent folder. Visual Studio automatically populates the Location field with the assembly name – go ahead an prefix the name with the version number followed by a backslash. Repeat for each version of the dll.
Now all versions of the assembly should appear in the Additional Assemblies grid in Visual Studio.
If we package the project and browse to the pkg folder, you’ll see that each version of the assembly is located in a separate subfolder.
Opening the manifest file also confirms that all assembly versions are included in the solution package.
Go ahead and deploy the solution package and, voilĂ , all of our assembly versions are now in the GAC!