locked
Automatic way to change default name of the project template in VS RRS feed

  • Question

  • Hi,

    When we create a project template, it's created with default name MyTemplate.vstemplate. To change the name of the template file we have to manually change it's name.If there are many projects then it's a tedious task to change each template name.

    So, wanted to know Is there any way that I can change the name of project template file on it's creation or any other way rather than manually processing the things?


    Thursday, May 18, 2017 8:12 AM

All replies

  • Hi Yugank,

    >>So, wanted to know Is there any way that I can change the name of project template file on it's creation or any other way rather than manually processing the things?

    As far as I know, I could not change the file name via some setting. we could create a c# console app to change the name in the zip file. and I create a simple demo as below for your reference.

    using System.IO.Compression;
    
    namespace RenameFileNameInZip
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                string zipPath = @"F:\ColeWu\TestApp.zip";
    
                using (ZipArchive archive = ZipFile.Open(zipPath,ZipArchiveMode.Update))
                {
                    archive.RenameEntry("MyTemplate.vstemplate", "TestApp.vstemplate");
                }
            }
        }
    }
    

    #Extesion Class

    using System.IO;
    using System.IO.Compression;
    
    namespace RenameFileNameInZip
    {
        public static class ExtendExtension
        {
            public static void RenameEntry(this ZipArchive archive, string oldName, string newName)
            {
                ZipArchiveEntry oldEntry = archive.GetEntry(oldName),
                    newEntry = archive.CreateEntry(newName);
    
                using (Stream oldStream = oldEntry.Open())
                using (Stream newStream = newEntry.Open())
                {
                    oldStream.CopyTo(newStream);
                }
    
                oldEntry.Delete();
            }
        }
    }
    

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 26, 2017 8:04 AM