<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lawrence Agbani</title>
    <description>The latest articles on DEV Community by Lawrence Agbani (@raznerd).</description>
    <link>https://dev.to/raznerd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F214660%2F342b1191-6325-47bb-a00a-3d70c43d2f56.jpg</url>
      <title>DEV Community: Lawrence Agbani</title>
      <link>https://dev.to/raznerd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raznerd"/>
    <language>en</language>
    <item>
      <title>Azure pipelines: How to restore local nuget packages</title>
      <dc:creator>Lawrence Agbani</dc:creator>
      <pubDate>Mon, 19 Aug 2019 10:16:33 +0000</pubDate>
      <link>https://dev.to/raznerd/azure-pipelines-how-to-restore-local-nuget-packages-38o</link>
      <guid>https://dev.to/raznerd/azure-pipelines-how-to-restore-local-nuget-packages-38o</guid>
      <description>&lt;h3&gt;
  
  
  Why would I want to restore local nuget packages?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Please note that it is recommended to pack and &lt;a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget?view=azure-devops#push-nuget-packages"&gt;publish all packages&lt;/a&gt; and reference them by adding the URL as a new packageSource in your Nuget.config&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With that out of the way, there might be times when you have local &lt;code&gt;.nupkg&lt;/code&gt; packages and wish to restore these packages during the build stage in your Azure pipeline. In my case, I had to quickly setup Azure pipeline for a client and they were still figuring out their private nuget package repository, so I set it up in such a way that it  was possible for them to add the new package repository URL when they were done.&lt;/p&gt;

&lt;h3&gt;
  
  
  What problems will I encounter?
&lt;/h3&gt;

&lt;p&gt;For the purpose of this article, I’ll be using the &lt;code&gt;azure-pipeline.yml&lt;/code&gt; file method (instead of the GUI method). In your &lt;code&gt;azure-pipeline.yml&lt;/code&gt; file, you might have something that looks like this:  &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;With the above, if you only have referenced packages from api.nuget.org, the build pipeline should run fine. However, the moment you add references to local packages, you’ll get an error that looks like this:&lt;br&gt;
&lt;br&gt;
 &lt;br&gt;
&lt;code&gt; error NU1101: Unable to find package Company.Connect.Shared.Logging. No packages exist with this id in source(s): nuget.org Build failed &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  How can I solve the problem?
&lt;/h3&gt;

&lt;p&gt;That’s why you’re here, right? To solve this problem, you need to add an extra step to your azure-pipeline.yml file called the the &lt;code&gt;Restore&lt;/code&gt; step before your &lt;code&gt;Build&lt;/code&gt; step. Now your azure-pipeline.yml should look like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;With this, your Azure pipeline first does a &lt;code&gt;dotnet restore&lt;/code&gt; fetching all packages including the local ones before going ahead to &lt;code&gt;build&lt;/code&gt;. At this time, during build, the local packages will then be available.&lt;/p&gt;

&lt;p&gt;Thanks for reading :D&lt;/p&gt;

</description>
      <category>azure</category>
      <category>azurepipelines</category>
      <category>dotnet</category>
      <category>dotnetcore</category>
    </item>
  </channel>
</rss>
