Your official information source from the .NET Web Development and Tools group at Microsoft.
If we want to package and deploy .NET assemblies for a web application only, we can simply reference them and change their “Copy Local” property to “True”.
For example, we can do the following to package a MVC project from VS2010.
You can multi-select them and set the value together.
Deploy the above package to a 4.0 site, no matter if the corresponding MVC runtime is installed on the server, your application will simply work fine.
If we want to package and deploy GACed dll, we need to use gacAssembly web deploy provider and extend our project similarly to the one stated in the how to package registry blog. The extended projectName.wpp.targets file looks like following:
<!--********************************************************************--> <!-- Task CollectGacAssemblyForPackage –> <!-- GacAssembly reference: http://technet.microsoft.com/en-us/library/dd569056(WS.10).aspx --> <!--********************************************************************--> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <!--Targets get execute before this Target--> <OnBeforeCollectGacAssemblyForPackage Condition="'$(OnBeforeCollectGacAssemblyForPackage)'==''"> </OnBeforeCollectGacAssemblyForPackage> <!--Targets get execute after this Target--> <OnAfterCollectGacAssemblyForPackage Condition="'$(OnAfterCollectGacAssemblyForPackage)'==''"> </OnAfterCollectGacAssemblyForPackage> <CollectGacAssemblyForPackageDependsOn Condition="'$(CollectGacAssemblyForPackageDependsOn)'==''"> $(OnBeforeCollectGacAssemblyForPackage); Build; </CollectGacAssemblyForPackageDependsOn> </PropertyGroup> <PropertyGroup> <IncludeGacAssemblyForMyProject Condition="'$(IncludeGacAssemblyForMyProject)'==''">False</IncludeGacAssemblyForMyProject> <MyGacAssemblies Condition="'$(MyGacAssemblies)'==''"></MyGacAssemblies> <AfterAddContentPathToSourceManifest Condition="'$(AfterAddContentPathToSourceManifest)'==''"> $(AfterAddContentPathToSourceManifest); CollectGacAssemblyForPackage; </AfterAddContentPathToSourceManifest> </PropertyGroup> <ItemGroup> <MyGacAssembly Include = "$(MyGacAssemblies)"/> </ItemGroup> <Target Name="CollectGacAssemblyForPackage" DependsOnTargets="$(CollectGacAssemblyForPackageDependsOn)" Condition="$(IncludeGacAssemblyForMyProject) AND '$(MyGacAssemblies)'!=''"> <Message Text="Adding %(MyGacAssembly.Identity)" /> <ItemGroup> <MsDeploySourceManifest Include="gacAssembly" Condition="$(IncludeGacAssemblyForMyProject)"> <Path>%(MyGacAssembly.Identity)</Path> </MsDeploySourceManifest> </ItemGroup> <CallTarget Targets="$(OnAfterCollectGacAssemblyForPackage)" RunEachTargetSeparately="false" /> </Target> </Project>
Then you can use the following command line to package the project with corresponding Mvc GACs and 4.0 version of System.Web.Routing and System.Web.Abstractions.
msbuild WebApplication2.csproj /target:package /p:IncludeGacAssemblyForMyProject=True;MyGacAssemblies="System.Web.Mvc;System.Web.Routing,Version=4.0.0.0;System.Web.Abstractions,Version=4.0.0.0"
Note, gacAssembly web deploy provider has some limitation as described in the link.
Xinyang Qiu | Visual Web Developer
This is very useful information and i salute you. youre expert.
Hi its very nice article. But will that be problematic with GAC dll's ?
Thanks,
Thani
GAC dlls affects system wide, and I would avoid it if possible. But in some automated test lab, using this way to GAC dlls for your web application might be a userful option.
The title of this post is misleading. None of the assemblies you're deploying are COM components; they're .NET assemblies.
Thanks, Richard, I just realized the error. Title is changed to reflect the fact. Thanks again.
There is another minor mistake in the post, look at the picture, it selected these following dlls
System.Web.Mvc
System.Web.Routing
System.Web.Services
In fact in the post's writing it asks for these dlls
System.Web.Abstractions
Ray, Thanks, I've corrected the picture