Definition
Assembly: CloudNimble.EasyAF.Tools.dll Namespace: CloudNimble.EasyAF.Tools.Scaffolding Inheritance: System.ObjectSyntax
Summary
Instantiates the .NET SDK’s built-in C# project templates (classlib, web, console)
in-process through Microsoft.TemplateEngine, without spawning dotnet new.
Remarks
Template packages are discovered the same way the SDK’s ownBuiltInTemplatePackageProvider finds them:
{dotnetRoot}/templates/{version}/*.nupkg, where {version} is the highest folder whose major version
matches the requested target framework. Template post-actions (such as restore) are not executed.
Constructors
.ctor
Initializes a new instance of the SdkTemplateHost class.Syntax
Parameters
.ctor Inherited
Inherited from
objectSyntax
Properties
SdkVersion
Gets the version of the SDK that supplied the templates in SdkTemplateHost.TemplateFolder (for example,10.0.401),
or null when it can’t be determined.
Syntax
Property Value
Type:string
Remarks
The SDK installs its common project templates asmicrosoft.dotnet.common.projecttemplates.{Major}.{Minor}.{SdkVersion}.nupkg,
so the version is read from that package name.
TargetFramework
Gets the target framework moniker projects are created for (for example,net10.0).
Syntax
Property Value
Type:string
TemplateFolder
Gets the resolved template version folder (for example,C:\Program Files\dotnet\templates\10.0.12),
or null when SdkTemplateHost.TemplatesRoot has no folder for the target framework’s major version.
Syntax
Property Value
Type:string
TemplatesRoot
Gets the folder containing versioned template package folders (normally{dotnetRoot}/templates).
Syntax
Property Value
Type:string
Methods
CreateProjectAsync
Creates a project from an SDK template.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<string>
The full path of the created .csproj file.
Exceptions
Dispose
Syntax
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
FindDotnetRoot
Finds the .NET installation root that owns thedotnet host, checking DOTNET_ROOT,
then DOTNET_HOST_PATH, then dotnet on the PATH.
Syntax
Returns
Type:string
The .NET installation root.
Exceptions
FindTemplatesRoot
Finds thetemplates folder of the .NET installation returned by SdkTemplateHost.FindDotnetRoot.
Syntax
Returns
Type:string
The full path of the templates folder.
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetMajorVersion
Gets the major version of a target framework moniker (for example,10 for net10.0).
Syntax
Parameters
Returns
Type:int
The major version.
Exceptions
GetMissingTemplatesAsync
Finds which of the given C# project templates are not available, so a caller can fail before creating anything.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>>
The short names with no matching C# project template, in the order given. Empty when all are available.
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- System.IDisposable