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.
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.
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.