31

I've heard through the grapevine that Sitecore DLL's can be referenced through the use of NuGet Packages. I found Sitecore.NuGet, but I don't think that's the right option. I also found this blog post talking about the Sitecore NuGet Package Generator which looks promising.

Seems like there are quite a few ways that this is being handled according to Google. I also recall at the Sitecore Symposium 2016, that NuGet package availability might be something Sitecore provides.

So, the root of my question is:

What is the best way to reference Sitecore DLL's?

42

Updated with new information about NuGet feeds for 9.1

Previously, the 9.1 packages were in a separate feed, as of March 4th 2019, these have now been moved back into the main feed. The NoReferences packages are still removed.

To avoid link rot, here are the feed urls for the official feeds:

For all versions:

NuGet V3 feed URL (Visual Studio 2015+)

NuGet V2 feed URL (Visual Studio 2012+)

Browse packages

Versioning Updates

As of 9.1, The package versions will follow the Product version numbers, this will make it easier to identify which version a package refers to rather than having to look up the revision number for each update. So Sitecore 9.1 packages are versioned 9.1.0

What about the separate 9.1 feed? Will this break my build?

TL/DR; No, it wont, but you should change the feed asap.

Sitecore are removing the "old 9.1" feed listing from the gallery, but the feed will remain in place for those of you who have already used it. Once you upgrade, you will need to use the original feed for newer packages.

What happened to the .NoReferences packages?

With the new updates to the packages, Sitecore have also stopped providing the .NoReferences packages. This was done to simplify the the process for developers and also the release process for Sitecore.

But - you can still have a similar behavior with the full packages. Using the Nuget Package Manager you can change the Dependency Behavior option to Ignore Dependencies:

Change the dependency behavior

If you want to use the Package Manager Console you can use the -IgnoreDependencies flag like this:

Install-Package -Id <package name> -IgnoreDependencies -ProjectName <project name>

PackageReference

For those of you on VS 2017+, you can also migrate to using PackageReference to reference your nuget packages. This uses the PackageReference node in the .csproj file to manage the NuGet dependencies instead of the packages.config file. This brings a number of benefits that are too numerous to mention here, but you can find out more on the PackageReference page.

Build Servers

If you are using a build server, as well as adding this to Visual Studio you will want to update your Nuget.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
  Used to specify the default Sources for list, install and update.
  -->
  <packageSources>
    <add key="Official Sitecore" value="<URL to the package feed appropriate for your project>" />
  </packageSources>

  <activePackageSource>
    <!-- this tells that all of them are active -->
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>

Upgrading your Solution

There is a nice post here talking about adding that to your VS solution: https://jermdavis.wordpress.com/2016/09/05/the-official-sitecore-nuget-feed-is-here/

Some of the main points when using are: * There are packages with .NoReferences suffixed. These are probably the most useful as they don't try to bring in a lot of dependencies you may not need in your project. * They set the binaries as CopyLocal=true, so you may want to change that in your project

@kamsar wrote a nifty PowerShell script to update your solution to use this: http://kamsar.net/index.php/2016/09/Nugetify-your-Sitecore-References/

7

The official Sitcore Nuget feed is hosted on myget.org as @Adam correctly points out the details are in that document.

You can also read up more details about setting this up for your project in this blog post about the nuget feed but if you have an existing project that you want to migrate all references on, esp on a project which follows Helix guidelines meaning you will have a lot of projects and a lot of references, then this blog post about Nugetify your Sitecore References includes PowerShell scripts to change all the references.

If you are using Visual Studio 2015, rather than adding the Nuget server details from the tools option for each developer (and adding the settings in your build tool), you should do it the right way and add a NuGet.config file next to your .sln file with the nuget server details:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="Sitecore NuGet Feed" value="https://sitecore.myget.org/F/sc-packages/" />
    <add key="Internal Nuget Server" value="http://proget-internal/url-to-feed/" />
  </packageSources>
</configuration>

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.