• How To: Create wsp package for user controls

    by  • March 5, 2010 • MOSS 2007 • 0 Comments

    We can copy our user controls to the layouts or control templates folder manually. But moving user controls from development to production manually is very risky or not recommended. Here is how you can deploy these changes programmatically.

    1. Create a  web part project or wsp builder project and create a folder.

    2. Add all the required user controls (both .ascx and .cs files) to the above folder.

    3. Add manifest.xml, makecab.exe and wspstructure.ddf to it.

    4. Make the following changes to manifest.xml file

    <?xml version="1.0" encoding="utf-8"?>
    
    <solution xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
    <!—Add what all are the files you want to deploy as user control, mention path correctly</span><span style="color: #339966;">
    
    Here  I want to deploy StockChart.ascx, StockChart.ascx.cs in ABC folder in the layouts folder -->
    
    <rootFile Location ="TEMPLATE\LAYOUTS\ABC\StockChart.ascx"/>
    
    <rootFile Location ="TEMPLATE\LAYOUTS\ABC\StockChart.ascx.cs"/>    </rootFiles>
    
    </solution>
    

     

    5. Make the following changes to wspstructure.ddf

    
    .OPTION EXPLICIT     ; Generate errors
    
    .Set CabinetNameTemplate="Release-03-Mar-2010.wsp"
    
    .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
    
    .Set CompressionType=MSZIP;** All files are compressed in cabinet files
    
    .Set UniqueFiles="ON"
    
    .Set DiskDirectory1="Release"
    
    ;CAB MANIFEST
    
    .Set Cabinet=on
    
    manifest.xml
    
    ;ASSEMBLY
    
    ;FEATURE MANIFEST
    
    .Set DestinationDir=TEMPLATE\LAYOUTS\ABC
    
    StockChart.ascx
    
    .Set DestinationDir=TEMPLATE\LAYOUTS\ABC
    
    StockChart.ascx.cs
    

    6. Save the ddf file and the project.

    7. Goto command prompt and Navigate to the directory of the solution using CD command.

    8. Create the wsp using Makecab /f  nameofddffile.ddf

    Note: If you want to verify whether the files are packed successfully, you can rename the wsp file to .cab file. you can then opne the file using Winzip.

    About

    Radhika Sajin was working in US Technology in Trivandrum, India. She has 7.5 years experience in working with Web Development Technologies inlcuding MOSS, SharePoint 2010 and ASP.net.

    Leave a Reply

    Your email address will not be published. Required fields are marked *