dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

[WebToolsE2E] After installing .NET SDK 9.0 RC2, an error "MSB4018: The "DefineStaticWebAssetEndpoints" task failed unexpectedly." in the Error List when create ASP.NET Core Web App (Razor Pages) or MVC 6.0/8.0 IndAuth project. #43407

Closed v-doyang closed 1 month ago

v-doyang commented 2 months ago

REGRESSION INFO: Worked in 17.11.2 and 17.12 Preview 2(which includes 9.0 RC1). Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2248967

TESTCASES AFFECTED AspNetCore80_WebApp_RazorPages_IndAuth_RegisterAndLoginAsync AspNetCore80_WebApp_MVC_IndAuth_CreateRunPublishAsync AspNetCore80_WebApp_RazorPages_IndAuth_CreateRunPublishAsync AspNetCore80_WebApp_MVC_IndAuth_RegisterAndLoginAsync AspNetCore60_WebApp_RazorPages_IndAuth_ScaffoldingAsync AspNetCore60_WebApp_MVC_IndAuth_CreateRunPublishAsync

INSTALL STEPS

  1. Clean machine: Win 11 x64 23h2 ENU
  2. Install VS Dev17.12 Preview 3 build main-35310.165. Branch channel

REPRO STEPS

  1. File > New> Project > ASP.NET Core Web App (Razor Pages) or ASP.NET Core Web App (MVC) > NET 6.0/8.0 >Individual Accounts >Create.

Note:

Error info: MSB4018: The "DefineStaticWebAssetEndpoints" task failed unexpectedly. System.InvalidOperationException: Fingerprint for 'C:\Users\TestUser.nuget\packages\microsoft.aspnetcore.identity.ui\8.0.7\staticwebassets\V5\css\site.css' is not defined. at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate() at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer`1 comparer) at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() WebApplication2 C:\Program Files\dotnet\sdk\9.0.100-rc.2.24460.10\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets 675

File: Microsoft.NET.Sdk.StaticWebAssets.targets

ACTUAL: There is an error in the Error List window. image

EXPECTED: There is no error in the Error List window.

Error message: Assert.Fail failed. (10:12.427) [Visual Studio Host (14764):ErrorListVerifier] Verification failed: Error list was expected to contain no errors. Actually Error List contains '1' items: error 'The "DefineStaticWebAssetEndpoints" task failed unexpectedly. System.InvalidOperationException: Fingerprint for 'C:\Users\TestUser.nuget\packages\microsoft.aspnetcore.identity.ui\8.0.7\staticwebassets\V5\css\site.css' is not defined. at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate() at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer`1 comparer) at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()' at Microsoft.NET.Sdk.StaticWebAssets.targets(675, 5), project 'WebApplication1'

Stack trace: at Microsoft.Test.Apex.DelayedAssertionVerifierSink.RerouteAssertion(String message) in D:\dbs\el\ddvsm\src\Omni\Apex\Framework\Verifier\DelayedAssertionVerifierSink.cs:line 431 at Microsoft.Test.Apex.DelayedAssertionVerifierSink.DoFinalAssertion() in D:\dbs\el\ddvsm\src\Omni\Apex\Framework\Verifier\DelayedAssertionVerifierSink.cs:line 240 at Microsoft.Test.Apex.ApexTest.TestCleanup() in D:\dbs\el\ddvsm\src\Omni\Apex\MsTestIntegration\ApexTest.cs:line 561 at Microsoft.Test.Apex.ExternalProcessHostTest`2.TestCleanup() in D:\dbs\el\ddvsm\src\Omni\Apex\MsTestIntegration\ExternalProcessHostTest.cs:line 136 at Microsoft.Test.Apex.VisualStudio.VisualStudioHostTest.TestCleanup() in D:\dbs\el\ddvsm\src\Omni\Apex\MsTestIntegration\VisualStudioHostTest.cs:line 236 at Microsoft.VisualStudio.Tests.WebTools.NetCore.IntegrationTests.WebAppMvcIndAuthTestBase.TestCleanup() in D:\dbs\el\ddvsm\src\Tests\WebTools\IntegrationTests\NetCore\BaseClasses\AspNetCore\WebAppMvcIndAuthTestBase.cs:line 220

v-elenafeng commented 2 months ago

Unloading and reloading resolved the warnings for me.

JamesNK commented 1 month ago

I also see this.

Severity    Code    Description Project File    Line    Suppression State   Details
Error (active)  MSB4018 The "DefineStaticWebAssetEndpoints" task failed unexpectedly.
System.InvalidOperationException: Fingerprint for 'C:\Users\jamesnk\.nuget\packages\microsoft.fluentui.aspnetcore.components\4.9.3\staticwebassets\Components\Anchor\FluentAnchor.razor.js' is not defined.
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate()
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Aspire.Dashboard, Aspire.Dashboard.Components.Tests C:\Program Files\dotnet\sdk\9.0.100-rc.2.24468.2\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets   675     
baronfel commented 1 month ago

Cc @javiercn for investigation

JamesNK commented 1 month ago

@javiercn I see this change went into 9.0 recently: https://github.com/dotnet/sdk/pull/43099

Could it have caused this issue?

JamesNK commented 1 month ago

I think this issue is pretty serious. I'm getting this error from a file in the Microsoft.FluentUI.AspNetCore.Components package. When I have RC2 installed, all references to that package in VS at design time are broken. There are many errors from C# and razor files about types not found. I assume the two problems are linked.

I can compile and run the app ok, but design time is busted. It's really annoying.

Downgrading to RC1 fixes both issues.

Code: https://github.com/dotnet/aspire. See the Aspire.Dashboard project.

v-elenafeng commented 1 month ago

Should be fixed in: https://github.com/dotnet/sdk/pull/43496.

v-doyang commented 1 month ago

Verify this bug on the latest .NET 9.0 RC2[9.0.100-rc.2.24470.13], it works well, so close this issue as Fixed.