Template engine not renaming primaryOutputs paths
See original GitHub issueThis issue has been fixed in (#1566), but I can’t get it to work, here is my template.json:
{
"$schema": "http://json.schemastore.org/template",
"author": "Me",
"classifications": [
"Common",
"Console",
"C#8"
],
"identity": "ExampleTemplate.AsyncProject",
"name": "Example templates: async project",
"shortName": "new-template",
"sourceName": "$safeProjectName$",
"tags": {
"language": "C#",
"type": "project"
},
"primaryOutputs": [
{
"path": "/$safeProjectName$/$safeProjectName$.csproj"
}
],
"postActions": [
{
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}
when I am running dotnet new new-template -n NewProject
will receive following error:
Processing post-creation actions...
Running 'dotnet restore' on /$safeProjectName$/$safeProjectName$.csproj...
MSBUILD : error MSB1001: Unknown switch.
Switch: /$safeProjectName$/$safeProjectName$.csproj
For switch syntax, type "MSBuild -help"
Restore failed.
Post action failed.
Description: Restore NuGet packages required by this project.
Manual instructions: Run 'dotnet restore'
That’s because $safeProjectName$
not renamed to NewProject
.
dotnet new --debug:version
result:
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.404
Repo:
https://github.com/ccpu/dotnet-template-primaryOutputs-issue
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Using Primary Outputs for Post Actions · dotnet/templating ...
Renaming. When using renames in source modifiers, make sure that primary output path contains the filename after source based file rename is ...
Read more >Net Core 2.0 project template $safeprojectname
Let's say you only want to replace "Template" and not "Template.Tools.WebAPI", just change the value of SourceName to "Template".
Read more >Templating Projects On .NET Core. by Roman Patutin
To rename a project, we can use the framework's built-in functionality. It's enough to specify the sourceName and primaryOutputs keys to open ...
Read more >`Guids` section of `template.json` - GitHub
In this field you define the values shown as Tags in `dotnet new`|no| |`name`|The name for the template. This is displayed as the...
Read more >How to build a .NET template and use it within Visual Studio ...
When you create a new solution using this template every .csproj file and the .sln file will be renamed by the template engine...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ccpu this is a known issue and will be fixed in https://github.com/dotnet/templating/issues/2453. I will keep this ticket opened until fix is merged. Thank you.
I think problem is that primaryOutput thats with
/
: https://github.com/ccpu/dotnet-template-primaryOutputs-issue/blob/main/.template.config/template.json#L19 should be:Leaving issue open to consider doing some basic check that primaryOutput don’t start with
/
…