Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing custom template from local nupkg contains additional files

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:

  • _rels/.rels
  • [Content_Types].xml
  • The original nuspec file

The project template was created locally as a local NuGet package. See the flow of things in the screenshots Generating and installing project template and enter image description here

Can anyone tell me how I can prevent these additional files to be part of the project that is generated from my template?

like image 689
baumgarb Avatar asked Jun 26 '18 17:06

baumgarb


2 Answers

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;"/>
like image 181
alim Avatar answered Sep 23 '22 12:09

alim


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.

like image 40
CarlesD Avatar answered Sep 22 '22 12:09

CarlesD