简体   繁体   中英

Blazor Server build error - new web application causes build errors

I recently installed Blazor as part of my Visual Studio Community 2019 version 16.3.2 installation. After creating a brand new Blazor Server web application in VS 2019 I have tried to run the app, only to get 3 errors in the build. The errors are:

  1. Error: Project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Microsoft.Common.targets\ImportAfter\Microsoft.Web.ImportAfter.targets" was not imported by "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets" at (6101,3), due to the file being invalid. OktaBlazorAspNetCoreServerSide C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Microsoft.Common.targets\ImportAfter\Microsoft.Web.ImportAfter.targets
  2. Error: Project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\Managed.Web\Microsoft.Web.Designtime.targets" was not imported by "C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk.Web.ProjectSystem\targets\Microsoft.NET.Sdk.Web.ProjectSystem.targets" at (42,5), due to the file being invalid. OktaBlazorAspNetCoreServerSide C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\Managed.Web\Microsoft.Web.Designtime.targets
  3. Error MSB4024 The imported project file "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Microsoft.Common.targets\ImportAfter\Microsoft.Web.ImportAfter.targets" could not be loaded. Root element is missing. OktaBlazorAspNetCoreServerSide C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets

I haven't encountered MSBuild errors like this before and I need some directions. I am using.Net Core 3.0.100. If I use dotnet run from the command line the project runs as expected.

Updating Visual Studio Community 2019 to version 16.3.3 seems to have fixed this problem. I can create a new Blazor Server application and build and run with no errors, using DotNET Core SDK 3.0.100 on Windows 10. I guess the update must have contained the necessary bugfixes to finally try out this new product.

I had some odd issues with Blazor applications with Visual Studio 2019. I had been running the preview versions of Visual Studio 2019 and installed the release version on top of that. Completely uninstalling VS2019 and reinstalling fixed everything for me. Not a great solution, but it did resolve the weirdness I was having.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM