Skip to content

VS 17.3.0 Preview 3.0 Generation failed: System.MissingMethodException: Method not found: 'System.ReadOnlySpan`1<Char> When LangVersion 8.0 or lower #9297

Closed

Description

@Rytisgit

Current behavior

Testing Uno.Samples on VS2022 preview 3 gives error when building projects with LangVersion 8.0 included in the .csproj file.

1>MSBUILD : error : Generation failed: System.MissingMethodException: Method not found: 'System.ReadOnlySpan`1<Char> Microsoft.IO.Path.GetFileName(System.ReadOnlySpan`1<Char>)'.
1>MSBUILD : error : 
1>MSBUILD : error : Server stack trace: 
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.IsFileNameMatch(String path, String pattern)
1>MSBUILD : error :    at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
1>MSBUILD : error :    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
1>MSBUILD : error :    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFilesForStep(RecursiveStepResult stepResult, RecursionState recursionState, String projectDirectory, Boolean stripProjectDirectory)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFilesRecursive(ConcurrentStack`1 listOfFiles, RecursionState recursionState, String projectDirectory, Boolean stripProjectDirectory, IList`1 searchesToExclude, Dictionary`2 searchesToExcludeInSubdirs, TaskOptions taskOptions)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFilesImplementation(String projectDirectoryUnescaped, String filespecUnescaped, List`1 excludeSpecsUnescaped)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.<>c__DisplayClass67_0.<GetFiles>b__1(String _)
1>MSBUILD : error :    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
1>MSBUILD : error :    at Microsoft.Build.Shared.FileMatcher.GetFiles(String projectDirectoryUnescaped, String filespecUnescaped, List`1 excludeSpecsUnescaped)
1>MSBUILD : error :    at Microsoft.Build.Internal.EngineFileUtilities.GetFileList(String directoryEscaped, String filespecEscaped, Boolean returnEscaped, Boolean forceEvaluateWildCards, IEnumerable`1 excludeSpecsEscaped, FileMatcher fileMatcher, Object loggingMechanism, IElementLocation includeLocation, IElementLocation excludeLocation, IElementLocation importLocation, BuildEventContext buildEventContext, String buildEventFileInfoFullPath, Boolean disableExcludeDriveEnumerationWarning)
1>MSBUILD : error :    at Microsoft.Build.Internal.EngineFileUtilities.GetFileListEscaped(String directoryEscaped, String filespecEscaped, IEnumerable`1 excludeSpecsEscaped, Boolean forceEvaluate, FileMatcher fileMatcher, Object loggingMechanism, IElementLocation includeLocation, IElementLocation excludeLocation, IElementLocation importLocation, BuildEventContext buildEventContext, String buildEventFileInfoFullPath, Boolean disableExcludeDriveEnumerationWarning)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, Project project, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
1>MSBUILD : error :    at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
1>MSBUILD : error :    at Uno.SourceGeneration.Host.ProjectLoader.LoadProjectDetails(BuildEnvironment environment, Dictionary`2 globalProperties) in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\ProjectLoader.cs:line 143
1>MSBUILD : error :    at Uno.SourceGeneration.Host.SourceGeneratorEngine.Generate() in D:\a\1\s\src\Uno.SourceGeneration.Engine.Shared\SourceGeneratorEngine.cs:line 85
1>MSBUILD : error :    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
1>MSBUILD : error :    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
1>MSBUILD : error : 
1>MSBUILD : error : Exception rethrown at [0]: 
1>MSBUILD : error :    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
1>MSBUILD : error :    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
1>MSBUILD : error :    at Uno.SourceGeneratorTasks.RemoteSourceGeneratorEngine.Generate(RemotableLogger2 logger, BuildEnvironment environment)
1>MSBUILD : error :    at Uno.SourceGeneration.Host.Server.GenerationServerHost.GenerateForCollection(EnvironmentPool collection, BuildEnvironment environment) in D:\a\1\s\src\Uno.SourceGeneration.Host\Server\GenerationServerHost.netframework.cs:line 61
1>MSBUILD : error :    at Uno.SourceGeneration.Host.Server.GenerationServerHost.RunGeneration(RunRequest request, CancellationToken cancellationToken) in D:\a\1\s\src\Uno.SourceGeneration.Host\Server\GenerationServerHost.cs:line 73
1>C:\Users\SuperPC\.nuget\packages\uno.sourcegenerationtasks\4.0.2\build\netstandard1.0\Uno.SourceGenerationTasks.targets(134,2): error : Generation failed, error code Rejected
1>Done building project "UnoChat.Client.Wasm.csproj" -- FAILED.

Expected behavior

The samples build successfully. If the LangVersion 8 is not supported, a better message when building to make troubleshooting easier.

How to reproduce it (as minimally and precisely as possible)

Add 8.0 to a .csproj file, these are included in some of the samples, I tested ChatSignalR and SkiaSharpTest, also fails when adding to a sample which doesn't include LangVersion.

Workaround

Update .csproj to use LangVersion 9 or higher

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

from ChatSignalR sample

<ItemGroup>
    <!-- Note that for WebAssembly version 1.1.1 of the console logger required -->
    <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.6" />
    <PackageReference Include="MVx.Observable" Version="2.0.0" />
    <PackageReference Include="Uno.UI.Lottie" Version="4.1.9" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
    <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" />
    <PackageReference Include="Uno.UI.WebAssembly" Version="4.1.9" />
    <PackageReference Include="Uno.UI.RemoteControl" Version="4.1.9" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.9" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="3.2.0" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.2.0" />
  </ItemGroup>

Affected platforms

Build tasks

IDE

Visual Studio 2022

IDE version

17.3.0 Preview 3.0

Relevant plugins

No response

Anything else we need to know?

No response

Activity

  1. added
    difficulty/tbd
    kind/bug
    triage/untriaged
    on Jul 16, 2022
  2. francoistanguay commented on Jul 16, 2022

    @francoistanguay
    Contributor

    What a great catch. Thank you, the team will investigate asap now that we have a repro!

  3. francoistanguay commented on Jul 19, 2022

    @francoistanguay
    Contributor

    So, team found the issue:

    The new msbuild shipped with 17.3 Preview 3 includes this commit where they bumped the System.Memory version: dotnet/msbuild@bfd80ab

    Our Source Gen Host therefore suddendly become incompatible because of that breaking change.

    If you do an bindingRedirect ,in this file it should start working again : "C:\Users\User.nuget\packages\uno.sourcegenerationtasks\4.0.2\build\host\net472\Uno.SourceGeneration.Host.exe.config"
    bindingRedirect

    Short term, we'll push an update to our Source Generation Host.

  4. artemious7 commented on Jul 20, 2022

    @artemious7
    Contributor

    Thanks, it did the trick!

    The file is in
    C:\Users\<user>\.nuget\packages\uno.sourcegenerationtasks\<your_version>\build\host\net472\Uno.SourceGeneration.Host.exe.config

    Here's the text to easily paste it:

          <dependentAssembly>
            <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
          </dependentAssembly>
    

    Save and restart Visual Studio

  5. francoistanguay commented on Jul 20, 2022

    @francoistanguay
    Contributor

    Thank you for the more accurate details!

  6. francoistanguay commented on Jul 23, 2022

    @francoistanguay
    Contributor

    The new Uno Source Generation host now tonains the updated dependency to System.Memory so the nuget should be updated to latest dev: https://www.nuget.org/packages/Uno.SourceGenerationTasks/4.1.0-dev.9

    The Uno Source Generator is an msbuild tasks used to generate C# code.
  7. pkar70 commented on Aug 18, 2022

    @pkar70
    Contributor

    So, when my app uses Uno 4.2.6, workaround presented here ("set LangVersion to 9") works. But for newer Uno versions this workaround doesn't work, and app doesn't compile.
    What should I do to be able to use Uno > 4.2.6?

  8. jeromelaban commented on Aug 18, 2022

    @jeromelaban
    Member
  9. added a commit that references this issue on Aug 26, 2022
  10. added a commit that references this issue on Oct 13, 2022
  11. added a commit that references this issue on Mar 14, 2023
  12. zipswich commented on Aug 10, 2025

    @zipswich

    Can't believe that the following was suddenly needed to fix a Uno.SourceGenerationTasks error in August 2025

      <PropertyGroup>
        <LangVersion>10.0</LangVersion>
      </PropertyGroup>
    

    I found this out after struggling for hours by trying all kinds of things related to SDKs, NuGet packages.
    I am using Uno.SourceGenerationTasks 4.2.0 refereced by Uno.UI 4.10.39

  13. github-actions commented on May 2, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  14. locked as resolved and limited conversation to collaborators on May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/tbdkind/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions