Fix RazorSourceGenerator flakiness (original) (raw)

Tests still failing due to RazorSourceGenerator problems. Latest one to fail was RazorPagesTemplate_RazorRuntimeCompilation_BuildsAndPublishes() in https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-aspnetcore-refs-heads-main-d5fff004899741f7a1/BlazorTemplates.Tests--net6.0/console.d0602f71.log and https://dev.azure.com/dnceng/public/_build/results?buildId=1035551

  Failed Templates.Test.BlazorWasmTemplateTest.BlazorWasmHostedPwaTemplate_Works(browserKind: Chromium) [1 m 28 s]
  Error Message:
   Project  failed to build. Exit code 1.
dotnet build --no-restore -c Debug /bl \nStdErr: \nStdOut: Microsoft (R) Build Engine version 16.10.0-preview-21126-01+6819f7ab0 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\MSBuild.dll -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\dotnet.dll -maxcpucount -property:Configuration=Debug -verbosity:m /bl .\AspNet.fkf0knjgsp1.Server.csproj
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  AspNet.fkf0knjgsp1.Shared -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Shared\bin\Debug\net6.0\AspNet.fkf0knjgsp1.Shared.dll
CSC : warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'AggregateException' with message 'One or more errors occurred. (Object reference not set to an instance of an object.)' [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\Program.cs(18,40): error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]

Build FAILED.

CSC : warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'AggregateException' with message 'One or more errors occurred. (Object reference not set to an instance of an object.)' [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\Program.cs(18,40): error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:07.70

Expected: True
Actual:   False
  Stack Trace:
     at Templates.Test.BlazorWasmTemplateTest.BlazorWasmHostedPwaTemplate_Works(BrowserKind browserKind) in /_/src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs:line 215
--- End of stack trace from previous location ---
  Standard Output Messages:
 Acquired DotNetNewLock
 Released DotNetNewLock
 Acquired DotNetNewLock
 ==> dotnet new blazorwasm --debug:custom-hive "Hives\.templateEngine" --hosted --pwa -o C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1 [C:\h\w\B38E09E0\w\B3C40981\e\]
 The template "Blazor WebAssembly App" was created successfully.
 This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details.
 
 Processing post-creation actions...
 Running 'dotnet restore' on C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\AspNet.fkf0knjgsp1.sln...
   Determining projects to restore...
 Process exited.
   Restored C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Server\AspNet.fkf0knjgsp1.Server.csproj (in 326 ms).
   Restored C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Shared\AspNet.fkf0knjgsp1.Shared.csproj (in 316 ms).
   Restored C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj (in 53 ms).
 Restore succeeded.
 
 Released DotNetNewLock
 Publishing ASP.NET Core application...
 ==> dotnet publish --no-restore -c Release /bl  [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Server]
 Microsoft (R) Build Engine version 16.10.0-preview-21126-01+6819f7ab0 for .NET
 Copyright (C) Microsoft Corporation. All rights reserved.
 
 C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\MSBuild.dll -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\dotnet.dll -maxcpucount -property:Configuration=Release -target:Publish -verbosity:m /bl .\AspNet.fkf0knjgsp1.Server.csproj
   You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
   You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
   AspNet.fkf0knjgsp1.Shared -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Shared\bin\Release\net6.0\AspNet.fkf0knjgsp1.Shared.dll
   AspNet.fkf0knjgsp1.Client -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\bin\Release\net6.0\AspNet.fkf0knjgsp1.Client.dll
   AspNet.fkf0knjgsp1.Client (Blazor output) -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\bin\Release\net6.0\wwwroot
   AspNet.fkf0knjgsp1.Server -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Server\bin\Release\net6.0\AspNet.fkf0knjgsp1.Server.dll
   AspNet.fkf0knjgsp1.Server -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Server\bin\Release\net6.0\AspNet.fkf0knjgsp1.Server.Views.dll
   Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
   Compressing Blazor WebAssembly publish artifacts. This may take a while...
   AspNet.fkf0knjgsp1.Server -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Server\bin\Release\net6.0\publish\
 Process exited.
 Building ASP.NET Core application...
 ==> dotnet build --no-restore -c Debug /bl  [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Server]
 Microsoft (R) Build Engine version 16.10.0-preview-21126-01+6819f7ab0 for .NET
 Copyright (C) Microsoft Corporation. All rights reserved.
 
 C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\MSBuild.dll -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\h\w\B38E09E0\w\B3C40981\e\sdk401\x64\sdk\6.0.100-preview.3.21160.5\dotnet.dll -maxcpucount -property:Configuration=Debug -verbosity:m /bl .\AspNet.fkf0knjgsp1.Server.csproj
   You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
   You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
   AspNet.fkf0knjgsp1.Shared -> C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Shared\bin\Debug\net6.0\AspNet.fkf0knjgsp1.Shared.dll
 CSC : warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'AggregateException' with message 'One or more errors occurred. (Object reference not set to an instance of an object.)' [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
 C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\Program.cs(18,40): error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
 
 Build FAILED.
 
 CSC : warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'AggregateException' with message 'One or more errors occurred. (Object reference not set to an instance of an object.)' [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
 C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\Program.cs(18,40): error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) [C:\h\w\B38E09E0\w\B3C40981\e\Templates\BaseFolder\AspNet.fkf0knjgsp1\Client\AspNet.fkf0knjgsp1.Client.csproj]
     1 Warning(s)
     1 Error(s)
 
 Time Elapsed 00:00:07.70
 Process exited.