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

Dash in project name breakes loading css file #7759

Open
1 task done
E-niek opened this issue Mar 19, 2024 · 1 comment
Open
1 task done

Dash in project name breakes loading css file #7759

E-niek opened this issue Mar 19, 2024 · 1 comment

Comments

@E-niek
Copy link

E-niek commented Mar 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I create a project with a dash in the project name (e.g. ASPNET-Core), one css stylesheet in _Layout.cshtml won't be loaded. That is the ~/projectname.styles.css stylesheet. This happens only when you have a dash in your project name, because in _Layout.cshtml it changes the dash to an underscore.

This means that where _Layout.cshtml has to search for ' ~/ASPNET-Core.styles.css ', it IS searching for ' ~/ASPNET_Core.styles.css ', which is not working, because the css file is named with a dash.

You can easily fix this by manually changing the underscore to a dash, but it can be a little bit confusing if you don't know what is going on.

Expected Behavior

The dash should not be changed to an underscore in the _Layout.cshtml file.

Steps To Reproduce

Create two folder one with the name 'Project', and another with the name 'Project-Dash'.

Open both of the folder in a different VSCode window, and run in both projects:

dotnet new webapp

Once that is finished, run in both projects:

dotnet watch

Two webpages will open automatically, and you will see that the 'Project' page does look how it is supposed to look, but on the 'Project-Dash' page you will see that the footer is not at the bottom of the page. This is because the stylesheet ' ~/Project_Dash.styles.css ' can't be loaded, because it doesn't exist. Therefore, try changing the underscore to a dash, so you get
' ~/Project-Dash.styles.css '. Now, after dotnet watch reloads the page, you will see that the footer is on the place where it has to be, in both of the pages.

From:
Screenshot_2024-03-19_11-23-28

To:
Screenshot_2024-03-19_11-23-38

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

Editor: VSCode
Editor version: 1.87.2

Dotnet info:

.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.a7f084b6

Runtime Environment:
OS Name: artix
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /usr/share/dotnet/sdk/8.0.100/

.NET workloads installed:
Workload version: 8.0.100-manifests.a7f084b6
[android]
Installation Source: SDK 8.0.100
Manifest Version: 34.0.85/8.0.100
Manifest Path: /usr/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.android/34.0.85/WorkloadManifest.json
Install Type: FileBased

[maui-android]
Installation Source: SDK 8.0.100
Manifest Version: 8.0.7/8.0.100
Manifest Path: /usr/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.7/WorkloadManifest.json
Install Type: FileBased

Host:
Version: 8.0.2
Architecture: x64
Commit: 1381d5ebd2

.NET SDKs installed:
8.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.15 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

@captainsafia
Copy link
Member

@E-niek Thanks for reporting this issue!

I believe this is happening because of the interpolation rules the templating engine uses. I suspect that it removes dashes when it interpolates the project name into source files, but not when it generates filenames.

Transferring this to the templating repo in case they have any insights here.

@captainsafia captainsafia transferred this issue from dotnet/aspnetcore Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants