dotnet / dotnet/templating

Dash in project name breakes loading css file

Open
#7,759 1 comment 0 reactions 0 assignees View on GitHub
triage:transfer-to-sdk
Dominant language
No language data
Stars
1.7k
Forks
399
Avg merge
3d 5h
Merged PRs (30d)
39

Description

### Is there an existing issue for this?

- [x] 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](https://github.com/dotnet/aspnetcore/assets/121483853/434d2219-7c92-4824-98e8-eeae188e0f71)

To:
![Screenshot_2024-03-19_11-23-38](https://github.com/dotnet/aspnetcore/assets/121483853/655aed42-95e5-4673-b2dc-d3c48777c2fc)

### 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.