Search code examples
visual-studiovisual-studio-2017visual-studio-templates

TargetFolderName with space character (char)


I'm using visual studio templates in order to build a custom visual studio template project. I'm trying to create a folder with a name «External Models» that has space char but the visual studio is creating a folder with the name «External%20Models» replacing the space by %20.

Follows my .vstemplate file:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">

<TemplateData>
   ...
</TemplateData>

<TemplateContent>

  <Project TargetFileName="Product.Models.csproj" File="Product.Models.csproj" ReplaceParameters="true">

    ...

    <Folder Name="GeneratedCode" TargetFolderName="GeneratedCode">
        ...
    </Folder>
    <Folder Name="External Models" TargetFolderName="External Models">
      <Folder Name="CorePatterns" TargetFolderName="CorePatterns">
        ...
      </Folder>
    </Folder>
  </Project>
</TemplateContent>

<WizardExtension>
    ...
</WizardExtension>

And the content of the .vsix files generated:

ual


Solution

  • I changed from this:

    <Folder Name="External Models" TargetFolderName="External Models">
      <Folder Name="CorePatterns" TargetFolderName="CorePatterns">
            ...
      </Folder>
    </Folder>
    

    To this, and start to work.

    <Folder Name="ExternalModels" TargetFolderName="External Models">
      <Folder Name="CorePatterns" TargetFolderName="CorePatterns">
            ...
      </Folder>
    </Folder>
    

    Explanation:

    It does not matter which folders are generated to create the .vsix installer. What is matter is TargetFolderName="External Models" tag name which will generate the project folder (during the Visual Studio->File->Create new project). By changing the Name="External Models" to Name="ExternalModels" and, in the template project that generate the .vsix, change the name of the folder "External Models" to "ExternalModels" everithing will work fine.