Now that PostSharp 2.1 CTP 2 is out of the door, I’ll write more about individual new features. Let’s start with something easy: the NuGet package.

The PostSharp nuget contains everything you need to add aspects to an application. So not only does it contain the run-time library PostSharp.dll, but all the stuff you need to build the project, including the Visual Studio Extension.

Adding PostSharp to your application

It has never been easier to add aspects to your code:

1. Open the Add Library Package Reference dialog normally and search for a package named PostSharp. You may have to scroll down a bit because we just uploaded the package.

 

2. Click on Install :), accept license terms.

3. A few seconds after the installation completes, and only the first time you add PostSharp on your machine, PostSharp will ask you if you want to install the Visual Studio Extension (VSX). The VSX is an important help, so we highly recommend you to install it.

 

4. After the VSX has been installed, restart Visual Studio (again, you should do that only once per machine).

You can see a new page in the project properties. It means PostSharp is enabled for this project.

Features

A lot of smart things actually happen behind this apparent simplicity. The installation process will:

  • Add a reference to the proper PostSharp.dll library. Ok, this is obvious, all NuGet packages do that. Currently, the package supports the .NET Framework and Silverlight.
  • Add a reference to PostSharp.targets so that PostSharp kicks in the build process.
  • Remove any reference to a previous version of PostSharp.
  • Check whether a previous version of the VSX is installed, and help you to uninstall it if applicable.

Installation in Source Repository

It has always been possible to install PostSharp into the source repository however, until this version, there were some inconveniences. In version 1.5, PostSharp ran much more slowly from source repository because its libraries were not ngenned. Version 2.0 mitigated this issue by providing a long-running process (pipe server), but you had to use the setup program to use the VSX.

Starting from version 2.1, you can even deploy the Visual Studio Extension (VSX) from the source repository. When a developer runs PostSharp for the first time on his machine, he will see a dialog box asking whether the VSX should be installed. When someone installs a newer version of PostSharp in the source repository, all developers are requested to upgrade the VSX. No administrative privilege is required. Everything happens in the user profile only.

Note that this feature is not bound to NuGet. You get the same if you use the zip distribution instead of the NuGet package.

Summary

NuGet is a very convenient way to install PostSharp. It provides a streamlined experience and does not require administrative privileges. But most importantly, it will allow third-party vendors and OSS projects to handle dependencies to PostSharp in a very easy way. If your project or product ships aspects, make it easy for developers: include PostSharp as a NuGet dependency.

We’re open to remarks and ideas. Please add a comment to the current post or a topic to the support forum.

Happy PostSharping!

-gael

Comments (4) -

Dmitry
Dmitry
6/1/2011 10:12:58 AM #

Nice, but how can i install VSX again after i uninstalled it? I've uninstalled postsharp, previously installed via setup and decided to isntall it as nuget package. Now, when i try to build the project i'm constantly getting the message: The project uses non-licensed features (Run from Source Control). Please visit http://www.sharpcrafters.com/ to acquire a license of PostSharp.   What's the workaround for that?

Gael Fraiteur
Gael Fraiteur
6/1/2011 11:22:50 AM #

The license message is a bug, sorry for that.
To reinstall the VSX of PostSharp 2.0, you have to run the setup program and reinstall the feature.

-gael

Dmitry
Dmitry
6/1/2011 11:47:06 AM #

Gael Fraiteur, reinstalled already. Hope in future there will be easy way to use JUST NuGet. Thank you for work.

Bryce Fischer
Bryce Fischer
6/6/2011 7:06:35 PM #

Getting an error: "Arithmetic operation resulted in an overflow."

Pingbacks and trackbacks (3)+

Comments are closed