question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code generation problem if project name contains "-" (dash, minus)

See original GitHub issue

Describe the bug

dotnet new mvc command produces faulty style reference if project name contains - character.

To Reproduce

Using cli version 6.0.2.

mkdir cloud-manager
cd cloud-manager
dotnet new mvc

Further technical details

The cli generated the project successfuly. But the _layout.cshtml file has a reference to “cloud_manager.styles.css” which needs to be “cloud-manager.styles.css”. So until changing the _ to -, the site doesn’t look properly due to a 404 error.

The generator seems falsely to use root namespace name instead of project output name.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vlada-shubinacommented, Mar 23, 2022

Thanks for contacting us, @buraksarica. @vlada-shubina what do we put here to make sure that it matches the project name?

My recommendation is to change sourceName in template.json to Company.WebApplication.1 here(https://github.com/dotnet/aspnetcore/blob/f902dd8e154b2d20555a294ce83d21ddffaee8c4/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json#L24). Then in template content:

  • if the name should stay as entered by user, use Company.WebApplication.1 in the template, including here
  • if the safe namespace or safe class name should be used, use Company.WebApplication._1 and Company_WebApplication_1 respectively.

@sayedihashimi just a heads up, this issue is a good candidate to be included in template validation, happened already couple of times.

1reaction
mkArtakMSFTcommented, Mar 22, 2022

Thanks for contacting us, @buraksarica. @vlada-shubina what do we put here to make sure that it matches the project name?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are there problems with hyphens in functions, aliases, and ...
dash is the default shell ( /bin/sh ) on the debian-ubuntu family and it does not support hyphens in function names:
Read more >
[question] why names cannot contain dash '-' · Issue #479
For example, the majority of programming languages don't support - inside property names so it will make code/typings generation harder.
Read more >
Java Package with hyphen in name - import
No, I can't change the package name, I'm getting an: error '.' expected . The line giving the error is: import poof-support.exception;. java ......
Read more >
values containing dash - not evaluated
but there is no error and i get return values as if there really does not exist this filed. the column name is...
Read more >
Are there semantic differences using a dash '-' vs. an ...
The dash symbol (ASCII code = 45 or 0x2D) usually means minus, not dash. So programming languages does not allow this symbol in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found