NotEqu's Blog

March 2008 - Posts

Multiple Startup Projects

  One of the cool new features of Visual Studio 2008 is the ability to have multiple startup projects. To enable that feature right click on the solution and select "Set Startup Projects..." option.

Pic1

  Select "Multiple startup projects:" radio button and change the Action to start next to the projects you want to start.

Pic2

  Next, start your projects and enjoy :-)

Posted: Mar 31 2008, 09:25 AM by NotEqu | with 3 comment(s) |
Filed under:
PowerCommands for Visual Studio 2008

PowerCommands   Few weeks ago Microsoft released a set of useful extensions for the Visual Studio 2008. Here is a list of functions from version 1.0:

  • Collapse Project - collapses a hierarchy in the solution explorer starting from the root selected node. It can be executed from three different places: solution, folders and project nodes respectively
  • Copy Class - copies a selected class entire content to the clipboard. It can be executed from a single project item or a project item with dependent sub items
  • Paste Class - pastes a class entire content from the clipboard. It can be executed from a project or folder node
  • Copy References - copies a ferefence or set of references to the clipboard. It can be executed from the references node, a single reference node of set of reference nodes
  • Paste References - pastes a reference or set of references from the clipboard. It can be executed from different places depending on the type of project. For C# projects it can be executed from references node. For VB and Website projects it can be executed from the project node
  • Copy As Project Reference - copies a project as a project reference to the clipboard. It can be executed from a project node
  • Edit Project File - opens the MSBuild project file for a selected project inside Visual Studio. It can be executed from a project node
  • Open Containing Folder - opens a Windows Explorer window pointing to the physical path of a selected item. It can be executed from a project item node
  • Open Command Prompt - opens a Visual Studio command prompt pointing to the physical path of a selected item. It can be executed from four different places: solution, project, folder and project item nodes respectively
  • Unload Projects - unloads all projects in a solution. It can be executed from the solution node
  • Reload Projects - reloads all unloaded projects in a solution. It can be executed from the solution node
  • Remove and Sort Usings - removes and sort using statements for all classes given a project. It can be executed from a solution node or a single project node.
    Note: The Remove and Sort Usings feature is only available for C# projects since the C# editor implements this feature as a command in the C# editor (which this command calls for each .cs file in the project). The Visual Basic IDE implements this functionality for Imports in an interactive way: Project properties, go to the References tab, then click the Unused References... button, then select which references you want removed via a listbox

You can (must) download the PowerCommands for Visual Studio 2008 from:

http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=PowerCommands&ReleaseId=559

Posted: Mar 17 2008, 02:26 PM by NotEqu | with no comments |
Filed under:
Kid’s Corner

babycomputer   Ko od vas ima decu? Ko od vas želi da mu deca budu geekovi kao vi? Ako želite da naučite klince kako se pravi softver posetite dečji ugao na MSDN-u   :-)

http://msdn2.microsoft.com/en-us/beginner/bb308754.aspx

  Na ovom mestu možete besplatno preuzeti elektronske knjige sa primerima za C#, VB, HTML, ASP .NET, Web dizajn koje su prilagođene mlađim uzrastima.

Posted: Mar 17 2008, 11:02 AM by NotEqu | with 1 comment(s)
Filed under: ,
Installer class

  If you want to build your own setup project for any kind of application, it is good to know something about installer classes. I will make a little example to show you how to pass the value from custom setup dialogs to installer class.

  First you add installer class into your project or you can make new project just for installer classes inside your solution. I made widows form application and added installer1.cs into my application.

Slika1

Next, open design window for installer1.cs and in properties window on Events tab choose event you would like to override. In this case let's choose AfterInstall event.

Slika2

  You will see empty method that look's like this:

private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
}

  Add setup project to your solution. Because my installer class is in windows form project, all I have to do is open File System of my setup project and add primary output to Application Folder. Then open User Interface and add dialog you need. I added RadioButtons (3 buttons) and Textboxes (A) for my example. You can change order of dialogs just by dragging them up and down. This will be the order they will show during the installation.

Slika3

  Open properties window for RadioButtons dialog and enter text and values for radio buttons now:

Slika4

  Open properties window for Textboxes dialog. This dialog consists four text boxes and because I only need two, I will set visible property to true for the first two text boxes and false for the rest of them:

Slika5 

  Then open Custom Actions and add custom action you need. For this example we only need action OnInstall. Right click on Install folder and choose Add Custom Action. Then choose Application folder and select the primary output. You can rename it if you wish. I call it OnInstall.

Slika6

  Now we need to pass the values from custom dialogs to installer class. From the previous pictures you can see that RadioButtons dialog has property called ButtonProperty witch value is BUTTON3. BUTTTON3 represents the value we chosen with radio buttons. Open properties window for OnInstall action and for CustomActionData enter:

/TEST=[BUTTON3] /FNAME=[EDITA1] /LNAME=[EDITA2]

  We sad that BUTTON3 is the value of radio button we chose. EDITA1 and EDITA2 represents the value for text boxes. We have three parameters (TEST, FNAME and LNAME) which will we use to get to this values from installer class.

Slika7

  In Installer1_AfterInstall method we will now enter some code to do something with values from setup project:

private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
    string myPassedValue = this.Context.Parameters["TEST"];
    string fName = this.Context.Parameters["FNAME"];
    string lName = this.Context.Parameters["LNAME"];
    StreamWriter writer = new StreamWriter("C:\\Install.log", true);
    writer.WriteLine("Install log file");
    writer.WriteLine(DateTime.Now.ToShortDateString() + "  " + DateTime.Now.ToShortTimeString());
    writer.WriteLine("Install path is " + path);
    string s = "";
    switch (myPassedValue)
    {
        case "1":
            s = "develop";
            break;
        case "2":
            s = "test";
            break;
        case "3":
            s = "product";
            break;
    }
    writer.WriteLine("You selected " + s);
    writer.WriteLine("First name: " + fName);
    writer.WriteLine("Last name: " + lName);
    writer.Flush();
    writer.Close();
}

  You can see that we used TEST, FNAME and LNAME parameters to get values from setup dialogs. All that this method will do is to put this values into install.log file. I hope you will find something more useful to do with installer classes then I in this example. Good luck!