2

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.

3
  • 1
    Never met this issue before, have you checked if the Microsoft.Web.ImportAfter.targets file has been broken? Root element is missing always means the targets file has no <Project> tag in it. Also, is VS2019 and .net core 3.0.1 the only version in your current machine, any preview version in it? I didn't found same issue like this, but found some similar issues which are about VS-preview or .net sdk preview... Hope the info helps :) Commented Oct 9, 2019 at 11:29
  • I am wondering if it may have something to do with installing Blazor templates 3.0.0-preview9.19424.4 just before I updated VS2019. I shall check shortly Commented Oct 9, 2019 at 12:49
  • I just checked with dotnet --info and 3.0.100-preview-010184 SDK is installed Commented Oct 9, 2019 at 19:03

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi James, thanks for your sharing and please mark your reply as answer and that will help other community members who easier search this useful information, it just a reminder :)
1

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.

1 Comment

Completely uninstalling VS2019 is surely a bit extreme - I use it for a whole range of tasks, not just experimenting with new products like Blazor. I am assuming there is a fix for this problem that is out there somewhere - maybe updating VS2019 again will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.