Building .NET Projects with NuGet

This section provides information on how to consume the Solace .NET messaging API NuGet package using the NuGet Visual Studio extension version v3.5.0 or NuGet Commandline v3.5.0.

NuGet is a package manager for the Microsoft development platform, that is distributed as a Microsoft Visual Studio extension (NuGet.Tools.vsix) and is pre-installed starting with Microsoft Visual Studio 2012. If you download the Windows x86 Command line distribution (nuget.exe), you can also use NuGet from console by running it directly from the Windows command processor or by using the package manager console.

From version 10.0.0 on, the Solace .NET messaging API (also referred to as SolClient for .NET) is also available as a NuGet package. The SolClient for .NET NuGet package can be consumed directly from nuget.org, published to and then consumed from a corporate repository that supports the NuGet packaging format, or copied to a local directory and consumed from there.

The following section provides information on how to consume the Solace .NET messaging API NuGet package using the NuGet Visual Studio extension version v3.5.0 or NuGet Commandline v3.5.0.

For general information on how to consume NuGet packages, see Microsoft NuGet Package Consumption Workflow web page.

Upgrading Projects to NuGet

Before upgrading an existing Visual Studio project to consume the SolClient for .NET NuGet package, remove any post-build events that copy Solace C API libraries into the target directory. Failing to do this will result in the loading of wrong Solace C API libraries at runtime.

Correct libraries from the SolClient for .NET NuGet will be automatically copied to the target directory at build time.

Consuming Using NuGet Visual Studio Extension

  1. Specify the package source.

    You must know the location from which the SolClient for .NET package will be consumed: nuget.org, an internal NuGet repository, or a local file. Knowing the consuming location allows you to select the package source from the NuGet Visual Studio extension (VSE) GUI.

    When the package source is specified, the SolaceSystems.Solclient.Messaging package will display in the browse tab of the NuGet VSE.

    NuGet Browse Tab

  2. Click the “Install” button in the NuGet VSE, then accept the license terms.

    When the installation finishes, the SolaceSystems.Solclient.Messaging package appears on the Installed tab of the NuGet VSE, and it is added to the list of your project references, as shown below.

    NuGet Project References

    At this stage, the SolClient for .NET NuGet package has been successfully consumed, and it should be possible to use the SolaceSystems.Solclient.Messaging namespace in a program.

Consuming Using the NuGet Command Line

This section provides examples of using the NuGet command line that is embedded into the NuGet Visual Studio extension (the Package Manager Console) and the standalone nuget.exe.

Package Manager Console

  1. To use the package manager console on the NuGet Visual Studio extension, activate its window.

    Select View > Other Windows > Package Manager Console, and switch the input focus to that window.

  2. Select the proper package source and default project.

    Package Monitor Console

  3. At the command line prompt, enter the Install-Package SolaceSystems.Solclient.Messaging command:
    PM> Install-Package SolaceSystems.Solclient.Messaging
    Attempting to gather dependency information for package 'SolaceSystems.Solclient.Messaging.10.0.0' with respect to project 'ConsoleApplication1', targeting '.NETFramework,Version=v4.5'
    Attempting to resolve dependencies for package 'SolaceSystems.Solclient.Messaging.10.0.0' with DependencyBehavior 'Lowest'
    Resolving actions to install package 'SolaceSystems.Solclient.Messaging.10.0.0'
    Resolved actions to install package 'SolaceSystems.Solclient.Messaging.10.0.0'
    Adding package 'SolaceSystems.Solclient.Messaging.10.0.0' to folder 'C:\Projects\ ConsoleApplication1\packages'
    Added package 'SolaceSystems.Solclient.Messaging.10.0.0' to folder 'C:\Projects\ ConsoleApplication1\packages'
    Added package 'SolaceSystems.Solclient.Messaging.10.0.0' to 'packages.config'
    Successfully installed 'SolaceSystems.Solclient.Messaging 10.0.0' to ConsoleApplication1

For more details, see the Microsoft Package Manager Console tools page.

Standalone nuget.exe

To use a standalone nuget.exe, you must specify a proper package source as a parameter.

It is also possible to describe the source in the %AppData%\NuGet\NuGet.config file, but this is an advanced option for package consumption and it is recommended only when other methods listed above do not produce the intended results. For more details see the Microsoft Configuring NuGet Behavior Web page.

If the package source location is C:\Projects, the command will be:

C:\Projects\ConsoleApplication1>nuget.exe install SolaceSystems.Solclient.Messaging –Source C:\Projects
Feeds used:
C:\Projects
Attempting to gather dependency information for package 'SolaceSystems.Solclient.Messaging.10.0.0' with respect to project 'C:\Projects\ ConsoleApplication1', targeting 'Any,Version=v0.0'
Gathering dependency information took 14.1 ms
Attempting to resolve dependencies for package 'SolaceSystems.Solclient.Messaging.10.0.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'SolaceSystems.Solclient.Messaging.10.0.0'
Resolved actions to install package 'SolaceSystems.Solclient.Messaging.10.0.0'
Retrieving package 'SolaceSystems.Solclient.Messaging 10.0.0' from 'C:\Projects'.
Adding package 'SolaceSystems.Solclient.Messaging.10.0.0' to folder 'C:\Projects\ConsoleApplication1'
Added package 'SolaceSystems.Solclient.Messaging.10.0.0' to folder 'C:\Projects\ConsoleApplication1'
Successfully installed 'SolaceSystems.Solclient.Messaging 10.0.0' to C:\Projects\ConsoleApplication1
Executing nuget actions took 198.63 ms
C:\Projects\ConsoleApplication1>

Notice that the install command does not modify a project file or the packages.config file, it only adds packages to disk but does not change a projectʼs dependency.

To add SolaceSystems.Solclient.Messaging as a dependency, either add it to a project through the package manager UI or console in Visual Studio, or modify packages.config and then run the install command.

For more details on using the standalone nuget.exe, see the Microsoft NuGet CLI Reference web page.