giraffe-fsharp / giraffe-template

A dotnet new template for Giraffe web applications.
Apache License 2.0
37 stars 22 forks source link

AppNamePlaceholder not being set #9

Closed nojaf closed 5 years ago

nojaf commented 6 years ago

I've created new project using dotnet new giraffe --UsePaket -o error-giraffe and ran the build.bat file.

C:\temp\error-giraffe>dotnet build src/error_giraffe
MSBUILD : error MSB1009: Project file does not exist.
Switch: src/error_giraffe

When I look into the src folder I see a folder named AppNamePlaceholder, while the bat file contains

IF NOT EXIST paket.lock (
    START /WAIT .paket/paket.exe install
)
dotnet restore src/error_giraffe
dotnet build src/error_giraffe

Are dashes a problem?

dustinmoris commented 6 years ago

Hmm good question... I have never tried that but this must be a dotnet templating issue then I believe...

Would be good to try the same with a non Giraffe template (e.g. MVC) and see how that works.

TheAngryByrd commented 6 years ago

Yeah this is a dotnet templating issue. I've had similar issues with my other templates.

TheAngryByrd commented 6 years ago

Related: https://github.com/dotnet/templating/issues/1168

dburriss commented 6 years ago

@nojaf Does this only happen when using a special character in the name like '_' or '-" or '.'?

nojaf commented 6 years ago

So I've just tried the 0.16 version and this didn't work at all.

PS C:\temp> dotnet new giraffe -o SSReact
The template "Giraffe Web App" was created successfully.
PS C:\temp> cd .\SSReact\
PS C:\temp\SSReact> ls

    Directory: C:\temp\SSReact

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         3/2/2018  10:39 PM                src
-a----         3/2/2018  10:39 PM             56 build.bat
-a----         3/2/2018  10:39 PM             56 build.sh
-a----         3/2/2018  10:39 PM            804 README.md

PS C:\temp\SSReact> .\build.bat

C:\temp\SSReact>dotnet restore src/SSReact
MSBUILD : error MSB1009: Project file does not exist.
Switch: src/SSReact

C:\temp\SSReact>dotnet build src/SSReact
MSBUILD : error MSB1009: Project file does not exist.
Switch: src/SSReact
magnushammar commented 6 years ago

The problem with hyphens is that Build.bat get the wrong path to the project file. Changing src/error_giraffe to src/error-giraffe is all that is needed.

The template engine correctly replaces all - with _ in sourceName (AppNamePlaceholder). Unfortunately the template for build.bat will pick up this change even though it's a path.

As far as I can see there is no elegant solution to this with the Template.Engine as the placeholder always is replaced with error_giraffe in code and error-giraffe in files & folders.

Things would be great if we could instruct Template.Engine to replace certain placeholders with sourceNameOriginal (unescaped). That way it would be a breeze to construct correct paths in code.

nojaf commented 6 years ago

Even without any hyphens whatsoever there are still problems on Windows. The last name I tried was SSReact.

magnushammar commented 6 years ago

That's strange. It works for me no matter how I install the template . To get a better picture of what's wrong.

PS C:\data> dotnet new giraffe -o SSReact The template "Giraffe Web App" was created successfully. PS C:\data> cd .\SSReact\ PS C:\data\SSReact> .\Build.bat


They all work for me
dustinmoris commented 5 years ago

Hi, the issue with underscores and hyphens is not really something that I am in control of therefore I will close this issue as there's no action I can really take to help with it. It's a general .NET templating issue which applies to all .NET Core templates and there's nothing unique about giraffe-template AFAIK.

Thanks for bringing it to attention though!