I tried to exclude .vs folder from template following instructions at https://github.com/dotnet/templating/wiki/%22Runnable-Project%22-Templates#sourcesexclude-optional
but it does not work.
If I enter "exclude": ".vs/*/" I got following error:
Illegal characters in path.
Parameter name: path
at System.IO.Path.GetFullPath(String path)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.TemplateEngine.Utils.PhysicalFileSystem.OpenRead(String path)
at Microsoft.TemplateEngine.Edge.Mount.FileSystem.FileSystemFile.OpenRead()
at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.SimpleConfigModel.JTokenToCollection(JToken token, IFile sourceFile, String[] defaultSet)
at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.SimpleConfigModel.Evaluate(IParameterSet parameters, IVariableCollection rootVariableCollection, IFileSystemInfo configFile)
at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.CreateAsync(IEngineEnvironmentSettings environmentSettings, ITemplate templateData, IParameterSet parameters, IComponentManager componentManager, String targetDirectory)
at Microsoft.TemplateEngine.Edge.Template.TemplateCreator.<InstantiateAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.TemplateEngine.Cli.New3Command.<CreateTemplateAsync>d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.TemplateEngine.Cli.New3Command.<EnterSingularTemplateManipulationFlowAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.TemplateEngine.Cli.New3Command.<EnterTemplateManipulationFlowAsync>d__65.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.TemplateEngine.Cli.New3Command.<ExecuteAsync>d__66.MoveNext()
SDK is 1.0.4
The issue you're seeing is that if the value of one of the include/exclude/copyOnly properties is a string (rather than an array), it's assumed that the string is a file that contains a list of newline separated patterns. In the case that you're setting the exclude property on sources, it overrides the defaults, whereas you're looking to exclude something additional. Modifiers is the thing to use to include/exclude/change to copyOnly additional things while leaving the existing behaviors. I think what you'd want is actually this:
"sources": [
{
"modifiers": {
"exclude": [ ".vs/**" ]
}
}
]
Ok, I added that way,and now there is no error, but I have .vs folder inside my generated project. It's not excluded

I tried both
"sources": [
{
"modifiers": {
"exclude": [ ".vs/**/*" ]
}
}
and
"sources": [
{
"modifiers": {
"exclude": [ ".vs/**" ]
}
}
]
@seancpeters ideas? This is the 1.x CLI
I forgot to mention that this is a multiproject template.
I also tried to exclude Logs folder, which resides within some project in src folder like this
"sources": [
{
"modifiers": {
"exclude": [ ".vs/**/*", "**/Logs/**" ]
}
}
with no effect at all.
@neman - could you post the entire "sources" section of your templates?
This is entire sources section. There are no additional options. I was fine with defaults and just wanted to add modifers to default.
@neman I believe I see the problem now. The modifiers needs to be an array, like this:
"sources": [
{
"modifiers": [
{
"exclude": [ ".vs/**" ]
}
]
}
],
Please let us know if that works for you, or if it's still causing problems. Thanks!
It's working now. Good troubleshooting (how in the world did I miss that square bracket)
Most helpful comment
@neman I believe I see the problem now. The modifiers needs to be an array, like this:
Please let us know if that works for you, or if it's still causing problems. Thanks!