'"WriteLinesToFile" task was not given a value for the required parameter "File"

Error MSB4044 The "WriteLinesToFile" task was not given a value for the required parameter "File". BlazorTutorial.Client C:\Program Files\dotnet\sdk\5.0.400\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets

 // !---Line that gives error
 <WriteLinesToFile
      File="%(_ServiceWorkerIntermediateFile.Identity)"
      Lines="/* Manifest version: $(_ServiceWorkerAssetsManifestVersion) */"
      Condition="'$(_ServiceWorkerAssetsManifestVersion)' != ''" />

I don't how to resolve this or don't know what other information have to share here. I looked over internet but couldn't find any information about this error.

Things i tried :

  • I tried update sdk version 5.0.3 to 5.0.4 but not worked.
  • Meaningless but updated visual studio.
  • I reverted project to working version from git still getting same error.
  • I tried open new project and there was no error.

Edit 1:

  • (@Nicola Biada thank you) Cleared project > exited visual studio > deleted bin and obj folders > opened project > rebuilded project > same error accurred

Solved but don't know why:*

// from server's program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
       Host.CreateDefaultBuilder(args)
           .ConfigureWebHostDefaults(webBuilder =>
           {       
                webBuilder.UseContentRoot(Directory.GetCurrentDirectory()); // Deleted this line
                webBuilder.UseWebRoot("wwwroot"); // And this
                webBuilder.UseStartup<Startup>();
           });

After that, deleted wwwroot folder at server side and magic become real error gone for good.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source