-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
VS inserts unwanted csproj items when copy/pasting .razor.css files #24790
Comments
@NTaylorMullen \ @ajaybhargavb do you happen to know how this needs to be resolved? |
Oh goodness, no idea. We'll have to query others who have more context. @davkean is this on the CPS front that handles this? |
To avoid unexpected behavior, VS is trying to avoid including a file multiple times in both None/Content. Looks like the SDK has them included under globs in None. What is the end result you are expecting? And what Item do you expect these css files to be under? |
We expect the csproj not to include any explicit references to these files individually. @javiercn, do you have an answer for "what Item do you expect these css files to be under?"? I would have thought The desired UX is the same as when copy/pasting a Do you think the problem is in the SDK with how it matches them with globs? Is there a recommended pattern we should follow for populating itemgroups in a different way to avoid having VS think it should update the csproj when copy/pasting items? |
It's hard to tell, can you paste the entire project? How did you add first css file originally? VS has a few rules:
I can't tell why the first |
Sure, I'm using .NET 5.0.100-rc.1.20407.13 and VS 16.8.0 Preview 1.0, and here's my entire csproj before adding any <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AnalysisLevel>4</AnalysisLevel>
</PropertyGroup>
</Project> FYI this project was created via Weirdly I can no longer repro this problem at all. I've tried creating @davkean @javiercn Unless either of you have ideas for what might repro this, I propose just to close it. If others encounter the issue perhaps they will discover repro steps. |
@SteveSandersonMS should this be closed now? |
No, we are investigating this. |
When resolving this, please check if #25841 is also resolved as I think it's the same underlying cause. |
Not sure if this will help but, the issue doesn't only occur when copy/pasting css files, but also when creating them.
I'm still unsure how to reproduce this at 100%. |
OK, I looked into this and found it has nothing to do with Blazor or the Razor SDK. I can repro the same problem with plain old Repro steps, based on VS 16.8.0 Preview 3.1:
Expected: <ItemGroup>
<None Remove="Program.cs.blah" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs.blah" />
</ItemGroup> Demo videoWhy this matters
@davkean Can you suggest where would be best to report this? Is this part of the project system something that you work on? |
See my comment here: #24790 (comment). This behavior is as per the original design.
There is likely something in the default globs for the SDK you are using that that includes .css files in the |
Here is the bug: By default, VS says The Web inherits the .NET SDK which says that .css files outside of What item type do you want these css? That will determine the owner of the bug. |
OK, thanks for clarifying. So if I follow this correctly, this issue will occur when a developer:
... because in both cases VS is trying to preserve the original file's categorisation. If so, the mechanics of the issue do make sense, so thanks very much for clarifying the details! To be honest I do question the design of trying to preserve the file type when pasting or renaming. It feels like it's a hangover from an earlier era where project files listed every single item. In the newer world where project files don't list every file explicitly but rather match based on patterns, it's really uncommon for any developer to want to create single-file exceptions to the normal build rules. I personally suspect it's far more common, when renaming a file, that the developer's intent is to change the file type, not to create a special exception where the file has a different type than implied by its extension/location. Apologies if I'm missing awareness of some common cases where people do want that, I just can't think of any from my own experience 😄
I don't want to change the build configuration. If What I would ideally like is for VS not to try to generate exceptions to these rules implicitly when people perform common gestures like copy or rename (similar to how VS Code does not do that). But I appreciate you may have reasons that I don't know about why it's important for VS to do so. |
@dotnet/aspnet-blazor-eng I'm closing this as external. |
Filed an internal issue to track this. |
I have a project with some
.razor.css
files. When copy-pasting them (e.g., to duplicate the file with a new name), it adds unwanted junk to the csproj. Currently I have got the following, which breaks compilation and has to be removed manually:The text was updated successfully, but these errors were encountered: