Saturday, November 24, 2007

Create un-install setup shortcut and project

In order to create professional setup project using .Net setup and deployment projects, the you have to create your own way for un-installing the products using shortcut from start menu.

And you can accomplish that by:
1- creating a new project (console application) to your solution.
2- In program.cs class place the following code:
//**** Begin here
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace UninstallMyProject
{
///
/// Used to handle project custom uninstall from start menu or target directory
///

class Program
{
static void Main(string[] args)
{
string[] arguments = Environment.GetCommandLineArgs();

Process proc = new Process();
string path = Environment.GetFolderPath(Environment.SpecialFolder.System);

// Default product code must be changed if the product changed in setup project
string productCode = "{BBA4SSBD2-20B5-410C-8F23-C23E18806C7B}";

// if no arguments send then the uninstall called from exe itself ,, and
// for this we cant send the product code so assume the default one

if (arguments.Length == 1)
{
proc.StartInfo.FileName = string.Concat(path, "\\msiexec.exe");
proc.StartInfo.Arguments = string.Concat(" /i ", productCode);
proc.Start();
}
else
{
foreach (string argument in arguments)
{
string[] parameters = argument.Split('=');
if (parameters[0].ToLower() == "/u")
{
productCode = parameters[1];

proc.StartInfo.FileName = string.Concat(path, "\\msiexec.exe");
proc.StartInfo.Arguments = string.Concat(" /i ", productCode);
proc.Start();
}
}
}







}
}
}

//** Ends Here


3- Then you can just create Shortcut on your setup project, that point to this exe with the required product code as parameter. parameter in the shortcuts placed in argument property as: /u=[ProductCode]

Hope this information will be helpful, and if any help needed, just leave your comments.

Cheers,
Nasser

Friday, August 24, 2007

SharePoint Custom Web Parts

What is Web Part?

ASP.NET Web Parts controls are an integrated set of controls for creating Web sites that enable end users to modify the content, appearance, and behavior of Web pages directly in a browser. The topics in this section provide information on what Web Parts are, how they work, and how to use them to create user-customizable ASP.NET Web pages.

How to create custom VS 2005 web parts, Using Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions:

This is a new addons to VS 2005 IDE that will enable developers create web parts, by downloading this setup from here.

After installation, open VS 2005 IDE, click on New Project at File Menu, then go Share Point node at the left menu, then here you go, you got new project types, for example Web Parts, see below:



After that, select web part, then the projects open, and you can place any Html contents you wanted on following line sub that will appear:

protected override void Render(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
writer.write("Hello World web part.");
}

Then by Just clicking on "F5" & Run the VS will compile & deploy it at SharePoint, and by adding new web parts from the Share Point, you will notice that your web part will be available on the web parts galley !

Cheers,