dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
492 stars 190 forks source link

the new blazor component or page auto add content remove config in csproj file #10667

Closed ArgoZhang closed 1 month ago

ArgoZhang commented 2 months ago

Is there an existing issue for this?

Describe the bug

  1. right-click on project
  2. add new item
  3. type a component name
  4. check the project file
  <ItemGroup>
    <Content Remove="Components\Data\UniCorrectionConfig.razor" />
  </ItemGroup>

  <ItemGroup>
    <UpToDateCheckInput Remove="Components\Data\UniCorrectionConfig.razor" />
  </ItemGroup>

  <ItemGroup>
    <_ContentIncludedByDefault Remove="Components\Data\UniCorrectionConfig.razor" />
  </ItemGroup>

it will be auto-generated. This is so annoying.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

vs2022 17.10.4

Anything else?

No response

davidwengier commented 2 months ago

@ArgoZhang could you share what type of project you have? Does this behaviour happen on a new blazer project created from the template?

ArgoZhang commented 2 months ago

@davidwengier thank you for reply this issue. the following is a repro video

https://github.com/user-attachments/assets/d00d79f1-834c-426e-955d-7f49748ad6f6

project info:

Microsoft.NET.Sdk.Razor

dotnet target framework

net6.0
davidwengier commented 2 months ago

Thanks @ArgoZhang but unfortunately these doesn't seem to be anything in that project file that would cause this problem, and when I create a new project using the same Sdk and target framework, and even adding the AspNetCore.App framework reference, the issue doesn't repro for me. Perhaps there is something like a Directory.Build.props file in your repo at a higher level that is causing an issue?

I wonder if it would be possible for you to share your project with us? If you want to do it privately you can email me directly at david.wengier@microsoft.com. I understand if that's not possible of course, so the other option would be to share a binlog with me privately? To get that, you can open a command prompt to the root folder of your solution and run dotnet build -bl. That will create a file called msbuild.binlog, and if you could email that through, it would be very helpful.

ArgoZhang commented 1 month ago

@davidwengier Thank you very much for getting back to me so quickly. I created a new project and this problem did not occur. But this problem has been bothering our team in my old project. I will send you the msbuild.binlog file by email.

ArgoZhang commented 1 month ago

@davidwengier

Thank you very much for your patience and support.

I had upgraded to v17.10.5. This issue has been fixed. I can't reproduce this issue.