Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
I can reproduce this with the following solution: https://github.com/onovotny/SampleXamFormsWithNetStandard
The portable project in there is a .NETStandard library using the new (sdk style?) csproj format.
I do not get this error with PCL library (ie. File > New Project).
OK so some initial investigation below:
With a .xaml file the InitializeComponent method is defined in a generated file (e.g. obj/Debug/RootNamespace.MainPage.xaml.g.cs).
With a normal C# PCL project, with the Xamarin.Forms NuGet package installed, the generated .xaml.g.cs files are added to the list of source files in Project.OnGetSourceFiles so they are available for the type system and code completion.
At a lower level, the .xaml.g.cs files themselves are determined by running the targets that CoreCompileDependsOn defines. This includes the XamlG target provided by the Xamarin.Forms MSBuild targets. The XamlG targets will add the .xaml.g.cs files.
With a .NET Core project the CoreCompileDependsOn is currently not defined. It returns null so no project files are added here so the .xaml.g.cs files are not being made available to the type system. This results in the error in the text editor. Building the project works fine.
I suspect the problem is that the generated NuGet files (e.g. obj/ProjectName.nuget.g.targets) are not being used by the project model. These generated NuGet files have imports for the Xamarin.Forms MSBuild targets. The Xamarin.Forms MSBuild targets modify CoreCompileDependsOn so it depends on the XamlG target.
How are targets like ProjectName.nuget.g.targets imported into the main project by MSBuild?
Not sure. There are some NuGet.targets that get included by MSBuild Microsoft.NuGet.targets and Microsoft.NuGet.ImportAfter.targets but I do not see anything explicitly importing the nuget.g.targets or nuget.g.props files. Asked Ankit about this.
There is a fix for this on the d15-2-dotnetcore-imports-from-generated-nuget-targets branch. Still need to add a test for this.
Pull request for d15-2:
Fixed in version 220.127.116.1163 (d15-2)
Author: Matt Ward
Commit: 2bc0c06ca2da61c001a8d505dc96bc03fd75aa8e (mono/monodevelop)
Verified the bug on the latest build :-
Visual Studio for Mac Version Preview 10 (7.0 build 3111)
Xamarin.iOS Version: 10.10.0.31
Xamarin.Android Version: 18.104.22.168
Build Information :-
Screencast link :-
Hence marking the bug as verified.