What are PackageReferences and how will they help optimise the way I deal with NuGet packages?












8














With version 9.1, Sitecore changed their NuGet library to no longer include NoReferences versions of their assemblies. This is also mentioned in How do I reference Sitecore binaries from NuGet?.



One alternative being brought up, is to shift to using PackageReferences (applicable only to VS2017 and above). What is that? And what would be involved in making the switch?










share|improve this question



























    8














    With version 9.1, Sitecore changed their NuGet library to no longer include NoReferences versions of their assemblies. This is also mentioned in How do I reference Sitecore binaries from NuGet?.



    One alternative being brought up, is to shift to using PackageReferences (applicable only to VS2017 and above). What is that? And what would be involved in making the switch?










    share|improve this question

























      8












      8








      8







      With version 9.1, Sitecore changed their NuGet library to no longer include NoReferences versions of their assemblies. This is also mentioned in How do I reference Sitecore binaries from NuGet?.



      One alternative being brought up, is to shift to using PackageReferences (applicable only to VS2017 and above). What is that? And what would be involved in making the switch?










      share|improve this question













      With version 9.1, Sitecore changed their NuGet library to no longer include NoReferences versions of their assemblies. This is also mentioned in How do I reference Sitecore binaries from NuGet?.



      One alternative being brought up, is to shift to using PackageReferences (applicable only to VS2017 and above). What is that? And what would be involved in making the switch?







      nuget






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 30 '18 at 15:03









      Mark Cassidy

      16.7k43280




      16.7k43280






















          1 Answer
          1






          active

          oldest

          votes


















          11














          PackageReference is a new way to allow NuGet to manage your projects references. Before this, adding a NuGet package would update both the packages.config file and the .csproj file for your solution. The packages.config contains the package name and version, and the .csproj file contains a reference to the downloaded package on disk.



          Enter PackageReference



          From VS2017 you can now use the PackageReference node to manage NuGet dependencies directly within the .csproj file. This still uses other aspects of NuGet like the nuget.config file, all those settings are still applied.



          Because of this, you get a lot more control over your NuGet dependencies. For example, you can use MSBuild conditions to choose package references per target framework, configuration, platform etc...



          Adding a PackageReference



          To add a package reference, you just need to add it to the project file like this:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.0" />
          <!-- ... -->
          </ItemGroup>


          You can specify the version. If you specify a specific number, that means that it is >=12.0.0. The preference is on the lowest version that meets that requirement.



          One very cool thing is Floating Versions. With floating version you can do things like "use the latest 12.0.x version". For example:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.*" />
          <!-- ... -->
          </ItemGroup>


          Benefits of using PackageReference




          • You can manage all your project dependencies in one place


          • Easier to see your projects actual dependencies - With PackageReference, you only add direct dependencies to your .csproj file. If a NuGet package has dependencies, they do not clutter up your project file anymore.


          • Performance - PackageReference packages are saved to a global-packages folder instead of a local solution folder. Uses less disk space, is a bit faster when you already have packages downloaded. See Managing the global packages and cache folders


          • Control over dependencies and content flow using the MSBuild conditions as mentioned above


          Packages.config is not being developed



          One big benefit of moving to this way of handling NuGet packages is that the existing packages.config is no longer under active development, whereas PackageRefrence is https://github.com/NuGet/Home/issues/6763



          Migrating to PackageReference



          There is a way in VS to migrate existing packages.config setups to PackageReference. In your Solution Explorer, right-click on the References node or the packages.config file and click Migrate packages.config to PackageReference



          This should migrate you over to PackageReference - but there are known issues with that. See here for details on the known issues Migrate from packages.config to PackageReference



          There is also a NuGet PackageReference Updater tool on the VS market place: NuGet PackageReference Updater



          Conclusion



          PackageReference is the future and has a number of benefits over packages.config. Its worth looking into migrating your projects, but just be aware that there are some limitations with existing packages, especially Sitecore modules like Glass and Unicorn that include example config files. They will need updates to fully support that with PackageReference, so hopefully that will happen soon.



          Some references:




          • Migrate to PackageReference with 3 clicks

          • Migrate from packages.config to PackageReference

          • Package references (PackageReference) in project files






          share|improve this answer

















          • 1




            It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
            – Richard Szalay
            Dec 2 '18 at 19:54











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "664"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15293%2fwhat-are-packagereferences-and-how-will-they-help-optimise-the-way-i-deal-with-n%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          11














          PackageReference is a new way to allow NuGet to manage your projects references. Before this, adding a NuGet package would update both the packages.config file and the .csproj file for your solution. The packages.config contains the package name and version, and the .csproj file contains a reference to the downloaded package on disk.



          Enter PackageReference



          From VS2017 you can now use the PackageReference node to manage NuGet dependencies directly within the .csproj file. This still uses other aspects of NuGet like the nuget.config file, all those settings are still applied.



          Because of this, you get a lot more control over your NuGet dependencies. For example, you can use MSBuild conditions to choose package references per target framework, configuration, platform etc...



          Adding a PackageReference



          To add a package reference, you just need to add it to the project file like this:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.0" />
          <!-- ... -->
          </ItemGroup>


          You can specify the version. If you specify a specific number, that means that it is >=12.0.0. The preference is on the lowest version that meets that requirement.



          One very cool thing is Floating Versions. With floating version you can do things like "use the latest 12.0.x version". For example:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.*" />
          <!-- ... -->
          </ItemGroup>


          Benefits of using PackageReference




          • You can manage all your project dependencies in one place


          • Easier to see your projects actual dependencies - With PackageReference, you only add direct dependencies to your .csproj file. If a NuGet package has dependencies, they do not clutter up your project file anymore.


          • Performance - PackageReference packages are saved to a global-packages folder instead of a local solution folder. Uses less disk space, is a bit faster when you already have packages downloaded. See Managing the global packages and cache folders


          • Control over dependencies and content flow using the MSBuild conditions as mentioned above


          Packages.config is not being developed



          One big benefit of moving to this way of handling NuGet packages is that the existing packages.config is no longer under active development, whereas PackageRefrence is https://github.com/NuGet/Home/issues/6763



          Migrating to PackageReference



          There is a way in VS to migrate existing packages.config setups to PackageReference. In your Solution Explorer, right-click on the References node or the packages.config file and click Migrate packages.config to PackageReference



          This should migrate you over to PackageReference - but there are known issues with that. See here for details on the known issues Migrate from packages.config to PackageReference



          There is also a NuGet PackageReference Updater tool on the VS market place: NuGet PackageReference Updater



          Conclusion



          PackageReference is the future and has a number of benefits over packages.config. Its worth looking into migrating your projects, but just be aware that there are some limitations with existing packages, especially Sitecore modules like Glass and Unicorn that include example config files. They will need updates to fully support that with PackageReference, so hopefully that will happen soon.



          Some references:




          • Migrate to PackageReference with 3 clicks

          • Migrate from packages.config to PackageReference

          • Package references (PackageReference) in project files






          share|improve this answer

















          • 1




            It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
            – Richard Szalay
            Dec 2 '18 at 19:54
















          11














          PackageReference is a new way to allow NuGet to manage your projects references. Before this, adding a NuGet package would update both the packages.config file and the .csproj file for your solution. The packages.config contains the package name and version, and the .csproj file contains a reference to the downloaded package on disk.



          Enter PackageReference



          From VS2017 you can now use the PackageReference node to manage NuGet dependencies directly within the .csproj file. This still uses other aspects of NuGet like the nuget.config file, all those settings are still applied.



          Because of this, you get a lot more control over your NuGet dependencies. For example, you can use MSBuild conditions to choose package references per target framework, configuration, platform etc...



          Adding a PackageReference



          To add a package reference, you just need to add it to the project file like this:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.0" />
          <!-- ... -->
          </ItemGroup>


          You can specify the version. If you specify a specific number, that means that it is >=12.0.0. The preference is on the lowest version that meets that requirement.



          One very cool thing is Floating Versions. With floating version you can do things like "use the latest 12.0.x version". For example:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.*" />
          <!-- ... -->
          </ItemGroup>


          Benefits of using PackageReference




          • You can manage all your project dependencies in one place


          • Easier to see your projects actual dependencies - With PackageReference, you only add direct dependencies to your .csproj file. If a NuGet package has dependencies, they do not clutter up your project file anymore.


          • Performance - PackageReference packages are saved to a global-packages folder instead of a local solution folder. Uses less disk space, is a bit faster when you already have packages downloaded. See Managing the global packages and cache folders


          • Control over dependencies and content flow using the MSBuild conditions as mentioned above


          Packages.config is not being developed



          One big benefit of moving to this way of handling NuGet packages is that the existing packages.config is no longer under active development, whereas PackageRefrence is https://github.com/NuGet/Home/issues/6763



          Migrating to PackageReference



          There is a way in VS to migrate existing packages.config setups to PackageReference. In your Solution Explorer, right-click on the References node or the packages.config file and click Migrate packages.config to PackageReference



          This should migrate you over to PackageReference - but there are known issues with that. See here for details on the known issues Migrate from packages.config to PackageReference



          There is also a NuGet PackageReference Updater tool on the VS market place: NuGet PackageReference Updater



          Conclusion



          PackageReference is the future and has a number of benefits over packages.config. Its worth looking into migrating your projects, but just be aware that there are some limitations with existing packages, especially Sitecore modules like Glass and Unicorn that include example config files. They will need updates to fully support that with PackageReference, so hopefully that will happen soon.



          Some references:




          • Migrate to PackageReference with 3 clicks

          • Migrate from packages.config to PackageReference

          • Package references (PackageReference) in project files






          share|improve this answer

















          • 1




            It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
            – Richard Szalay
            Dec 2 '18 at 19:54














          11












          11








          11






          PackageReference is a new way to allow NuGet to manage your projects references. Before this, adding a NuGet package would update both the packages.config file and the .csproj file for your solution. The packages.config contains the package name and version, and the .csproj file contains a reference to the downloaded package on disk.



          Enter PackageReference



          From VS2017 you can now use the PackageReference node to manage NuGet dependencies directly within the .csproj file. This still uses other aspects of NuGet like the nuget.config file, all those settings are still applied.



          Because of this, you get a lot more control over your NuGet dependencies. For example, you can use MSBuild conditions to choose package references per target framework, configuration, platform etc...



          Adding a PackageReference



          To add a package reference, you just need to add it to the project file like this:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.0" />
          <!-- ... -->
          </ItemGroup>


          You can specify the version. If you specify a specific number, that means that it is >=12.0.0. The preference is on the lowest version that meets that requirement.



          One very cool thing is Floating Versions. With floating version you can do things like "use the latest 12.0.x version". For example:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.*" />
          <!-- ... -->
          </ItemGroup>


          Benefits of using PackageReference




          • You can manage all your project dependencies in one place


          • Easier to see your projects actual dependencies - With PackageReference, you only add direct dependencies to your .csproj file. If a NuGet package has dependencies, they do not clutter up your project file anymore.


          • Performance - PackageReference packages are saved to a global-packages folder instead of a local solution folder. Uses less disk space, is a bit faster when you already have packages downloaded. See Managing the global packages and cache folders


          • Control over dependencies and content flow using the MSBuild conditions as mentioned above


          Packages.config is not being developed



          One big benefit of moving to this way of handling NuGet packages is that the existing packages.config is no longer under active development, whereas PackageRefrence is https://github.com/NuGet/Home/issues/6763



          Migrating to PackageReference



          There is a way in VS to migrate existing packages.config setups to PackageReference. In your Solution Explorer, right-click on the References node or the packages.config file and click Migrate packages.config to PackageReference



          This should migrate you over to PackageReference - but there are known issues with that. See here for details on the known issues Migrate from packages.config to PackageReference



          There is also a NuGet PackageReference Updater tool on the VS market place: NuGet PackageReference Updater



          Conclusion



          PackageReference is the future and has a number of benefits over packages.config. Its worth looking into migrating your projects, but just be aware that there are some limitations with existing packages, especially Sitecore modules like Glass and Unicorn that include example config files. They will need updates to fully support that with PackageReference, so hopefully that will happen soon.



          Some references:




          • Migrate to PackageReference with 3 clicks

          • Migrate from packages.config to PackageReference

          • Package references (PackageReference) in project files






          share|improve this answer












          PackageReference is a new way to allow NuGet to manage your projects references. Before this, adding a NuGet package would update both the packages.config file and the .csproj file for your solution. The packages.config contains the package name and version, and the .csproj file contains a reference to the downloaded package on disk.



          Enter PackageReference



          From VS2017 you can now use the PackageReference node to manage NuGet dependencies directly within the .csproj file. This still uses other aspects of NuGet like the nuget.config file, all those settings are still applied.



          Because of this, you get a lot more control over your NuGet dependencies. For example, you can use MSBuild conditions to choose package references per target framework, configuration, platform etc...



          Adding a PackageReference



          To add a package reference, you just need to add it to the project file like this:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.0" />
          <!-- ... -->
          </ItemGroup>


          You can specify the version. If you specify a specific number, that means that it is >=12.0.0. The preference is on the lowest version that meets that requirement.



          One very cool thing is Floating Versions. With floating version you can do things like "use the latest 12.0.x version". For example:



          <ItemGroup>
          <!-- ... -->
          <PackageReference Include="Sitecore.Kernel" Version="12.0.*" />
          <!-- ... -->
          </ItemGroup>


          Benefits of using PackageReference




          • You can manage all your project dependencies in one place


          • Easier to see your projects actual dependencies - With PackageReference, you only add direct dependencies to your .csproj file. If a NuGet package has dependencies, they do not clutter up your project file anymore.


          • Performance - PackageReference packages are saved to a global-packages folder instead of a local solution folder. Uses less disk space, is a bit faster when you already have packages downloaded. See Managing the global packages and cache folders


          • Control over dependencies and content flow using the MSBuild conditions as mentioned above


          Packages.config is not being developed



          One big benefit of moving to this way of handling NuGet packages is that the existing packages.config is no longer under active development, whereas PackageRefrence is https://github.com/NuGet/Home/issues/6763



          Migrating to PackageReference



          There is a way in VS to migrate existing packages.config setups to PackageReference. In your Solution Explorer, right-click on the References node or the packages.config file and click Migrate packages.config to PackageReference



          This should migrate you over to PackageReference - but there are known issues with that. See here for details on the known issues Migrate from packages.config to PackageReference



          There is also a NuGet PackageReference Updater tool on the VS market place: NuGet PackageReference Updater



          Conclusion



          PackageReference is the future and has a number of benefits over packages.config. Its worth looking into migrating your projects, but just be aware that there are some limitations with existing packages, especially Sitecore modules like Glass and Unicorn that include example config files. They will need updates to fully support that with PackageReference, so hopefully that will happen soon.



          Some references:




          • Migrate to PackageReference with 3 clicks

          • Migrate from packages.config to PackageReference

          • Package references (PackageReference) in project files







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 30 '18 at 17:26









          Richard Seal

          13.5k32560




          13.5k32560








          • 1




            It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
            – Richard Szalay
            Dec 2 '18 at 19:54














          • 1




            It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
            – Richard Szalay
            Dec 2 '18 at 19:54








          1




          1




          It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
          – Richard Szalay
          Dec 2 '18 at 19:54




          It should be noted that the built in migration is not available to ASP.NET projects, those will require the VS extension.
          – Richard Szalay
          Dec 2 '18 at 19:54


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Sitecore Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15293%2fwhat-are-packagereferences-and-how-will-they-help-optimise-the-way-i-deal-with-n%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents