I'm successfully creating and installing a custom project template using the pretty good instructions here. The template is installed successfully, however, when I create a new project based on this template the resulting folder contains three additional things I actually don't want to have there:
The project template was created locally as a local NuGet package. See the flow of things in the screenshots and
Can anyone tell me how I can prevent these additional files to be part of the project that is generated from my template?
I have faced with the same problem. Found the solution with nuspec file.
the nuspec file was like
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>XYZ.Template</id>
<version>1.0.7</version>
<description>
Creates the XYZ API Template
</description>
<authors>XYZ</authors>
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
<files>
<file src="**" exclude="**\bin\**\*;**\obj\**\*;**\*.user;"/>
</files>
</package>
The problem was file src expression. The **
expression will be include those files. Move your nuspec file to one folder above. Then change the following line.
<file src="api/**" exclude="**\bin\**\*;**\obj\**\*;**\*.user;"/>
You can exclude files. In your template.json:
"sources": [
{
"modifiers": [
{
"exclude": [ "[Content_Types].xml" ,"_rels/**", "Baumgarb.Demo.DemoWebApi.nuspec"]
}
]
}
]
But I would put all files that are not related to your template outside the template folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With