Installing PostSharp Into a Project

The compiler components of PostSharp are distributed as a NuGet package named simply PostSharp. If you want to use PostSharp in a project, you simply have to add this NuGet package to the project.

This topic contains the following sections:

Adding PostSharp to a project

To add PostSharp to a project:

  1. Open the Solution Explorer in Visual Studio.

  2. Right-click on the project.

  3. Click on Add PostSharp.

Tip Tip

Remember that adding PostSharp to a project just means adding the PostSharp NuGet package. If you want to add PostSharp to several projects in a solution, it may be easier to use NuGet to manage packages at solution level. You may need to select the Include Prerelease option to install a prerelease version of PostSharp.

Tip Tip

NuGet Package Manager can be configured using a file named nuget.config, which can be checked into source control and can specify, among other settings, the location of the package repository (if it must be shared among several solutions, for instance) or package sources (if packages must be pre-approved). See NuGet Configuration File and NuGet Configuration Settings for more information.

Including files in source control

After you add PostSharp to a project, you need to add the following files to source control:

  • packages.config

  • *.psproj

  • *.pssln

Optionally, you can also include the packages folder in source control. Note that some people advise against this practice. If you choose not to include the packages folder in source control, read Restoring Packages at Build Time.

Once you have all of these files include in your source code repository any other developer getting that source code from the repository will have the required information to be able to build the application.