33

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?

0

3 Answers 3

47

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

This is a breaking change!!!

In the separate 9.1 feed, the version numbers followed the binary versions, so the version for 9.1 initial release was 12.0.0, in the new feed they follow the product version, so it will now be 9.1.0, so when you switch to the correct feed, you will have to change your version numbers to match.

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

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.

Sitecore have now deprecated the original Sitecore XP 9.1 MyGet feed. After March 31st, 2020 the original 9.1 MyGet feed will not be available. Please make sure you move over to the current feed. More info can be found here: https://kb.sitecore.net/articles/686847

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/

Updates:

  • March 24th 2020 with new information about the original 9.1 specific MyGet feed.
  • March 26th 2019 with new information about NuGet feeds for 9.1
2
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>
1

And voila.

It looks like Sitecore changed the NuGet version of all Sitecore 9.1 related DLLs while migrating those to the standard NuGet repository.

What used to be 12.0.0 is now 9.1.0 (but the DLLs versions in each NuGet package are still 12.0.0).

If you want to fix this issue, just change the reference on all our projects to:

<package id="Sitecore.Abstractions" version="9.1.0" targetFramework="net472" />
1
  • 1
    Thanks for sharing :-) It really is in the site's best interest to try and consolidate all the information on nuget feeds and versions, so I'm going to merge your question with our primary post on the subject.
    – Mark Cassidy
    Commented Mar 26, 2019 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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