Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Service Worker Asset Manifest path construction bug #25959

Closed
amis92 opened this issue Sep 16, 2020 · 12 comments
Closed

Blazor Service Worker Asset Manifest path construction bug #25959

amis92 opened this issue Sep 16, 2020 · 12 comments
Assignees
Labels
affected-few This issue impacts only small number of customers area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-pwa Issues related to building PWAs with Blazor investigate severity-minor This label is used by an internal tool

Comments

@amis92
Copy link

amis92 commented Sep 16, 2020

Describe the bug

When BaseIntermediateOutputPath is non-default, GenerateServiceWorkerAssetsManifest task fails.

To Reproduce

> dotnet new blazorwasm --pwa -o BlazorSwamPathBugRepro
> cd BlazorSwamPathBugRepro
> echo "<Project>
    <PropertyGroup>
        <BaseOutputPath>$(MSBuildThisFileDirectory)build/bin/$(MSBuildProjectName)/</BaseOutputPath>
        <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build/obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
    </PropertyGroup>
</Project>" > Directory.Build.props

Repro repo: https://github.com/amis92/BlazorSwamPathBugRepro

Exceptions (if any)

Exception stack trace C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: The "GenerateServiceWorkerAssetsManifest" task failed unexpectedly. [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\obj\Debug\net5.0\service-worker-assets.js'. [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at System.IO.File.Create(String path) [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at Microsoft.NET.Sdk.BlazorWebAssembly.GenerateServiceWorkerAssetsManifest.Execute() [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj] C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets(68,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\Users\Amadeusz\Source\Repos\BlazorSwamPathBugRepro\BlazorSwamPathBugRepro.csproj]

Further technical details

  • ASP.NET Core version: 5.0.100-rc.1.20452.10
  • Include the output of dotnet --info:
dotnet --info output
.NET SDK (reflecting any global.json):
 Version:   5.0.100-rc.1.20452.10
 Commit:    473d1b592e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\

Host (useful for support):
  Version: 5.0.0-rc.1.20451.14
  Commit:  38017c3935

.NET SDKs installed:
  2.1.809 [C:\Program Files\dotnet\sdk]
  3.1.402 [C:\Program Files\dotnet\sdk]
  5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version
    Version: 1.49.0 (system setup)
    Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
    Date: 2020-09-10T13:22:08.892Z
    Electron: 9.2.1
    Chrome: 83.0.4103.122
    Node.js: 12.14.1
    V8: 8.3.110.13-electron.0
    OS: Windows_NT x64 10.0.18363

Personal investigation

The issue seems to crop up in Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets which is part of Microsoft.NET.Sdk.BlazorWebAssembly in this repository:

<_ServiceWorkerAssetsManifestIntermediateOutputPath Condition="'$([System.IO.Path]::IsPathRooted($(BaseIntermediateOutputPath)))' == 'true'">obj\$(Configuration)\$(TargetFramework)\$(ServiceWorkerAssetsManifest)</_ServiceWorkerAssetsManifestIntermediateOutputPath>
<_ServiceWorkerAssetsManifestIntermediateOutputPath Condition="'$([System.IO.Path]::IsPathRooted($(BaseIntermediateOutputPath)))' != 'true'">$(IntermediateOutputPath)$(ServiceWorkerAssetsManifest)</_ServiceWorkerAssetsManifestIntermediateOutputPath>
<_ServiceWorkerAssetsManifestFullPath>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(_ServiceWorkerAssetsManifestIntermediateOutputPath)'))</_ServiceWorkerAssetsManifestFullPath>

First of all, when the BaseIntermediateOutputPath is rooted, it doesn't actually use any user-set path and instead just forces the path to be relative and arbitrary, which doesn't seem to be correct (but maybe I'm missing something):

obj\$(Configuration)\$(TargetFramework)\$(ServiceWorkerAssetsManifest)

However, the second case looks like it should work, except it doesn't seem possible for the BaseIntermediateOutputPath to not be rooted at that point, because of the following:

https://github.com/dotnet/sdk/blob/d7ee9e27927f11c7e1b8ad1f48bcbffd2ac7a000/src/WebSdk/Publish/Targets/Microsoft.NET.Sdk.Publish.targets#L74-L75

Additionally I'm concerned that the _ServiceWorkerAssetsManifestIntermediateOutputPath itself shouldn't be used at all in other targets in that file and it is (the failing task itself takes it as an input); instead the _ServiceWorkerAssetsManifestFullPath probably should be.

@pranavkm pranavkm added the area-blazor Includes: Blazor, Razor Components label Sep 16, 2020
@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone Sep 16, 2020
@ghost
Copy link

ghost commented Sep 16, 2020

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@SteveSandersonMS SteveSandersonMS added affected-few This issue impacts only small number of customers bug This issue describes a behavior which is not expected - a bug. severity-minor This label is used by an internal tool labels Oct 7, 2020 — with ASP.NET Core Issue Ranking
@ghost
Copy link

ghost commented Oct 9, 2020

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@Kylar182
Copy link

This started happening to me all the time after moving my project to 5. Cut my dev time to a total crawl.

@robauer
Copy link

robauer commented Dec 10, 2020

So - I'm guessing this isn't going to fixed anytime in the near future? What is the work around for this? This halts any work I can do in Blazor.

@Kylar182
Copy link

So - I'm guessing this isn't going to fixed anytime in the near future? What is the work around for this? This halts any work I can do in Blazor.

I just deleted all bin / obj folders in the project and did a clean / rebuild on the solution and it worked fine.

@andreatosato
Copy link

Same error here: https://github.com/andreatosato/azure-static-app-pushnotification/actions
When debug work well.
When build locally work well:

dotnet publish ./src/Client/Blazoring.PWA.Client.csproj -c Release -o blazor -f NET5.0

On Github action there is error!

@javiercn javiercn added feature-pwa Issues related to building PWAs with Blazor feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Apr 20, 2021
@SimonCropp
Copy link
Contributor

suspect related to #29939

@robauer
Copy link

robauer commented May 14, 2021

I deleted bin and obj files, Cleaned and Build - no change. Still have same issue.

@SteveSandersonMS
Copy link
Member

@javiercn Any idea if this is resolved with the 6.0 SWA updates?

@javiercn
Copy link
Member

I believe so

@pranavkm
Copy link
Contributor

pranavkm commented Nov 3, 2021

@javiercn
Copy link
Member

javiercn commented Nov 4, 2021

@pranavkm sign-off and merge when happy? dotnet/sdk#22463

@pranavkm pranavkm closed this as completed Nov 4, 2021
ASP.NET Core Blazor & MVC 6.0 automation moved this from 6.0-Docs & Infra to Done Nov 4, 2021
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affected-few This issue impacts only small number of customers area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-pwa Issues related to building PWAs with Blazor investigate severity-minor This label is used by an internal tool
Projects
No open projects
Development

No branches or pull requests

9 participants