Skip to content
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

Error creating a "Blazor Web App" project with space in project name #52519

Open
vsfeedback opened this issue Dec 1, 2023 · 11 comments
Open
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. bug This issue describes a behavior which is not expected - a bug. feature-templates
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice]
Today I updated Visual studio community 2022 to the Preview version (17.9.0 Preview 1.1), I created a project with these characteristics:
Project Type: Blazor Web App
Frameworks: .NET 8.0
Authentication type: Individual accounts
Interactive render mode: None
Immediately after creation without making any changes I started the project, and this error appears in the browser console:
"Web%20Client.styles.css:1 Failed to load resource: the server responded with a status of 404 ()"
I checked, and this file does not appear in any folder of the project, I tried to delete and recreate the project, but I have the same problem, I also started Visual Studio as administrator, deleted and recreated the project, but it gives the same problem.


Original Comments

Feedback Bot on 11/28/2023, 04:53 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Dec 1, 2023
@ghost ghost added the Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. label Dec 1, 2023
@brianc36
Copy link

brianc36 commented Dec 1, 2023

I'm experiencing the same issue with Authentication type: None and Interactive render mode: Auto. It appears to be a CSS isolation bundling issue. However, I'm not finding a way to force the bundling to occur. I tried it using both Visual Studio Professional 17.8.2 and the VS Preview.

2023-12-01 16_39_26-Home — Mozilla Firefox

@surayya-MS surayya-MS changed the title Error creating a "Blazor Web App" project Error creating a "Blazor Web App" project with space in project name Dec 4, 2023
@surayya-MS surayya-MS added the bug This issue describes a behavior which is not expected - a bug. label Dec 4, 2023
@surayya-MS surayya-MS added this to the .NET 9 Planning milestone Dec 4, 2023
@ghost
Copy link

ghost commented Dec 4, 2023

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@surayya-MS
Copy link
Member

Thanks for contacting us. This is because you have spaces in the project name. It should work without spaces.

@brianc36
Copy link

brianc36 commented Dec 5, 2023

Sorry this has nothing to do with a blank in the project name. I created the project using the 'Blazor Web App template'. The only thing I entered was the name of BlazorApp. Everything else stayed the same. The interactive render mode is set to auto. When the project runs it gets a 404 trying to load the BlazorApp.styles.css.

I'm running this on:
Edition Windows 10 Enterprise
Version 21H2
Installed on ‎6/‎19/‎2020
OS build 19044.3693
Experience Windows Feature Experience Pack 1000.19053.1000.0

Using:
Microsoft Visual Studio Professional 2022
Version 17.8.3
VisualStudio.17.Release/17.8.3+34330.188
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

ASP.NET and Web Tools 17.8.358.6298
ASP.NET and Web Tools

Razor (ASP.NET Core) 17.8.3.2358002+8c7fb27bf8e8d4f9ff8080b624b35bca5e812e97
Provides languages services for ASP.NET Core Razor.

@brianc36
Copy link

brianc36 commented Dec 7, 2023

My hosting environment variable was set to Local. Changing to Development fixed the issue with the CSS not working. I'm not sure why when I launch the project it fails to pick up the environment from the launchsettings?

The project name never contained a space.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@PhilippJR
Copy link

Not sure, if it's really the same issue with hyphens, but could be.

@halter73
Copy link
Member

It's not exactly the same issue, but it's very similar, and we plan on addressing both at the same time.

@danroth27
Copy link
Member

Not sure, if it's really the same issue with hyphens, but could be.

The hyphen issue seems different. You can create a Blazor project with a hyphen in its name and that builds and runs fine. But if you then try to add a class to the project using VS, the added class uses the project name for the namespace, but you can't have a namespace with a hyphen in it, so the added class fails to compile. I think this is a VS issue, not a Blazor issue. @mkArtakMSFT I think we may need to reopen this VS feedback ticket and get it to the right team.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
@mkArtakMSFT mkArtakMSFT added External This is an issue in a component not contained in this repository. It is open for tracking purposes. vs labels Apr 16, 2024
@mkArtakMSFT mkArtakMSFT reopened this Apr 16, 2024
@mkArtakMSFT mkArtakMSFT removed External This is an issue in a component not contained in this repository. It is open for tracking purposes. vs labels Apr 16, 2024
@phenning
Copy link
Contributor

Not sure, if it's really the same issue with hyphens, but could be.

The hyphen issue seems different. You can create a Blazor project with a hyphen in its name and that builds and runs fine. But if you then try to add a class to the project using VS, the added class uses the project name for the namespace, but you can't have a namespace with a hyphen in it, so the added class fails to compile. I think this is a VS issue, not a Blazor issue. @mkArtakMSFT I think we may need to reopen this VS feedback ticket and get it to the right team.

I think this IS an issue with the blazor template specifically, as other templates all generate the proper RootNamespace element in the project file.

simple repro:

c:\repros
c:\repros> dotnet new blazor -o blazor-web
c:\repros> dotnet new razor -o razor-web

blazor-web.csproj has the following - note the dash in the rootnamespace (this is incorrect)

<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RootNamespace>blazor-web</RootNamespace>
    <AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
  </PropertyGroup>

</Project>

While the razor-web.csproj has - note how the rootnamespace has the proper safenamespace

<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RootNamespace>razor_web</RootNamespace>
  </PropertyGroup>

</Project>

I think this is due to the dashes being used in the Blazor.csproj.in file - the Blazor template is using a dash in the source name instead of Company.WebApplication1 like all the other templates are doing, this is causing the safenamespace to not generate properly by the value form

@danroth27
Copy link
Member

Thanks @phenning for explaining these details! We'll look at the hyphen issue then as part of this issue as originally planned.

@ghowardzoonou
Copy link

I came across this ticket via (maybe relevant):

SpecFlow includes hyphens from the Project name for the namespace references inside its generated feature class files on build. So invalid class syntax and plenty of build errors ensue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. bug This issue describes a behavior which is not expected - a bug. feature-templates
Projects
Status: 8.0.x
Development

No branches or pull requests

11 participants