Bug 45321 - NuGet generated .targets are not used at compile time
Summary: NuGet generated .targets are not used at compile time
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: 4.8.0 (C9)
Assignee: Ankit Jain
: 52574 ()
Depends on:
Reported: 2016-10-12 15:19 UTC by Matt Ward
Modified: 2017-03-03 21:35 UTC (History)
1 user (show)

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 GitHub or Developer Community 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:

Description Matt Ward 2016-10-12 15:19:53 UTC
When using a project with a project.json file that references a NuGet package with its own custom MSBuild .targets file the generated .nuget.targets files are not used at compile time.

Mono 4.9.0 version 4.9.0 (master/8d1a651 Mon Oct 10 14:11:22 EDT 2016)

To repro:

1) Git clone the following repo:


2) Open the solution in Xamarin Studio 6.1 and right click the Packages folder and click Restore

This generates the TestMSBuildNuGetImports.nuget.props and TestMSBuildNuGetImports.nuget.targets files. Running nuget restore from the command line does not do this (presumably because it is using NuGet v2)

3) From the command line run msbuild TestMSBuildNuGetImports.sln

Expected result:

A bin/debug/Test.1.2.3.nupkg is created.

No such file is created. It looks like the *.nuget.props and *.nuget.targets files are not imported by MSBuild. Possibly the NuGet.targets file is missing in Mono 4.9.0.
Comment 1 Ankit Jain 2016-10-14 21:08:50 UTC
This PR should fix it : https://github.com/xamarin/bockbuild/pull/25
Comment 2 Matt Ward 2016-11-15 14:52:23 UTC
project.json is being replaced with PackageReferences in .NET Core style projects so there is no plan to fix this. The recommendation is to not use project.json files and stay with packages.config files or switch to a .NET Core MSBuild based project instead.
Comment 3 Matt Ward 2017-02-24 16:15:32 UTC
This seems to be fixed with Mono 4.8.0 (mono-4.8.0-branch/e4a3cf3 Fri Feb 17 15:57:45 EST 2017) for both xbuild and MSBuild.
Comment 4 Bill Holmes 2017-02-24 22:01:13 UTC
*** Bug 52574 has been marked as a duplicate of this bug. ***
Comment 5 Matt Ward 2017-02-24 22:02:00 UTC
OK this works with a desktop .NET Framework project but not with Xamarin.iOS when using MSBuild. It does work with Xamarin.iOS if xbuild is used.

Marking this as not on roadmap. The NuGet.props/.targets files do not seem to be imported when building