Philippsen's Blog

Everyday findings in my world of .net and related stuff

Archive for June, 2011

Manually compile C# project using command line

Posted by Torben M. Philippsen on June 20, 2011

For various reasons I sometimes have to build projects outside my Visual Studio environment. One approach is to use the sommand line tool csc.exe (for c# projects) or vbc.exe (for vb.net projects). It can be quite exhausting to build the command – especially if your are using external libraries, ressources, settings and other quite common stuff. It would be nice if one could just fetch the command that Visual Studio uses to compile the project – well you can:-)

If you want to have a look at the command that Visual studio uses to compile you project, all you need to do is to launch a command similar to this in a visual studio command prompt:

E:\VSS\Grene\AxXMLService\AxXMLService>msbuild AxXMLService.csproj /t:rebuild /clp:showcommandline >> log.txt

This command will produce a log file containing the output – this will look something like this:

csc command output

csc command output

Please note the highlighted section – here you will find the command you need to build your project outside visual studio. the only requirement is ofcouse that the relevant framework version is installed on the machine performing the build.

Advertisements

Posted in Tools, Visual Studio | Tagged: , , , | Comments Off on Manually compile C# project using command line

Reading extended properties using EWS managed API

Posted by Torben M. Philippsen on June 20, 2011

Having been working with Exchange 2007 Web Services (EWS) for a couple af years a recent bug led me to testing various scenarios regarding appointment items using the EWS Managed API instead of the proxy classes that I have grown used to working with.

One of my struggles was to read the extended properties that we use. Having gotten it all to work I though that I’d create this post. Below you will find my code sample:

This first snippet set up the service connection using autodiscover.

        private ExchangeService GetService()

        {

            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

            service.Credentials = new NetworkCredential(Settings.Default.ConnectingUser, Settings.Default.ConnectingUserPassword, Settings.Default.ConnectingUserDomain);

            service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SID, Settings.Default.ImpersonatedUserSID);

            service.Url = new Uri(Settings.Default.EWSURL);

            return service;

        }

This second snippet defines and fetches the standard properties as well as the extended properties.

        private void btnGetItem_Click(object sender, EventArgs e)

        {

            string itemId = txtItemId.Text;

            ExchangeService service = GetService();

            AlternateId sourceId = new AlternateId(IdFormat.EwsLegacyId, itemId, Settings.Default.ImpersonatedUserMailbox);

            AlternateId destinationId = service.ConvertId(sourceId, IdFormat.EwsId) as AlternateId;

            //reference: http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/e01fe982-83c2-49ee-b900-78d49c47323c/

            //define the extended properties that should be fetched

            ExtendedPropertyDefinition rmsIsRms = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, “RMS-IsRMS”, MapiPropertyType.Boolean);

            ExtendedPropertyDefinition rmsCustomerProp = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, “RMS-CustomerProp”, MapiPropertyType.String);

            ExtendedPropertyDefinition rmsInternalProp = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, “RMS-InternalProp”, MapiPropertyType.Boolean);

            ExtendedPropertyDefinition rmsProjectProp = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, “RMS-ProjectProp”, MapiPropertyType.String);

            ExtendedPropertyDefinition rmsActivityProp = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, “RMS-ActivityProp”, MapiPropertyType.String);

            ExtendedPropertyDefinition[] userFields = new ExtendedPropertyDefinition[] { rmsIsRms, rmsActivityProp, rmsCustomerProp, rmsInternalProp, rmsProjectProp };

            //get the item and it’s extended properties

            PropertySet extendedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, userFields);

            Appointment item = (Appointment)Item.Bind(service, new ItemId(destinationId.UniqueId), extendedPropertySet);

            //having the item – get the extended properties

            object isRMS;

            object customerProp;

            object isInternalProp;

            object projectProp;

            object activityProp;

            //Print properties

            rtItemProps.AppendText(“ItemClass: “ + item.ItemClass + “\n”);

            rtItemProps.AppendText(“Subject: “ + item.Subject + “\n”);

            rtItemProps.AppendText(“CalendarItemType: “ + item.AppointmentType.ToString() + “\n”);

            rtItemProps.AppendText(“Organizer: “ + item.Organizer.Name + “\n”);

            rtItemProps.AppendText(“OrganizerEmail: “ + item.Organizer.Address + “\n”);

            rtItemProps.AppendText(“Start: “ + item.Start + “\n”);

            rtItemProps.AppendText(“End: “ + item.End + “\n”);

            rtItemProps.AppendText(“Location: “ + item.Location + “\n”);

            rtItemProps.AppendText(“Free/busy: “ + item.LegacyFreeBusyStatus.ToString() + “\n”);

            rtItemProps.AppendText(“—————RMS INFO————–\n”);

            //extended properties are printed only if they exist

            if (item.TryGetProperty(rmsIsRms, out isRMS) && isRMS != null)

            {

                rtItemProps.AppendText(“IsRMS: “ + isRMS.ToString() + “\n”);

            }

            if (item.TryGetProperty(rmsCustomerProp, out customerProp) && customerProp != null)

            {

                rtItemProps.AppendText(“Customer: “ + customerProp.ToString() + “\n”);

            }

            if (item.TryGetProperty(rmsProjectProp, out projectProp) && projectProp != null)

            {

                rtItemProps.AppendText(“Project: “ + projectProp.ToString() + “\n”);

            }

            if (item.TryGetProperty(rmsActivityProp, out activityProp) && activityProp != null)

            {

                rtItemProps.AppendText(“Activity: “ + activityProp.ToString() + “\n”);

            }

            if (item.TryGetProperty(rmsInternalProp, out isInternalProp) && isInternalProp != null)

            {

                rtItemProps.AppendText(“IsInternal: “ + isInternalProp.ToString() + “\n”);

            }

        }

Posted in Exchange development, Microsoft .net | Tagged: , , | 5 Comments »

Interesting whitepaper on sharepoint load testing using The Visual Studio Test Capabilities

Posted by Torben M. Philippsen on June 16, 2011

Check out this whitepaper – How to Configure a Stress Test Project for Microsoft Office SharePoint Server 2007 using Visual Studio Team Suite 2008.

I have experienced some availabilty problems with the link, and because of that, You will also be able to get a local copy of the whitepaper from here:

HowToConfigStressTestProjectForMOSS07usingVS2008TS

 

If you want more information on VS and testing, You should check out the blog of Ed Glas

Posted in Books and reading stuff | Tagged: , , , | Comments Off on Interesting whitepaper on sharepoint load testing using The Visual Studio Test Capabilities

Viewin a list of applied webparts on a EP page

Posted by Torben M. Philippsen on June 8, 2011

If You find yourself struggling with clientside events a list of applied WebParts could come in handy. You can view a list of applied webparts as well as the order in which they are applied to the content  page by appending “&contents=1” to the querystring. If you do so, You will see something like this:

EP WebPart list

Posted in Enterprise Portal Development | Tagged: | Comments Off on Viewin a list of applied webparts on a EP page

Manually sign any file using a pfx file

Posted by Torben M. Philippsen on June 6, 2011

A colleegue of mine recently build a MSI installer using some third party tool unknown to me. He kindly asked me, what he needed to do, to sign the installer using our corporate codesigning certificate.

I am used to build my installers using Visual Studio, but I remembered that I once or twice had used the SignTool.exe command line tool, to sign some files. I looked up the documentation for the tool And quickly I was able to create a command meeting my needs:

E:\VSS\USMT\MSIProject>signtool sign /f E:\VSS\CodeSigningCert\Trustzone\eg_codesigning.pfx /p mypassword /d USMTApp USMTApp.msi

Note: To me it seems rather important to remember the d options – adding a description to the installer. This will show when the user runs the isntallation package.

Posted in Visual Studio | Tagged: | Comments Off on Manually sign any file using a pfx file

 
%d bloggers like this: