diff --git a/docs/Binding-and-project-context-evaluation.md b/docs/Binding-and-project-context-evaluation.md
index f4ce729bfa..a951d7936b 100644
--- a/docs/Binding-and-project-context-evaluation.md
+++ b/docs/Binding-and-project-context-evaluation.md
@@ -9,7 +9,7 @@ The feature is available for both `dotnet new` and Visual Studio.
The symbol binds value from external sources.
By default, the following sources are available:
-- host parameters - parameters defined at certain host. For .NET SDK the following parameters are defined: `HostIdentifier: dotnetcli`, `GlobalJsonExists: true/false`. Binding syntax is `host:`, example: `host:HostIdentifier`.
+- host parameters - parameters defined at certain host. For .NET SDK the following parameters are defined: `HostIdentifier: dotnetcli`, `GlobalJsonExists: true/false`, `WorkingDirectory: `. Binding syntax is `host:`, example: `host:HostIdentifier`.
- environment variables - allows to bind environment variables. Binding syntax is `env:`, example: `env:MYENVVAR`.
It is also possible to bind the parameter without the prefix as a fallback behavior: `HostIdentifier`, `MYENVVAR`.
@@ -37,6 +37,10 @@ The higher value indicates higher priority.
"HostIdentifier": {
"type": "bind",
"binding": "host:HostIdentifier"
+ },
+ "WorkingDirectory": {
+ "type": "bind",
+ "binding": "host:WorkingDirectory"
}
}
```
diff --git a/src/Microsoft.TemplateEngine.Edge/DefaultTemplateEngineHost.cs b/src/Microsoft.TemplateEngine.Edge/DefaultTemplateEngineHost.cs
index 98b198a587..1c893a25be 100644
--- a/src/Microsoft.TemplateEngine.Edge/DefaultTemplateEngineHost.cs
+++ b/src/Microsoft.TemplateEngine.Edge/DefaultTemplateEngineHost.cs
@@ -37,12 +37,16 @@ public DefaultTemplateEngineHost(
loggerFactory ??= NullLoggerFactory.Instance;
_loggerFactory = loggerFactory;
_logger = _loggerFactory.CreateLogger("Template Engine") ?? NullLogger.Instance;
+
+ WorkingDirectory = Environment.CurrentDirectory;
}
public IPhysicalFileSystem FileSystem { get; private set; }
public string HostIdentifier { get; }
+ public string WorkingDirectory { get; }
+
public IReadOnlyList FallbackHostTemplateConfigNames { get; }
public string Version { get; }
@@ -61,6 +65,9 @@ public virtual bool TryGetHostParamDefault(string paramName, out string? value)
case "HostIdentifier":
value = HostIdentifier;
return true;
+ case "WorkingDirectory":
+ value = WorkingDirectory;
+ return true;
}
return _hostDefaults.TryGetValue(paramName, out value);
diff --git a/src/Microsoft.TemplateEngine.Edge/PublicAPI.Shipped.txt b/src/Microsoft.TemplateEngine.Edge/PublicAPI.Shipped.txt
index bb4433c540..276f69f40b 100644
--- a/src/Microsoft.TemplateEngine.Edge/PublicAPI.Shipped.txt
+++ b/src/Microsoft.TemplateEngine.Edge/PublicAPI.Shipped.txt
@@ -267,3 +267,4 @@ static Microsoft.TemplateEngine.Edge.Template.InputDataStateUtil.GetInputDataSta
static Microsoft.TemplateEngine.Edge.Template.TemplateEqualityComparer.Default.get -> System.Collections.Generic.IEqualityComparer!
static Microsoft.TemplateEngine.Edge.Template.TemplateMatchInfoEqualityComparer.Default.get -> System.Collections.Generic.IEqualityComparer!
~Microsoft.TemplateEngine.Edge.FilterableTemplateInfo.ParameterDefinitions.get -> Microsoft.TemplateEngine.Abstractions.Parameters.IParameterDefinitionSet
+Microsoft.TemplateEngine.Edge.DefaultTemplateEngineHost.WorkingDirectory.get -> string!
\ No newline at end of file