mrward/monodevelop-nuget-addin

Nuget Restore

Closed this issue · 9 comments

Not sure if its related to the plugin or MonoDevelop but is Nuget Restore possible with this? I can get it working via the command line but ideally would like to hit Build on my project in MD and for it to work like VS.

Thanks

What do you use on the command line to get it working? xbuild?

The addin itself does not currently support enabling NuGet package restore but you can configure MonoDevelop to execute the package restore.

The NuGet package restore feature, once enabled, relies on a custom MSBuild task. So you will need to enable xbuild support in MonoDevelop. This can be done by ticking the Compile projects using MSBuild/XBuild option under Edit - Preferences - Build. You need to restart MonoDevelop after doing this since the change does not seem to be recognised until after a restart.

I did a quick test in OpenSuse 12.2 with MonoDevelop 3.0.5 and after modifying the project file and the NuGet.targets file a bit it seemed to restore the packages. My modifications were:

  1. Fix incorrect case for NuGet.targets reference in project file.
  2. Fix incorrect case for NuGet.exe in NuGet.targets file.
  3. Comment out the RequireConsentSwitch element.

I tried but failed to get it working with MonoDevelop under Windows at least with the .NET Runtime set to Mono.

Hi!

Thanks for the steps, brill support!

However, after the mods and open up MonoDevelop it won't build saying it can't find the NuGet.targets file even though it has the exact casing. Below is a screenshot to show the file names and the MD error.

I wonder if its because its in a hidden folder but permissions seem ok so a bit confused.

Screen Shot 2013-01-19 at 10 40 33

The error message looks to me as though the SolutionDir property is not being defined. I would expect the path to be shown in the error message without the $(SolutionDir) part. MonoDevelop does not define this property so it needs to be in the project file.

I had a quick look at your code on GitHub and managed to get it to restore the packages and compile, at least the Nancy.ViewEngines.Markdown project, by changing the case of the NuGet.targets import and NuGet.exe, and also fixing the SolutionDir property so it pointed to the correct solution folder:

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == 'Undefined'">....&lt;/SolutionDir>

It was pointing to the src folder ..\ originally.

I cannot reproduce the exact error message you are getting if I remove the SolutionDir property from the project file so the above change may not fix anything.

You can also fix the require consent problem by adding the package restore setting to your ~/.config/NuGet/NuGet.config file instead of modifying the NuGet.targets file:

<configuration>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>

I could not get the demo project to build since it uses the Microsoft.WebApplication.targets file.

Also I did tweak the solution file, dropping the version number down to 11, since I am using MonoDevelop 3.0.5 which does not recognise Visual Studio 2012 solutions. I think MonoDevelop 3.0.6 supports them but I have not upgraded yet.

Thanks really helpful!

I'm on 3.0.6 (I see there is an update available as well) so the VS verion number is OK but I also get the Microsoft.WebApplication.targets file issue. Is there a fix for this? Do I even need it?

You can probably tell I am complete noob with Mono so appreciate the help 😄

Microsoft.WebApplication.targets file seems to add some extra publishing tasks. You do not need them to compile if you are not publishing the application.

If you remove all the import elements that refer to the Microsoft.WebApplication.targets file, and fix the project reference to Nancy.ViewEngines.Markdown, the demo app compiles and you can debug it with MonoDevelop.

Thanks!

I also found this https://bugzilla.xamarin.com/show_bug.cgi?id=6327 and
copied v9.0 and called it v10.0, built and success!

Thanks :)

On 19 January 2013 17:26, Matt Ward notifications@github.com wrote:

Microsoft.WebApplication.targets file seems to add some extra publishing
tasks. You do not need them to compile if you are not publishing the
application.

If you remove all the import elements that refer to the
Microsoft.WebApplication.targets file, and fix the project reference to
Nancy.ViewEngines.Markdown, the demo app compiles and you can debug it with
MonoDevelop.


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-12457856.

I can confirm that this builds as well on osx as expected in the latest version of monodevelop (built from master)

NuGet 2.7 now includes a restore command line argument for NuGet.exe that can be used to restore all packages in a solution or those defined in a packages.config file.

NuGet.exe released August 22 does not support using this command line argument with mono. However the latest NuGet source code from the 2.7 branch, which includes a fix by Fei Ling, does allow this to work on Mono.

Added support for restoring NuGet packages in commit d573a57

There is now a Restore NuGet Packages menu option when a project or solution is selected that will run

NuGet.exe restore YourSolution.sln

The addin will ship with a version of NuGet.exe which supports restoring NuGet packages on Mono version 2.10.9 or above.