title: How do I set up TeamCity CI so that it unpacks Xamarin components?
body: <p><img src="https://i.stack.imgur.com/8mJuG.png" alt="enter image description here"></p>
  
  <p>In Visual Studio everything works and a Components directory is created with the appropriate dlls. However, TeamCity is not able to retrieve the Android Support Library dlls because the trigger for the restore is a Xamarin VS plugin that runs when loading the solution. The equivalent of nuget package restore for Xamarin is <a href="https://components.xamarin.com/submit/xpkg" rel="nofollow noreferrer">xamarin-component</a>. I have placed the xamarin-component.exe in my C:\Windows directory. To configure TeamCity, I prepended a Command Line build step with</p>
  
  <pre><code>Command executable: xamarin-component 
  Command parameters: restore mysolution.sln
  </code></pre>
  
  <p>TeamCity runs as NT Authority\System. So using PsExec, </p>
  
  <pre><code>psexec -i -s %SystemRoot%\system32\cmd.exe
  </code></pre>
  
  <p>If I then run 'xamarin-component login'</p>
  
  <pre><code>INFO (login): Computed cookie jar path: C:\Windows\system32\config\systemprofile\.xamarin-credentials 
  INFO (login): Computed cookie jar path: C:\Windows\system32\config\systemprofile\.xamarin-credentials 
  INFO (login): Credentials successfully stored.
  </code></pre>
  
  <p>When I go to my solution in cmd and attempt the restore, I get an attempt to download the componet, and then a Json parsing error. This is the same error I get in TeamCity.</p>
  
  <p><img src="https://i.stack.imgur.com/FoZ3b.png" alt="teamcity"></p>
  
  <p>I get the error if I use 'Administrator' (which stores the credential in C:\Users\Administrator. Earlier when I was using my personal account, it did work. However, once I deleted the C:\Users\tim\AppData\Local\Xamarin\Cache\Components, the same issue emerged. Fiddler shows that rather than getting Json back (as we do when we enter an invalid token) we are getting a 302 redirect that says Object moved <em>here</em>. And here is the xamarin 
  login page - obviously not Json.</p>
  
  <p><strong>Tried.</strong>
   1. Set COOKIE_JAR_PATH to C:\Users\tim.xamarin-credentials - <em>xpkg picks up but same error</em>
   2. Copy .xamarin-credentials from Config\system32 to D:\, set COOKIE_JAR_PATH to D:.xamarin-credentials - <em>xpkg picks up but same error</em>
   3. Move .xamarin-credentials to C:\, set COOKIE_JAR_PATH - <em>same error</em>
   4. Re-login in NT Authority with COOKIE_JAR_PATH to C:.xamarin-credentials - <em>same error</em></p>
  
  <p>My temporary idea now is to figure out where the NT Authority xamarin-component looks for Cache and put the files there.</p>
  
  <pre><code>C:\Windows\system32\config\systemprofile\AppData\Local\Xamarin\Cache\Components\xamandroidsupportv4-18-4.18.1.xam
  </code></pre>
  
  <p>The version of my xamarin-component is 0.99 - for 100, we try harder...</p>