Dotnet watch fails after changes, after I moved my folders.
After I moved my folder (Without the use of “Refractor This”), i get the errors:
C:\Users\andre\Desktop\Pog grammering\C#\kitchen-app\Program.cs(1,18): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'WebKitchen' (are you missing an assembly reference?)
and
C:\Users\andre\Desktop\Pog grammering\C#\kitchen-app\Program.cs(50,32): error CS0246: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)
after i change something in my code and saves it with "Ctrl + S".
Now, i have actually found a "fix" for this. I go into my .csproj file and just comment out the ItemGroup:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="8.0.5" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Components\SharedComponents\AddedIngredients.razor" />
<AdditionalFiles Include="Components\SharedComponents\NoImageSelectedToast.razor" />
<AdditionalFiles Include="Components\SharedComponents\OnAfterRenderAsyncIngredientsComponent.razor" />
<AdditionalFiles Include="Components\SharedComponents\OnAfterRenderAsyncRecipesComponent.razor" />
<AdditionalFiles Include="Components\SharedComponents\PreviewRecipe.razor" />
<AdditionalFiles Include="Components\SharedComponents\RealTimeIngredientSearchBar.razor" />
<AdditionalFiles Include="Components\SharedComponents\RealTimeRecipeSearchBar.razor" />
<AdditionalFiles Include="Components\SharedComponents\StatusMessageToast.razor" />
</ItemGroup>
</Project>
Commented out version:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="8.0.5" />
</ItemGroup>
<!-- <ItemGroup>
<AdditionalFiles Include="Components\SharedComponents\AddedIngredients.razor" />
<AdditionalFiles Include="Components\SharedComponents\NoImageSelectedToast.razor" />
<AdditionalFiles Include="Components\SharedComponents\OnAfterRenderAsyncIngredientsComponent.razor" />
<AdditionalFiles Include="Components\SharedComponents\OnAfterRenderAsyncRecipesComponent.razor" />
<AdditionalFiles Include="Components\SharedComponents\PreviewRecipe.razor" />
<AdditionalFiles Include="Components\SharedComponents\RealTimeIngredientSearchBar.razor" />
<AdditionalFiles Include="Components\SharedComponents\RealTimeRecipeSearchBar.razor" />
<AdditionalFiles Include="Components\SharedComponents\StatusMessageToast.razor" />
</ItemGroup>-->
</Project>
The hot reload feature now works as before, but this does not feel like the right solution and will at some point come back to bite me in the ass.
Does anybody else have a more “graceful” solution?
- Best regards, Me :3
Please sign in to leave a comment.
To prevent the outdated binaries impacting the dotnet watch mechanism, have you tried to clean the solution after modifying the project structure? Which part of the solution was changed?