Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding a cshtml file to a Blazor project results in multiple item groups getting added to the project file #16383

Closed
danroth27 opened this issue Mar 21, 2018 · 8 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@danroth27
Copy link
Member

VSIX version: 15.6.10124

Repro steps:

  • Create a new Blazor project
  • Add a new Razor View to the Pages folder using the VS item template
  • View the csproj file

Expected result:

  • No change to the csproj

Actual result:

<Project Sdk="Microsoft.NET.Sdk.Web;Microsoft.NET.Sdk.Razor/2.1.0-preview2-30230">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <RunCommand>dotnet</RunCommand>
    <RunArguments>blazor serve</RunArguments>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-30230" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.1.0-rc1-10117" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.1.0-rc1-10117" />
    <DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.1.0-rc1-10117" />
  </ItemGroup>

  <ItemGroup>
    <BlazorGenerate Remove="Pages\Todo.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <Content Remove="Pages\Todo.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <None Include="Pages\Todo.cshtml" />
  </ItemGroup>

</Project>
@rynowak
Copy link
Member

rynowak commented Mar 21, 2018

Yeah, it's not good if this is happening because it means that the item is going to be excluded from compilation.

@rynowak
Copy link
Member

rynowak commented Mar 23, 2018

Is it possible in this case that you renamed the file? I've seen this kind of thing happen when you rename a file to have some other file extension and then back to .cshtml

@danroth27
Copy link
Member Author

Not in this particular case. The repro steps are exactly as listed above.

@danroth27
Copy link
Member Author

I do see other oddities in the csproj file though when I copy an existing cshtml file within the same project and then rename it.

@danroth27
Copy link
Member Author

@SteveSandersonMS Can we get someone to take a look and figure out what is going on here?

floreseken referenced this issue in software-architects/learn-blazor Mar 27, 2018
@MisinformedDNA
Copy link
Contributor

I do see other oddities in the csproj file though when I copy an existing cshtml file within the same project and then rename it.

Seeing this as well.

@rynowak
Copy link
Member

rynowak commented May 9, 2018

OK thanks for the bump on this. I know it's annoying 😢.

@rynowak rynowak self-assigned this May 9, 2018
rynowak referenced this issue in dotnet/blazor Jun 1, 2018
This change should hopefully end the MSBuild craziness that happens when
you add a file to the project using the VS Add Item dialog.

VS apparently has a behavior that intentionally tries to make sure the
added file is only included in a single itemgroup. So when Blazor
defines an itemgroup at the top level of scope with the same members as
Content - VS does some gymnastics to prevent it working.

The workaround is to defer the initialization of our itemgroup.
rynowak referenced this issue in dotnet/blazor Jun 5, 2018
This change should hopefully end the MSBuild craziness that happens when
you add a file to the project using the VS Add Item dialog.

VS apparently has a behavior that intentionally tries to make sure the
added file is only included in a single itemgroup. So when Blazor
defines an itemgroup at the top level of scope with the same members as
Content - VS does some gymnastics to prevent it working.

The workaround is to defer the initialization of our itemgroup.
@rynowak
Copy link
Member

rynowak commented Jun 5, 2018

This should be fixed now in dev, and will be part of 0.4

SteveSandersonMS referenced this issue in SteveSandersonMS/BlazorMigration Nov 27, 2018
This change should hopefully end the MSBuild craziness that happens when
you add a file to the project using the VS Add Item dialog.

VS apparently has a behavior that intentionally tries to make sure the
added file is only included in a single itemgroup. So when Blazor
defines an itemgroup at the top level of scope with the same members as
Content - VS does some gymnastics to prevent it working.

The workaround is to defer the initialization of our itemgroup.
@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

4 participants