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 for Bug 58554 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
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Changing the BaseIntermediateOutputPath property of a .Net Standard library that references Xamarin Forms, and has a Content Page template page in the project, to anything other than obj/ causes a cs0103 error oin build:
In a .Net Standard library that references Xamarin Forms and has a template ContentPage, changing the BaseIntermediateOutputPath property to anything other than obj/ causes a cs0103 error on build:
>/path/to/file/Page1.xaml.cs(4,4): Error CS0103: The name 'InitializeComponent' does not exist in the current context (CS0103) (TestFormsBIOP)
This occurs in either VS (Windows) or in VS (Mac). I saw this similar bug report, bug 55593, but that was noted to be fixed in the current stable version 15.2
## Steps to reproduce (Windows):
1. Open Visual Studio 2017 (Windows) and create a new .Net Standard Library
2. Add a reference to Xamarin Forms to the .Net Standard library
3. Add a Forms Content Page to the project
4. Build the project and it will succeed
5. Edit the .csproj file, adding the following to the <PropertyGroup>, e.g.:
6. Clean and rebuild the project.
Expected result: Project will build successfully.
Actual Result: Project fails to build with above error.
Once the BaseIntermediateOutputPath is changed to "hello/", you see a "hello" and a "bin" folder in the project directory as expected, so it appears the changed value is being respected.
Microsoft Visual Studio Enterprise 2017
Version 15.2 (26430.15) Release
Microsoft .NET Framework
Installed Version: Enterprise
Architecture Diagrams and Analysis Tools 00369-60000-00001-AA405
Microsoft Architecture Diagrams and Analysis Tools
Visual Basic 2017 00369-60000-00001-AA405
Microsoft Visual Basic 2017
Visual C# 2017 00369-60000-00001-AA405
Microsoft Visual C# 2017
Visual C++ 2017 00369-60000-00001-AA405
Microsoft Visual C++ 2017
Visual F# 4.1 00369-60000-00001-AA405
Microsoft Visual F# 4.1
Application Insights Tools for Visual Studio Package 8.6.00404.2
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2017 15.0.30503.0
ASP.NET and Web Tools 2017
ASP.NET Web Frameworks and Tools 2012 4.0.11203.0
For additional information, visit https://www.asp.net/
ASP.NET Web Frameworks and Tools 2017 5.2.50303.0
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 15.0.30209.0
Azure App Service Tools v3.0.0
Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.
Azure Data Lake Tools for Visual Studio 2.2.5000.0
Microsoft Azure Data Lake Tools for Visual Studio
Common Azure Tools 1.9
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Fabric Diagnostic Events
KofePackagePackage Extension 1.0
KofePackagePackage Visual Studio Extension Detailed Info
Merq 1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.
Microsoft Azure Hive Query Language Service 2.2.5000.0
Language service for Hive query
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 4.2.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
SQL Server Data Tools 15.1.61702.140
Microsoft SQL Server Data Tools
Hosting json editor into a tool window
TypeScript tools for Visual Studio
Visual C++ for Cross Platform Mobile Development (Android) 15.0.26228.00
Visual C++ for Cross Platform Mobile Development (Android)
Visual C++ for Cross Platform Mobile Development (iOS) 15.0.26228.00
Visual C++ for Cross Platform Mobile Development (iOS)
Visual Studio Tools for Universal Windows Apps 15.0.26430.06
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
Xamarin 22.214.171.1246 (fec6f88)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android SDK 126.96.36.199 (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.
=== Visual Studio Enterprise 2017 for Mac ===
Version 7.0.1 (build 24)
Installation UUID: f86726f2-bd5d-4610-867e-44e82f306ca2
Mono 188.8.131.52 (2017-02/5077205) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 500010001
=== NuGet ===
=== .NET Core ===
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 8.3.3 (12175.1)
=== Xamarin.Android ===
Version: 184.108.40.206 (Visual Studio Enterprise)
Android SDK: /Users/jongoldberger/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
SDK Tools Version: 26.0.2
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 26.0.0
Java SDK: /usr
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Android Designer EPL code available here:
=== Xamarin.iOS ===
Version: 10.10.0.36 (Visual Studio Enterprise)
Build date: 2017-05-22 16:30:53-0400
=== Xamarin.Mac ===
Version: 220.127.116.11 (Visual Studio Enterprise)
=== Build Information ===
Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2
=== Operating System ===
Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Thu Jun 15 17:36:27 PDT 2017
Created attachment 23997 [details]
Note that bug 55593 is unrelated to this particular bug. Bug 55593 was not a build error but an error shown in the text editor for the InitializeComponent method. The build worked there.
The problem seems to be that if the BaseIntermediatePath is set the generated .nuget.g.targets and .nuget.g.props files are not loaded so the XamlG task is never used. The generated .nuget.g.targets files are created in the BaseIntermediatePath directory.
If instead you only define the IntermediateOutputPath to be something different then the build works.
What is interesting here is that whilst the above IntermediateOutputPath is used for the generated MyView.xaml.g.cs files, and compiled binaries, the generated .nuget.g.* files are created in the obj directory. So my guess is that this is a NuGet build task problem. If the .nuget.g.* files are not in the obj directory then things breaks - the Xamarin.Forms msbuild imports are not used since the .nuget.g.* files are not used. A workaround here for the BaseIntermediatePath is to copy the .nuget.g.* files into the obj directory. Then the build works.
Also tried using dotnet restore when the BaseIntermediatePath is configured and the .nuget.g.* files are generated in the new BaseIntermediatePath directory.
This does not seem to be IDE specific. Using msbuild from the command line gives the same build error.
Attached a sample project that reproduces the build error.
MSBuild diagnostic output:
MSBuild diagnostic output when IntermediateOutputPath is defined instead.
Digging into this a bit more. The *.nuget.g.* files seem to be imported based on the MSBuildProjectExtensionsPath property. In both the MSBuild output in the previous comment this property is defined to be:
MSBuildProjectExtensionsPath = /Users/matt/Projects/Tests/NetStandardXamFormsTest/NetStandardXamFormsTest/obj/
This value seems to be defined by the Microsoft.Common.props:
The declaration of $(BaseIntermediateOutputPath) had to be moved up from Microsoft.Common.CurrentVersion.targets
in order for the $(MSBuildProjectExtensionsPath) to use it as a default.
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj\</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath Condition="'$(MSBuildProjectExtensionsPath)' == '' ">$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
Then later on this file then imports all ProjectFileName.*.props files from this directory which import the nuget.g.props.
<Import Project="$(MSBuildProjectExtensionsPath)$(MSBuildProjectFile).*.props" Condition="'$(ImportProjectExtensionProps)' == 'true' and exists('$(MSBuildProjectExtensionsPath)')" />
Presumably something similar happens for the nuget.g.targets files. I am assuming the importing of the .nuget.g.targets file is done via the .NET Core sdk's Microsoft.Common.targets since they seem to do that.
So I am guessing that the BaseIntermediateOutputPath is not defined when the MSBuildProjectExtensionsPath is set. Presumably based on when the imports are loaded. The only way I could get this to build on the command line with msbuild is to move the Sdk imports around so the BaseIntermediateOutputPath is defined before the first Sdk.props import:
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<PackageReference Include="Xamarin.Forms" Version="18.104.22.168" />
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
Unfortunately VS Mac does not support the above file format, which it probably should, however dotnet restore and msbuild work and are happy with it.
Looking into another bug I saw this GitHub issue which is basically the same bug we have here in bugzilla:
So another workaround here is to use a Directory.Build.props file in a folder above your projects, such as next to the solution. This seems to work with VS Mac 7.1 build 1294 with .NET Core 2.0 SDK installed. Not tested .NET Core 1.0.4 SDK installed on its own.