Bug 58254 - dotnet restore fails to resolve Xamarin.Android.CSharp.targets
Summary: dotnet restore fails to resolve Xamarin.Android.CSharp.targets
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.4 (15.3)
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-07-19 19:00 UTC by Jon Douglas [MSFT]
Modified: 2018-04-05 19:54 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 for Bug 58254 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Jon Douglas [MSFT] 2017-07-19 19:00:35 UTC
*Description:

When trying to use `dotnet restore` on a Xamarin.Android project, it fails with the following error message:

C:\Users\dougl\Documents\Visual Studio 2017\Projects\App43\App43\App43.csproj(79,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.4\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Looking at the resolved $(MSBuildExtensionsPath) path which in this case is C:\Program Files\dotnet\sdk\1.0.4\Xamarin\Android\Xamarin.Android.CSharp.targets there does not exist such as file.

Rather the targets exist at the following resolved path:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets

I've also tried this with .NET Core 2.0 preview 2 bits and it seems to be the same behavior:

C:\Users\dougl\Documents\Visual Studio 2017\Projects\App43\App43\App43.csproj(79,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I believe this in theory would also happen in Xamarin.iOS as the targets will be missing.

*Version:

.NET Core 2.0.0 Preview 2

Microsoft Visual Studio Enterprise 2017 
Version 15.2 (26430.16) Release
VisualStudio.15.Release/15.2.0+26430.16
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Xamarin   4.5.0.486 (fec6f88)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.1.2 (9dbc4c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.37 (ad35de4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 1 Jon Douglas [MSFT] 2017-07-19 19:04:26 UTC
As a workaround, one would have to use msbuild via:

msbuild /t:restore MyApplication.sln

or

msbuild /t:restore MyApplication.csproj

However we all want to use that shiny new `dotnet restore` command!
Comment 2 Alexandre Izefler 2017-08-22 23:00:47 UTC
It worked for me.
Comment 3 Al Clark [MSFT] 2018-04-05 19:54:00 UTC
Changing importance to Enhancement Request.

For reference, here's a related Developer Community report:
https://developercommunity.visualstudio.com/content/problem/20550/cant-run-dotnet-restore.html