Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Build failure with VS / MSBuild 16.8 #9

Closed
TimLariviere opened this issue Nov 12, 2020 · 8 comments
Closed

Build failure with VS / MSBuild 16.8 #9

TimLariviere opened this issue Nov 12, 2020 · 8 comments

Comments

@TimLariviere
Copy link

TimLariviere commented Nov 12, 2020

Hi,

After upgrading to Visual Studio 16.8 (MSBuild 16.8.1.52902), F# Android projects that previously were working started failing with the following message:

error FS3053(0,0): Error
    The type provider 'Xamarin.Android.FSharp.ResourceProvider' reported an:
        The type provider constructor has thrown an exception:
        [
            error CS1703: An assembly with the same identity 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has already been imported. Try removing one of the duplicate references.
            error CS1703: An assembly with the same identity 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has already been imported. Try removing one of the duplicate references.
        ]

If I apply what the error message recommends and remove both System and System.Numerics, it builds and runs fine once again.

Though, if I try to remove System and System.Numerics with VS 16.7.8 (MSBuild 16.7.2.52901), it won't compile.

parse error FS3053:
    error : The type provider constructor has thrown an exception: 
    [
        error CS1069: The type name 'GeneratedCodeAttribute' could not be found in the namespace 'System.CodeDom.Compiler'. This type has been forwarded to assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' Consider adding a reference to that assembly.
        error CS0234: The type or namespace name 'GeneratedCodeAttributeAttribute' does not exist in the namespace 'System.CodeDom.Compiler' (are you missing an assembly reference?)
    ]

Since we can't have a workaround that applies to all VS versions, it's rather annoying.
We already got several user reports for it in Fabulous: https://github.com/fsprojects/Fabulous/issues/813

Also, I see that a few pull requests were merged recently to this repo but not yet published to NuGet.
Any plans to release them in the future?

@pjcollins @jonathanpeppers @nosami

@TimLariviere
Copy link
Author

To reproduce:

  • dotnet new -i Fabulous.XamarinForms.Templates
  • dotnet new fabulous-xf-app -n VSBuildRepro
  • cd VSBuildRepro && msbuild (or open with VS and build the Android project)

@pjcollins
Copy link
Member

@TimLariviere we are planning on pushing an update to nuget.org soon, but in the interim could you try the latest package version to see if the problem is still present there? If so we'll need to investigate further.

To test v1.0.1, you can use the following NuGet.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="Xamarin.Android" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/Xamarin.Android/nuget/v3/index.json" />
  </packageSources>
</configuration>

https://dev.azure.com/xamarin/public/_packaging?_a=package&feed=Xamarin.Android%40Local&package=Xamarin.Android.FSharp.ResourceProvider&protocolType=NuGet&version=1.0.1

@TimLariviere
Copy link
Author

TimLariviere commented Nov 12, 2020

@pjcollins It doesn't seem to run the type provider.

2>FSC: warning FS3005: Referenced assembly 'C:\Git\Test\TestVS16_8_NewPackage\packages\Xamarin.Android.FSharp.ResourceProvider.1.0.1\lib\monoandroid81\Xamarin.Android.FSharp.ResourceProvider.Runtime.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\Properties\AssemblyInfo.fs(9,40): error FS0039: The type 'Android' is not defined.
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\Properties\AssemblyInfo.fs(9,40): error FS0039: The type 'Android' is not defined.
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\MainActivity.fs(19,63): error FS0039: The value, constructor, namespace or type 'Layout' is not defined.
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\MainActivity.fs(20,61): error FS0039: The value, constructor, namespace or type 'Layout' is not defined.

The code generating the errors:
Assembly.fs

// the name of the type here needs to match the name inside the ResourceDesigner attribute
type Resources = TestVS16_8_NewPackage.Android.Resource
[<assembly: Android.Runtime.ResourceDesigner("TestVS16_8_NewPackage.Android.Resources", IsApplication=true)>]

MainActivity.fs

type MainActivity() =
    inherit FormsAppCompatActivity()
    override this.OnCreate (bundle: Bundle) =
        FormsAppCompatActivity.TabLayoutResource <- Resources.Layout.Tabbar
        FormsAppCompatActivity.ToolbarResource <- Resources.Layout.Toolbar

TestVS16_8_NewPackage.zip

@bddckr
Copy link

bddckr commented Jun 20, 2021

This is still happening in VS 2019, 16.11.0 Preview 2.0. It gives the exact same warning, then seemingly never runs the provider:

warning FS3005: Referenced assembly 'C:\Projects\TestVS16_8_NewPackage\packages\Xamarin.Android.FSharp.ResourceProvider.1.0.1\lib\monoandroid81\Xamarin.Android.FSharp.ResourceProvider.Runtime.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found

Note that I have used the version 1.0.1 that has been released on NuGet.org. I made sure my Nuget.Config does not list the AzDo feed.

Details
Microsoft Visual Studio Community 2019 Preview
Version 16.11.0 Preview 2.0
VisualStudio.16.Preview/16.11.0-pre.2.0+31410.223
Microsoft .NET Framework
Version 4.8.04161

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA534
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019   16.11.61.6649
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.11.61.6649
Azure App Service Tools v3.0.0

C# Tools   3.11.0-2.21301.11+757770cf2b5fcc3ffa83db516f90f0d2366a92f0
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

CodeMaid   11.2.231
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Codist   5.11.0
This extension provides enhanced syntax highlighting, contextual toolbar and navigation bar for code editor, shows more details on quick info and marks interesting items on scrollbar margin.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

EditorConfig Language Service   1.17.288
Language service for .editorconfig files.

EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.

EditProj   1.0
This packages allows you to edit project and solution files without the need to unload them first.

Extensibility Message Bus   1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

F# Formatting   0.9
F# source code formatting using Fantomas.

F# Lint   0.5
Source code linting for F#.

File Icons   2.7
Adds icons for files that are not recognized by Solution Explorer

FormatCommand Extension   1.0
FormatCommand Visual Studio Extension Detailed Info

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Line Press   13d97f3e-75e2-4715-a444-715b5f39f0a4
Control the line-height of code lines, and compress empty or any unimportant lines. Have best of both worlds, more code view with no cram.

Markdown Editor   1.12.253
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.2
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   16.10.15 (552afdf)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   5.11.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Razor (ASP.NET Core)   16.1.0.2122504+13c05c96ea6bdbe550bd88b0bf6cdddf8cde1725
Provides languages services for ASP.NET Core Razor.

Rewrap Extension   1.0
Re-wraps comments and other text

SQL Server Data Tools   16.0.62105.11120
Microsoft SQL Server Data Tools

SubwordNavigation   1.5.0
Provides subword navigation for Visual Studio.

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

TabPath Extension   1.2.2
Shows file paths in tab titles.

TrimCopyPackage Extension   1.0
TrimCopyPackage Visual Studio Extension Detailed Info

TypeScript Tools   16.0.30526.2002
TypeScript Tools for Microsoft Visual Studio

Viasfora   4.3.195
Add color to your Visual Studio editor!

Visual Basic Tools   3.11.0-2.21301.11+757770cf2b5fcc3ffa83db516f90f0d2366a92f0
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Cross Platform Mobile Development (Android)   16.0.31306.167
Visual C++ for Cross Platform Mobile Development (Android)

Visual F# Tools   16.10.0-beta.21262.7+1b23bbeda88ea3cb9be9af777f4c99fa8663df81
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

Visual Studio Tools for Unity   4.11.0.0
Visual Studio Tools for Unity

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSColorOutput   2.73
Color output for build and debug windows - https://mike-ward.net/vscoloroutput

Xamarin   16.11.000.157 (d16-11@0e025f1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   16.10.0.115 (remotes/origin/c750fbf1bde3c720d077f51640fe197c6dac7cbe@c750fbf1b)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.10.5 (355b57a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   11.3.99.54 (main/0e5e06f)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: c633fe9
    Java.Interop: xamarin/java.interop/main@a5ed891
    ProGuard: Guardsquare/proguard/v7.0.1@912d149
    SQLite: xamarin/sqlite/3.35.4@85460d3
    Xamarin.Android Tools: xamarin/xamarin-android-tools/main@683f375


Xamarin.iOS and Xamarin.Mac SDK   14.20.0.3 (17fdcf569)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

@gaelian
Copy link

gaelian commented Jul 22, 2021

@pjcollins It doesn't seem to run the type provider.

2>FSC: warning FS3005: Referenced assembly 'C:\Git\Test\TestVS16_8_NewPackage\packages\Xamarin.Android.FSharp.ResourceProvider.1.0.1\lib\monoandroid81\Xamarin.Android.FSharp.ResourceProvider.Runtime.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\Properties\AssemblyInfo.fs(9,40): error FS0039: The type 'Android' is not defined.
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\Properties\AssemblyInfo.fs(9,40): error FS0039: The type 'Android' is not defined.
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\MainActivity.fs(19,63): error FS0039: The value, constructor, namespace or type 'Layout' is not defined.
2>C:\Git\Test\TestVS16_8_NewPackage\TestVS16_8_NewPackage.Android\MainActivity.fs(20,61): error FS0039: The value, constructor, namespace or type 'Layout' is not defined.

@TimLariviere did you find a solution for this? I've just run into a similar error message from an Azure Pipeline run:

AssemblyInfo.fs(9,39): Error FS0039: The type 'Android' is not defined.
MainActivity.fs(21,66): Error FS0039: The value, constructor, namespace or type 'Layout' is not defined.
MainActivity.fs(25,52): Error FS0039: The value, constructor, namespace or type 'Style' is not defined.

My project builds fine locally with VS 16.10.3.

@gaelian
Copy link

gaelian commented Jul 25, 2021

Bit more information on this one: in my project, I've determined that using Xamarin.Android.FSharp.ResourceProvider v1.0.1 results in the kind of errors mentioned in this issue. Downgrading to v1.0.0.28 allows the build to complete successfully.

Removing references to System and System.Numerics did not work for me with v1.0.1 of the package. v1.0.0.28 doesn't seem to mind those references remaining.

@nbevans
Copy link

nbevans commented Oct 19, 2021

This is a blocking issue. Building F# apps for Xamarin.Android is currently broken because of this key piece of infrastructure.

@TimLariviere
Copy link
Author

Xamarin.Android.FSharp.ResourceProvider appears to be no longer maintained.
Please use https://github.com/fabulousfx/FSharp.Android.Resource instead.

Has support for .NET Framework and .NET 6.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants