File referenced by ProjectItem is not created when new Project created

175 views Asked by At

Trying to create my first Project Template for a simple VS2015 C# project. But when I try to create a Project with it, one of the files - post_build.bat - is missing.

The content of the project template ZIP file is:

    AssemblyInfo.cs
    Class1.cs
    ImsProject.ico
    ImsProject.vstemplate
    post_build.bat
    ProjectTemplate.csproj

The ImsProject.vstemplate file contains the following TemplateContent:

      <TemplateContent>
        <Project File="ProjectTemplate.csproj" ReplaceParameters="true">
          <ProjectItem ReplaceParameters="true" TargetFileName="Properties\AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
          <ProjectItem ReplaceParameters="true" OpenInEditor="true">Class1.cs</ProjectItem>
          <ProjectItem>post_build.bat</ProjectItem>
        </Project>
      </TemplateContent>

Seems simple, but I must be doing something wrong.

1

There are 1 answers

0
user2577528 On BEST ANSWER

Stoopid me!

I was thinking the post_build.bat file was not present was because when I created a new project it did not appear in the Solution Explorer in Visual Studio.

However ... it was present in the folder containing the new project.

The problem was I hadn't created a entry in an ItemGroup in the ProjectTemplate.csproj file.

Adding

    <ItemGroup>
        <None Include="post_build.bat" />
    </ItemGroup>

solved the problem