Bug 23033 - Xamarin Studio unable to restore packages from Continuous Integration
Summary: Xamarin Studio unable to restore packages from Continuous Integration
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NuGet ()
Version: 5.4
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: master
Assignee: Matt Ward
URL:
Depends on:
Blocks:
 
Reported: 2014-09-15 21:05 UTC by Kent Green [MSFT]
Modified: 2015-01-07 05:01 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Kent Green [MSFT] 2014-09-15 21:05:43 UTC
===Overview===
From this priority case:
https://xamarin.desk.com/agent/case/88542

Xamarin Studio is unable to restore packages from Continuous Integration. The customer reports that they encountered an error that the build was failing to link because the Xamarin.Forms NuGet package wasn't restored. They tried to work around by adding a call to "NuGet.exe restore <mysolution>" as a build step prior to the XBuild step; but they were unable to find NuGet.exe on their system; even though the NuGet AddIn is shown as installed. 

Specifically, they looked for it in:
/Applications/Xamarin Studio.app/Contents/MacOS/lib/monodevelop/Addins/MonoDevelop.PackageManagement
Comment 1 Matt Ward 2014-09-16 03:46:40 UTC
There were some changes made to Xamarin Studio 5.3 for NuGet restore and NuGet.exe is no longer shipped with Xamarin Studio. Xamarin Studio 5.3 no longer uses NuGet.exe itself to restore NuGet packages but does the restore itself.

On a build server NuGet.exe will need to be made available, either by having it in source control so it is checked out as part of the build, or having a script that downloads it, or having it installed on the build server so it is available.

For the Mac, if Mono 3.6 or higher is installed then NuGet.exe should be available already. There is a nuget script installed so you should be able to call nuget directory on the command line, without having to know the full path:

    nuget restore Path/To/YourSolution.sln

On Windows or for Mono 3.4 or earlier, NuGet.exe will need to be copied from one of the following locations and made available to the build server:

    a) https://nuget.codeplex.com/releases  (Official NuGet.exe)
    b) https://github.com/mono/nuget-binary  (Mono specific NuGet.exe that was shipped originally with Xamarin Studio)

The official NuGet.exe should work on the Mac for restoring the packages. The Mono specific NuGet.exe requires all the binaries from the GitHub repository to be copied as well as NuGet.exe.
Comment 2 dennis.doubleday 2014-09-16 09:08:00 UTC
I succeeded in restoring by installing the official NuGet.exe. However, there was an additional complication.

The restore didn't work until I modified the Import section of my .csproj, turning backslashes in the path into forward slashes. I read that this would work on a Mac, but wouldn't break things on Windows.

Perhaps this is a known separate bug, I do not know.
Comment 3 Matt Ward 2014-09-16 09:38:54 UTC
NuGet.exe does have some problems with paths on the Mac however I have only seen one affecting NuGet restore and that was if you use a custom repository path in your NuGet.config file:

<configuration>
  <config>
    <add key="repositoryPath" value="../../MyPackages" />
  </config>
</configuration>

If back slashes are used in the above file on the Mac the packages are not restored to the correct directory. Changing them to forward slashes works on both Windows and Mac.

Using forward slashes should be OK. One problem may be if this Import is used by a NuGet package then on updating the NuGet package the forward slashes will be replaced with back slashes again by Xamarin Studio on the Mac. Ideally it should just work with 

1) What does the import look like that was causing a problem?
2) Did the restore fail or did the restore complete without any errors but the build failed because of a missing file?
Comment 4 dennis.doubleday 2014-09-16 10:40:05 UTC
Apparently the backslashes were only a problem for the NuGet.exe I installed myself. I was invoking it as

NuGet.exe restore <long-path-to-my>Project.Android.csproj

I had to change backslashes in the Import section to forward slashes to get it to work. Otherwise, I would get the error message embedded in the Import section:

  <Import Project="..\packages\Xamarin.Forms.1.2.2.6243\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.2.2.6243\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\Xamarin.Forms.1.2.2.6243\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.1.2.2.6243\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets'))" />
  </Target>


However, following your lead, I switched my build setup to use /usr/bin/nuget. But, unlike the Nuget.exe I installed myself, the Mono version doesn't seem to want to accept the .csproj file as an argument.

It worked with no changes when I invoked

nuget restore Project.Android/packages.config -SolutionDirectory .
Comment 5 dennis.doubleday 2014-09-16 10:43:32 UTC
So, I think the backslash issue was user error, probably.
Comment 6 Sadik Ali 2015-01-07 02:39:26 UTC
I have checked this issue and able to reproduce	 this issue with the help of bug description.

Steps i have followed to reproduce :

1. Open ‘Working with Map’ sample.
2. Update Xamarin.forms and  Xamarin.forms.maps to version 1.3.1.6296 .
3. Restored forms package from right click of project->Restore package.
4. Status bar shows package successfully restored.
5. Observed that package does not restored and getting a build error.

Screencast:  http://www.screencast.com/t/6kLFx22tQl
Ide log : https://gist.github.com/Arpit360/6c332a7193ad1e83711b

Environment Info:

Xamarin.Forms : 1.3.1.6296

=== Xamarin Studio ===

Version 5.5.4 (build 15)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
	Mono 3.10.0 ((detached/92c4884)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000031

=== Apple Developer Tools ===

Xcode 6.1 (6602)
Build 6A1052c

=== Xamarin.Mac ===

Version: 1.10.0.18 (Enterprise Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin.iOS ===

Version: 8.4.0.47 (Enterprise Edition)
Hash: 7244769
Branch: 
Build date: 2014-12-11 14:54:30-0500

=== Build Information ===

Release ID: 505040015
Git revision: f93940a35458a18052f1a25e106e62ca970d9c40
Build date: 2014-11-19 15:32:41-05
Xamarin addins: dc23cbd91a3a0e1d326328e1229e86c942a49ec8

=== Operating System ===

Mac OS X 10.10.0
Darwin mac360-xamarins-Mac-mini.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 7 Matt Ward 2015-01-07 05:01:58 UTC
@Sadik - The original bug report is for using NuGet.exe to do a package restore as part of Continuous Integration and not using Xamarin Studio manually. Also a build error does not necessarily mean there was a problem with the NuGet package restore. Unfortunately you did not attach the build log. If there is a build error then a separate bug should be logged against Xamarin.Forms if there is not one already.

I am going to mark this bug as resolved since we have a workaround for restoring NuGet packages in a CI build as specified in comment 4.