dotnet / templating Goto Github PK
View Code? Open in Web Editor NEWThis repo contains the Template Engine which is used by dotnet new
Home Page: https://docs.microsoft.com/dotnet/
License: MIT License
This repo contains the Template Engine which is used by dotnet new
Home Page: https://docs.microsoft.com/dotnet/
License: MIT License
The matches are not anchored and so can match partial paths. Possibly other issues with overlap between what are meant to be disjoint match sets.
Update defaultinstalls to pull packages correctly again
There are many places in the code where invalid config is quietly ignored. It would be quite helpful to users to get diagnostic info about their config.
SimpleConfigModel.ProduceOperationSetup(SpecialOperationConfigParams, bool, ICustomFileGlobModel)
hard codes the condition evaluator to C++
.
ConditionalConfig.ConditionalSetup(ConditionalType, string, bool, bool, string)
hard codes the evaluator type for MSBuild (for cases where the selected conditional type is MSBuild)
This should be fixable by:
string EvaluatorName { get; }
to SpecialOperationConfigParams
(and reading it from the underlying configuration or defaults)defaultModel.EvaluatorName ?? "C++"
to ConditionalConfig.ConditionalSetup(ConditionalType, string, bool, bool, string)
instead of the hard coded C++
Any --debug:*
switches should not be shown in the output of --help
, but all other switches should be
Add --debug:help
to show only debug switches, but do not include that in --help
Add descriptions (and any other metadata) to each of the libraries so that the packages don't just say "Package Description" on the feed.
GlobalRunSpec stores the special RunSpec's in a dictionary, so the order defined in IRunnableProjectConfig.SpecialOperationConfig is lost. Make appropriate modifications to ensure the processing order is preserved.
postActions
does (keep evaluating conditions until one is true or no condition is specified) to determine the value to assignWhen I run dotnet --help
the first few lines are shown below.
c:\data\mycode\templating>dotnet --help
.NET Command Line Tools (1.0.0-preview5-004275)
Usage: dotnet [host-options] [command] [arguments] [common-options]
When I run dotnet new3 --help
the first few lines are
c:\data\mycode\templating>dotnet new3 --help
Usage: [arguments] [options]
To make this more consistent we should:
When I run dotnet new3 mvc --help
I see the following.
c:\temp\dotnetnew3>dotnet new3 mvc --help
MVC ASP.NET Web Application (C#)
Author: Microsoft
Options:
-au|--auth The type of authentication to use
None, Individual
Default: None
-uld|--use-local-db Whether or not to setup a local DB
bool - Optional
Default: false
From the dotnet new3 --help
the following are relevant during project creation.
-n|--name The name for the output being created. If no name is specified, the name of the current directory is used.
-o|--output Location to place the generated output.
It would be nice if we can pass these through so the user will see the full set of options they can pass during invocation.
This happens for all parameters, even when help
is specified
Input:
dotnet new3 empty -rv 1.1 --help -ffv net555
Output:
Empty ASP.NET Web Application
Author: Microsoft
Input param named [NetTargetFrameworkVersion] must be of data type = [choice] but was provided the invalid value = [net555]
Additional information:
Choice is invalid. Valid choices are: [net45,net451,net452,net46,net461,net462]
at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.DataTypeSpecifiedConvertLiteral(ITemplateParameter param, String literal)
at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.InternalConvertParameterValueToType(ITemplateParameter parameter, String untypedValue)
at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.ConvertParameterValueToType(ITemplateParameter parameter, String untypedValue)
at Microsoft.TemplateEngine.Edge.Template.TemplateCreator.ResolveUserParameters(ITemplate template, IParameterSet templateParams, IReadOnlyDictionary`2 inputParameters)
at dotnet_new3.New3Command.TemplateHelp(ITemplateInfo templateInfo, ExtendedCommandParser app, IReadOnlyDictionary`2 userParameters) in C:\Projects\templating\src\dotnet-new3\New3Command.cs:line 486
at dotnet_new3.New3Command.DisplayHelp(String templateNames, ExtendedCommandParser app, IReadOnlyDictionary`2 userParameters) in C:\Projects\templating\src\dotnet-new3\New3Command.cs:line 462
at dotnet_new3.New3Command.MaintenanceAndInfo(ExtendedCommandParser app, String templateName, Boolean& shouldExit) in C:\Projects\templating\src\dotnet-new3\New3Command.cs:line 313
at dotnet_new3.New3Command.<>c__DisplayClass4_0.<<Run>b__0>d.MoveNext() in C:\Projects\templating\src\dotnet-new3\New3Command.cs:line 120
Sources can have conditioned modifiers, but sources themselves should support conditions as well
We should show two examples of how to use the command when a list is displayed (unless the -l|--list switch was specified)
Remove the -d|--directory switch
Add a new switch -o|--output that accepts a path (relative or absolute)
The general purpose expression evaluator should be used for this as well - bitwise operators & value comparisons will need to be introduced
>dotnet-new3 classlib -h
LogMessage: Checking for updates...
LogMessage: Content generation time: 224.7369 ms
LogMessage: Primary Outputs (artifacts)
Give a message about no (or multiple) templates matching the specified search term, give possible corrections:
List templates that match the corrected forms for:
Also list if there are multiple matches
Make sure to add the "do you mean" type message & link it back to the user's input so it makes sense
Several items here:
$({0})
**/*.*proj
should use this new conditional evaluator instead of the existing Conditional
provider**/*.*proj
files should have a default attribute for evaluation called Condition
Condition="
<
), or earlier depending on the leading whitespace behavior</
is encountered, decrement the open element count and seek to the element end token >
<
is encountered, increment the open element count/>
is encountered, decrement the open element count0
, process the trailing whitespace behaviorflags
settings to disable and enable conditional
behavior for things like the default property groups, references to unresolved symbols should not be treated as false-y (as they are in the C++ style condition evaluator), instead, the expression (and originally matched conditional
token) should be emitted to the output stream if the expression contains any unresolved symbolsEx.
<root>
<element if="'$(variable)' == 'value'"/>
<element if="'$(variable)' != 'value'">
<child>
<grandchild />
</child>
</element>
</root>
If variable
== "value"
, the output would be
<root>
<element />
</root>
If variable
!= "value"
, the output would be
<root>
<element>
<child>
<grandchild />
</child>
</element>
</root>
Fixed by #79
Work for this is in progress in #28.
SimpleConfig and GlobalRunSpec are hard to follow and deal directly with the JSON for determining what to do. Fixing this involves:
In a future release, we'll add it back in cases where one or more templates have aliases
There will need to be some kind of a notion of what the result of a creation is so that consuming systems can add the artifact to the thing it was generated into (if required)
Two approaches come to mind:
This is a big item but will enable lookarounds in token matching. This will address ligershark/microsoft-templateengine#63
For things like running npm install
or what have you, templates should be able to suggest running actions if they're available and/or providing instructions on how to do this manually.
Actions should:
From dotnet new3 mvc --help
I see
Examples:
dotnet new3 mvc --auth None --use-local-db false
dotnet new3 mstest
dotnet new3 --help
Is the --use-local-db false
a relevant flag in the mvc template? I tried setting to true
and then to false
and the same content was produced.
Moved from https://github.com/dotnet/cli/3617 on behalf of @kichalla
userSecretsId
valueuserSecretsId
value should be different as they are different apps and can have different config values.
Not sure if this is hard coded, but I always see "userSecretsId": "aspnet-WebApplication-0799fe3e-6eaf-4c5f-b40e-7c6bfd5dfa9a",
when creating apps.
dotnet --info
output:
.NET Command Line Tools (1.0.0-preview2-003102)
Product Information:
Version: 1.0.0-preview2-003102
Commit SHA-1 hash: 0589496b98
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
Because of this, listing templates doesn't show locale specific.
Might need to use a full ILocalizationModel when working with template caches, instead of ILocalizationLocator.
When I run dotnet new3 --help
for arguments I see the following.
Usage: [arguments] [options]
Arguments:
template The template to instantiate.
I think it would be more consistent with dotnet --help
if we output the following.
Usage: [template] [options]
Arguments:
[template] Name of the template used for creation
[options] Options
Options:
-l|--list List templates containing the specified name.
-lang|--language Specifies the language of the template to create
-n|--name The name for the output being created. If no name is specified, the name of the current directory is used.
-o|--output Location to place the generated output.
-h|--help Displays help for this command.
Needs investigation
The templates that are in here (for testing) should be updated to the current template content
Currently, templates must be explicitly installed in order to compute the display information/runtime dependencies. It'd be great to have a way of having this information pre-computed and shipped with the binaries.
Something like:
Setting a preference for this particular host (host identifier/version specific)
dotnet new3 --set:preference language=F#
Setting a preference for all hosts that identify the same way as this one (host identifier specific)
dotnet new3 --host:set:preference language=F#
Setting a preference for all hosts (not specific to the current host identifier or version)
dotnet new3 --global:set:preference language=F#
When I do dotnet new3 --help
I see the following listed in options.
Options:
-l|--list List templates containing the specified name.
-lang|--language Specifies the language of the template to create
-n|--name The name for the output being created. If no name is specified, the name of the current directory is used.
-o|--output Location to place the generated output.
-h|--help Displays help for this command.
The -lang
description is the only one missing a period. I think it's better to remove the periods here though since dotnet --help
doesn't use periods either.
When an invalid choice is specified, show a message to that effect (and invoke the parameter error handler on the host) but don't stop execution in the parameter processor so that if the help switch has been specified, help is still shown.
If the template would be created & has a bad argument specified, creation should be prevented. This could be accomplished by validating parameters just before help or creation instead of during the parse.
Also, if the user explicitly specifies the default value for the parameter, it should be shown as the current value in help
We should accomodate versioning of environments that use semantic versioning to disambiguate their releases rather than a x.x.x.x
style version. To do that, we'll need to change this property to a string.
Ex. dotnet new3 asdfg
Would return an error like this
some text asdf some text
It should return text like this
some text "asdf" some text
The empty web template (current short name of emptyweb
) should just be web
High level summary of the current thinking:
*.netnew.json
should never be emitted as content(locale).netnew.json
if available, if a matching locale or property is missing, it should be taken from .netnew.json
(locale).netnew.json
should contain a localizations
property whose value is an object
(locale).netnew.json
applies to the current instantation, nothing changes(locale).netnew.json
) should become a set of Replacement
operationscopyOnly
), the file now needs to be processed, but only using the replacement operations without any other operations that would apply to the file based on any other pattern matchesThe comment is in this block of code in ConditionalConfig.CStyleLineCommentsConditionalSetup
// temporary - one time test
IOperationProvider uncomment = new Replacement("//", string.Empty, uncommentOperationId);
IOperationProvider reduceComment = new Replacement("////", "//", reduceCommentsOperationId);
Evaluate whether this should be here & either remove the comment or remove the code.
This comment was introduced with commit 03b6f1c on 10/13, but the code it applies to was introduced in commit 1c0d078 on 9/22
Currently the config system has to understand everything, delegating the settings read to the operation factory itself seems like a better approach
Spec is here https://docs.nuget.org/ndocs/create-packages/package-types#dotnetclitool
We'll need to send a PR to call out/standardize our package types
I have started to look into porting the ASP.NET MVC Boilerplate project template from a VSIX to dotnet new
. I have several questions:
dotnet new
or is it possible to somehow produce a dotnet new
NuGet package, as well as a VSIX? Should I support VS 15 and/or 2017?dotnet new3 -i C:\GitHub\templating\template_feed
to actually install the templates in that directory. Is dotnet new3
broken at the moment?.netnew.json
syntax, computed symbol syntax and learn how to create a package template? Are there any docs or more examples I can look at?dotnet restore
, dotnet build
, npm install
, gulp default
and start the MVC site using the TestHost
API to ensure that every feature combination works. How can I select features and run the templating engine programmatically in my functional tests?dotnet new
? If not, I'm thinking it would be fairly simple to write an electron app to do feature selection based on .netnew.json, would this be an interesting open source project to the tooling team at Microsoft? It would be nice to provide icons for each feature in .netnew.json.Please excuse the long list of questions, there is just a lot to templating :)
Show the alias command in help
Add the alias column to the template list iff at least one template has an alias
In some conditional processing situations, an extra newline is emitted.
See ConditionalTests.VerifyExcludeNestedConditionInNonTakenBranch() for additional notes.
See ConditionalTests.VerifyExcludeNestedCondition() for an example where an extra newline is emitted. The expected result should not have the trailing newline.
See ligershark/microsoft-templateengine#56 for what the additional defaults should be
Get the build to produce appropriately signed artifacts
Get the outputs of builds saved somewhere
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.