dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

Dotnet watch and hot reload does not work in Linux projects when there is a dot in the folder name of the project #44010

Closed eskaufel closed 1 month ago

eskaufel commented 1 month ago

Describe the bug

dotnet watch does not work in Linux when running from a folders with a ., Like Web.Portal. There is an error message in the verbose log

dotnet watch πŸ•΅οΈ [2425a748-e8b3-4432-af2b-734aa3b059f2] Ignoring process '/home/user/dev/Web.Portal/bin/Debug/net9.0/Web.Portal.dll', expecting '/home/user/dev/Web.Portal/bin/Debug/net9.0/Web.Portal'

There is a workaround to change the assembly name

<PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <LangVersion>preview</LangVersion>
    <AnalysisLevel>preview-all</AnalysisLevel>
    <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <AssemblyName>WebPortal</AssemblyName>
</PropertyGroup>

I have only tested this on dotnet 9.0.0-rc.2, this was not a problem in dotnet 8.

To Reproduce

mkdir Web.Portal
cd Web.Portal
dotnet new blazor
dotnet watch --verbose

Log

dotnet watch ⌚ Working directory: '/home/user/dev/Web.Portal'
dotnet watch ⌚ Watching with Hot Reload.
dotnet watch πŸ”₯ Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
  πŸ’‘ Press "Ctrl + R" to restart.
dotnet watch ⌚ Running MSBuild target 'GenerateWatchList' on '/home/user/dev/Web.Portal/Web.Portal.csproj'
dotnet watch πŸš€ Launched '/home/user/.dotnet/dotnet' with arguments 'msbuild /nologo /home/user/dev/Web.Portal/Web.Portal.csproj /p:_DotNetWatchListFile=/tmp/tmpe5leHr.tmp /nologo /v:n /t:GenerateWatchList /p:DotNetWatchBuild=true /p:DesignTimeBuild=true /p:CustomAfterMicrosoftCommonTargets=/home/user/.dotnet/sdk/9.0.100-rc.2.24474.11/DotnetTools/dotnet-watch/9.0.100-rc.2.24474.11/tools/net9.0/any/DotNetWatch.targets /p:CustomAfterMicrosoftCommonCrossTargetingTargets=/home/user/.dotnet/sdk/9.0.100-rc.2.24474.11/DotnetTools/dotnet-watch/9.0.100-rc.2.24474.11/tools/net9.0/any/DotNetWatch.targets /p:_DotNetWatchTraceOutput=true': process id 78515
dotnet watch ⌚ Process id 78515 ran for 327ms.
dotnet watch ⌚ Watching 59 file(s) for changes
dotnet watch ⌚ Target process is '/home/user/dev/Web.Portal/bin/Debug/net9.0/Web.Portal'
dotnet watch ⌚ Configuring the app to use browser-refresh middleware
dotnet watch ⌚ dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
dotnet watch ⌚ Refresh server running at wss://localhost:42301,ws://localhost:39983.
dotnet watch πŸ”₯ HotReloadProfile: Default.
dotnet watch ⌚ [Web.Portal (net9.0)] Waiting for application to connect to pipe 2425a748-e8b3-4432-af2b-734aa3b059f2.
dotnet watch πŸš€ [Web.Portal (net9.0)] Launched '/home/user/.dotnet/dotnet' with arguments '[env:DOTNET_MODIFIABLE_ASSEMBLIES=debug] [env:DOTNET_WATCH_HOTRELOAD_NAMEDPIPE_NAME=2425a748-e8b3-4432-af2b-734aa3b059f2] [env:DOTNET_STARTUP_HOOKS=/home/user/.dotnet/sdk/9.0.100-rc.2.24474.11/DotnetTools/dotnet-watch/9.0.100-rc.2.24474.11/tools/net9.0/any/hotreload/Microsoft.Extensions.DotNetDeltaApplier.dll:/home/user/.dotnet/sdk/9.0.100-rc.2.24474.11/DotnetTools/dotnet-watch/9.0.100-rc.2.24474.11/tools/net9.0/any/middleware/Microsoft.AspNetCore.Watch.BrowserRefresh.dll] run': process id 78587
Using launch settings from /home/user/dev/Web.Portal/Properties/launchSettings.json...
Building...
dotnet watch πŸ•΅οΈ [2425a748-e8b3-4432-af2b-734aa3b059f2] Ignoring process '/home/user/dev/Web.Portal/bin/Debug/net9.0/Web.Portal.dll', expecting '/home/user/dev/Web.Portal/bin/Debug/net9.0/Web.Portal'
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5046
dotnet watch ⌚ Launching browser: http://localhost:5046/

Further technical details

.NET SDK:
 Version:           9.0.100-rc.2.24474.11
 Commit:            315e1305db
 Workload version:  9.0.100-manifests.cea95dba
 MSBuild version:   17.12.0-preview-24473-03+fea15fbd1

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  24.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /home/user/.dotnet/sdk/9.0.100-rc.2.24474.11/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0-rc.2.24473.5
  Architecture: x64
  Commit:       990ebf52fc

.NET SDKs installed:
  8.0.401 [/home/user/.dotnet/sdk]
  8.0.402 [/home/user/.dotnet/sdk]
  8.0.403 [/home/user/.dotnet/sdk]
  9.0.100-rc.2.24474.11 [/home/user/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.8 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.10 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.8 [/home/user/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.10 [/home/user/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [/home/user/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/user/.dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
mhehle commented 1 month ago

Can confirm this issue under manjaro using rider and dotnet 9.0.100-rc.2.24474.11

asaf92 commented 1 month ago

Duplicate of #43861 Fix implemented, but not included in RC2. I built the release/9.1xx branch and the fix works, but there are other errors when using "watch" (crashing processes/broken pipes)

eskaufel commented 1 month ago

@asaf92 thank you, not sure how I missed that. Will close this issue.