Search code examples
c#.netblazormaui

Unable to Debug .NET Blazor MAUI on host Windows machine "This project needs to be deployed before we can debug"


OS Name: Microsoft Windows 10 Pro

OS Version: 10.0.19044 N/A Build 19044

Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.8.0

It works ok when debugging on my connected android device, but getting this error when trying to debug on windows: enter image description here

DEP1000: Cannot copy file "C:\Users\USER\.nuget\packages\microsoft.fluentui.aspnetcore.components\4.0.0\staticwebassets\Components\HorizontalScroll\FluentHorizontalScroll.razor.js" to layout "C:\Users\USER\Documents\Repositories\attendance-roll-app\AttendanceRollApp\AttendanceRollApp\bin\Debug\net8.0-windows10.0.19041.0\win10-x64\AppX\wwwroot\_content\Microsoft.FluentUI.AspNetCore.Components\Components\HorizontalScroll\FluentHorizontalScroll.razor.js". DirectoryNotFoundException - Could not find a part of the path 'C:\Users\USER\Documents\Repositories\attendance-roll-app\AttendanceRollApp\AttendanceRollApp\bin\Debug\net8.0-windows10.0.19041.0\win10-x64\AppX\wwwroot\_content\Microsoft.FluentUI.AspNetCore.Components\Components\HorizontalScroll\FluentHorizontalScroll.razor.js'.

This is my project structure. I'm using a Razor library project to try to reuse the UI later. enter image description here


Solution

  • According to the error screenshot you provided, you need to check the Deploy option of the Project contexts in Configuration Manager under Build option like below. Also, you can try to delete obj and bin folders.

    enter image description here

    DEP1000: Cannot copy file "C:\Users\USER.nuget\packages\microsoft.fluentui.aspnetcore.components

    For this error, this could be related with the path of the project is too long. You can try to copy the project to C:\ to see if it works.