Package management is a great way to manage the set of external dependencies (and their dependencies) as part of your typical modern development workflow. Whether the source code is being built by a cloud-based remote build agent or by a developer working locally on their laptop, package management helps to ensure consistency and reliability in a build process by abstracting and automating the process of locating, copying, version-checking, and referencing a particular resource or library.
InRule 5.0 and NuGet
Since the release of InRule 5.0 in April of 2016, irSDK has been available in the form of NuGet packages. These packages are laid down by the InRule installer onto users’ machines who select the appropriate options into the installation directory (C:Program Files (x86)InRuleirSDKNuGetPackages). For more on the specifics of the irSDK NuGet packages, see https://support.inrule.com/help/irSDKHelp50/using_inrule_nuget_packages.htm. The linked page shows how to configure Visual Studio to consume the SDK packages, a workable approach for individual developers working on prototypes or PoC’s.
For team, continuous integration and deployment (CI/CD), and other projects that are more enduring, using a folder-based package source has the issue of needing to be individually configured and set up in every environment. Build agents need to have access to the packages to compile the source. Additional licensing concerns may requires each machine locally using the packages to download and run the InRule installer or activation utility (to providing an irSDK license key). This adds complexity and effort to building anything using those packages. It may even remove the team’s ability to take advantage of certain cloud patterns and services! If only there was some way to have the cake of using a local folder for package sources whilst at the same time being able to eat it too by using a separate feed/path/source for CI/CD builds…
Configuring NuGet Package Sources
Fortunately, there’s another way to tackle the original problem that doesn’t carry with it the drawbacks of the earlier approach by designating a project- (or solution-) specific NuGet config file. The NuGet configuration file allows one or more package sources to be specified that will be used when downloading packages. You’ll check this file into your source control system, which will be used when developing locally. In your CI build definition, your build server’s NuGet feed integration can be used to point to a folder on your build agent or even to a private MyGet or VSTS package feed. Consult the documentation for your build server to learn how to configure feeds for your particular build process.
Here are two approaches to add a folder-based source to a project that uses the irSDK, using the default installation directory for InRule.
Approach 1: create/modify NuGet.config (use source control to share feed settings. Developers must install irSDK or copy packages to the given location)
Create an empty text file named NuGet.config in the root directory of your solution. Add a top-level XML declaration as well as a configuration root element. Within the configuration element, add the packageSources element along with child packageSource elements:
<packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> <add key="irSDKLocal" value="C:Program Files (x86)InRuleirSDKNuGetPackages" /> </packageSources>
The NuGet.config file will look something like this:
<?xml version="1.0" encoding="utf-8"?> <configuration> <solution> <add key="disableSourceControlIntegration" value="true" /> </solution> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> <add key="InRule SDK" value="C:Program Files (x86)InRuleirSDKNuGetPackages" /> </packageSources> </configuration>
Approach 2: use the NuGet.exe command line to add the source (Developer must install irSDK or copy packages to the given location)
- Open a command or powershell prompt.
- Run the NuGet sources command (adds to user’s nuget.config):
nuget sources add -Name InRuleSDK -Source C:Program Files (x86)InRuleirSDKNuGetPackages
- Alternatively, add the source to just the selected config file or project by adding to the command-line
-ConfigFile <config file path>
There it is – no need to go through the hassle of setting up a private MyGet, VSTS, or other type of package feed just to get the InRule SDK assemblies! With these directions, you should not have any trouble setting up and referencing the InRule SDK packages in your projects. The concept here is that if you’re working in a team of people, or have a CI server performing your builds (and you do have a CI, don’t you?) simply add an additional source pointing to either a shared location where the build agent can access the packages or go through the process to set up an internal, private feed accessible to the build.