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
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-07-19 19:00 UTC by Jon Douglas [MSFT]
Modified: 2017-08-22 23:00 UTC (History)
2 users (show)

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


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.