question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fix: ConfigurationGenerator is not generated in FluentUI

See original GitHub issue

This might very well be a user error, but i have failed to find out what i am doing wrong

🐛 Bug Report

ConfigurationGenerator is not generated Program.cs(13,35): error CS0103: The name ‘ConfigurationGenerator’ does not exist in the current context

💻 Repro or Code Sample

Using this docker image and template to make sure nothing else in setup is making problems.

FROM ubuntu:22.04
RUN apt-get update && \
    apt-get -y dist-upgrade && \
    DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install dotnet-sdk-6.0 dotnet-runtime-6.0 ca-certificates

WORKDIR /build
RUN dotnet new --install Microsoft.Fast.Templates.FluentUI::2.0.6
RUN dotnet new fluentuiblazorserver
  • Change Program.cs to use ConfigurationGenerator
builder.Services.AddHttpClient();

//builder.Services.AddFluentUIComponents();
//When using icons and/or emoji replace the line above with the code below
LibraryConfiguration config = new(ConfigurationGenerator.GetIconConfiguration(), ConfigurationGenerator.GetEmojiConfiguration());
builder.Services.AddFluentUIComponents(config);

builder.Services.AddSingleton<WeatherForecastService>();
  • Change build.csproj to only use .net 6.0 (did not get the -f to work ) and changed the propertygroup to
<PropertyGroup>
	<PublishFluentIconAssets>true</PublishFluentIconAssets>
	<FluentIconSizes>10,12,16,20,24,28,32,48</FluentIconSizes>
	<FluentIconVariants>Filled,Regular</FluentIconVariants>
	<PublishFluentEmojiAssets>true</PublishFluentEmojiAssets>
	<FluentEmojiGroups>Activities,Animals_Nature,Flags,Food_Drink,Objects,People_Body,Smileys_Emotion,Symbols,Travel_Places</FluentEmojiGroups>
	<FluentEmojiStyles>Color,Flat,HighContrast</FluentEmojiStyles>
</PropertyGroup>

Then dotnet build


root@2e3b8cfeb6bb:/build# dotnet build
Microsoft (R) Build Engine version 17.0.1+b177f8fa7 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
CSC : warning CS8032: An instance of analyzer Microsoft.Fast.Components.FluentUI.Generators.ConfigurationGenerator cannot be created from /root/.nuget/packages/microsoft.fast.components.fluentui/2.3.6/analyzers/dotnet/cs/Microsoft.Fast.Components.FluentUI.Configuration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/build/build.csproj]
/build/Program.cs(13,35): error CS0103: The name 'ConfigurationGenerator' does not exist in the current context [/build/build.csproj]
/build/Program.cs(13,82): error CS0103: The name 'ConfigurationGenerator' does not exist in the current context [/build/build.csproj]

Build FAILED.

CSC : warning CS8032: An instance of analyzer Microsoft.Fast.Components.FluentUI.Generators.ConfigurationGenerator cannot be created from /root/.nuget/packages/microsoft.fast.components.fluentui/2.3.6/analyzers/dotnet/cs/Microsoft.Fast.Components.FluentUI.Configuration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/build/build.csproj]
/build/Program.cs(13,35): error CS0103: The name 'ConfigurationGenerator' does not exist in the current context [/build/build.csproj]
/build/Program.cs(13,82): error CS0103: The name 'ConfigurationGenerator' does not exist in the current context [/build/build.csproj]
    1 Warning(s)
    2 Error(s)

🤔 Expected Behavior

Build without warning/error

😯 Current Behavior

CSC : warning CS8032: An instance of analyzer Microsoft.Fast.Components.FluentUI.Generators.ConfigurationGenerator cannot be created from /root/.nuget/packages/microsoft.fast.components.fluentui/2.3.6/analyzers/dotnet/cs/Microsoft.Fast.Components.FluentUI.Configuration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/build/build.csproj]
/build/Program.cs(13,35): error CS0103: The name 'ConfigurationGenerator' does not exist in the current context [/build/build.csproj]
/build/Program.cs(13,82): error CS0103: The name 'ConfigurationGenerator' does not exist in the current context [/build/build.csproj]

💁 Possible Solution

CSC : warning CS8032: An instance of analyzer Microsoft.Fast.Components.FluentUI.Generators.ConfigurationGenerator cannot be created from /root/.nuget/packages/microsoft.fast.components.fluentui/2.3.6/analyzers/dotnet/cs/Microsoft.Fast.Components.FluentUI.Configuration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/build/build.csproj]

Guessing i am missing something, but my attempts to fix it has failed

🔦 Context

Unable to use FluentNavMenu as it needs the icons (different setup, but same problem)

🌍 Your Environment

Ubuntu 22.04 (see ‘Repro or Code Sample’) for dockerfile

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
andreisaperskicommented, Jun 20, 2023

Microsoft.Fast.Components.FluentUI.Configuration references Microsoft.CodeAnalysis v4.5.0.0 (Microsoft.CodeAnalysis.CSharp v4.5.0.0 -> Microsoft.CodeAnalysis.Common v4.5.0.0), but the compiler shipped with .NET SDK 6.0 doesn’t have this version. The latest SDK (6.0.410) has Microsoft.CodeAnalysis v4.3.0.0. As a workaround, Microsoft.Net.Compilers.Toolset v4.5.0 reference can be added - it will force build of the project with a compiler shipped in the package.

    <PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.5.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>

It looks like the version of Microsoft.CodeAnalysis.CSharp in Microsoft.Fast.Components.FluentUI.Configuration could be downgraded to 4.2.0, it will resolve the issue at least for the majority 6.0.x SDKs. More robust option would be to implement different versions of the generator for different versions of Roslyn as Microsoft.Extensions.Logging.Abstractions does.

1reaction
vnbaaijcommented, Jun 20, 2023

@mattgoedde that is a deliberate error in the demo to show runtime verification :Screenshot_20230620-151301.png

Read more comments on GitHub >

github_iconTop Results From Across the Web

fix: Incomplete GetIconConfiguration() is generated if ...
Bug Report ConfigurationGenerator (src/Microsoft.Fast.Components.FluentUI.Configuration/ConfigurationGenerator.cs) adds code to populate ...
Read more >
Upgrading Microsoft.Fast.Components.FluentUI 1.6.0 to 2.1 ...
1 Answer 1 ... Adding Microsoft.Fast.Components.FluentUI to my server project as well solved the issue. Now the project loaded correctly.
Read more >
What's new in the Microsoft Fluent UI library for Blazor version ...
The easiest way to do this is by creating a new <PropertyGroup> and gather all the relevant and needed properties in there.
Read more >
Blazor fluent ui github. If you use the examples above this ...
Possible Solution Problem (?). status:blocked Any issue blocked by another … Bug Report ConfigurationGenerator not found Icon not rendered in output.
Read more >
Microsoft.Fast.Components.FluentUI 2.4.2
A set of Blazor components wrapping Microsoft's official Fluent UI Web Components. They implement the latest state of the Fluent design language, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found