Allow sourceName to be used as source for casing generator
See original GitHub issueI’m after a way to get the lowercase version of the main template name. The below template configuration produces the issue with the below csproj file. Maybe I’ve got invalid syntax or an something else isn’t correct. I can’t just specify the lowercase name as the -n command because I want to support a mixed case for that parameter (e.g. I want the user to specify FooDomain instead of foodomain because of naming conventions).
To repro, you can use the following template config:
{
"$schema": "http://json.schemastore.org/template",
"author": "Blank",
"classifications": [
"Web",
"WebAPI"
],
"name": "Test",
"identity": "Test.Casing",
"shortName": "casing-test",
"sourceName": "ApplicationName",
"preferNameDirectory": true,
"tags": {
"language": "C#"
},
"primaryOutputs": [
{
"path": "ApplicationName.csproj"
}
],
"symbols": {
"sourceNameLower": {
"type": "generated",
"generator": "casing",
"parameters": {
"source":"sourceName",
"toLower": true
},
"replaces": "ApplicationNameLower"
}
},
"postActions": []
}
And a single file in the template content called “ApplicationName.csproj”:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Authors>Blank/Authors>
<Version>1.0.0</Version>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>dd663411-3e30-405b-85b6-be2f9b61bf95</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<ArtifactsDirectory>app</ArtifactsDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" />
</ItemGroup>
<!--
DeleteArtifacts target:
This target runs after clean.
-->
<Target Name="DeleteArtifacts" BeforeTargets="Package" Condition="Exists('$(ArtifactsDirectory)')">
<Message Importance="High" Text="Deleting artifacts directory '$(ArtifactsDirectory)''" />
<RemoveDir Directories="$(ArtifactsDirectory)" />
</Target>
<!--
Package target:
This target compiles the project in release mode and builds the docker container.
-->
<Target Name="Package">
<Message Importance="High" Text="Publishing release artifacts..." />
<Exec Command="dotnet publish -c Release -o $(ArtifactsDirectory)" />
<Message Importance="High" Text="Building docker container..." />
<Exec Command="docker build . -t ApplicationNameLower:latest" />
</Target>
</Project>
My expectation is that when a user runs dotnet new casing-test -n FooDomain
that they get a csproj called FooDomain.csproj with the Exec step in the Package target matching <Exec Command="docker build . -t foodomain:latest" />
. Currently, the part that says foodomain
is just left blank.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:19 (6 by maintainers)
Top GitHub Comments
@ardove
sourceName
is available inname
symbol. The following change is needed totemplate.json
:Any workarounds or news of a fix for this? I’d really like the lower case
sourceName
, so I can use it for a Docker tag which is required to be lower case.