Visual Studio 2022 Custom Project Template doesn't show after unzipping / zipping - visual-studio

I have created a new Project Template by exporting a project via Project -> Export Template. Opening Visual Studio now, I can see my template showing up.
I then went to
Documents\Visual Studio 2022\My Exported Templates
and moved the MyTemplate.zip to another folder. Went to
Documents\Visual Studio 2022\Templates\ProjectTemplates
and made sure that MyTemplate.zip is not in there as well.
Now when I open VS again, I can see that my template is not available anymore.
To counter check, I moved the zip back into Documents\Visual Studio 2022\Templates\ProjectTemplates , reopened VS and made sure that the template is visible again.
I then went ahead, extracted MyTemplate.zip and compressed it into a zip again (Right Click -> Compress to Zip). Now when I move that zip into Documents\Visual Studio 2022\Templates\ProjectTemplates and restart VS, the template does not show up.
Bottom line, I am unable to import any template that I have manually compressed into a zip archive, seems like something is happening to the zip during extract / compress. I have been testing this on Win 11 with the OOB zip tools as well as nanazip.

Did you try extracting your template project ZIP file?
I was struggling as well but as soon as I extracted my custom template project with the rest of the Default templates it started showing up.

VS template is looking for folders in the ..\Visual Studio 2022\Templates\ProjectTemplates\ not a zip file. If you want your template to show up, move its folder there.

In my case the problem was that I named the XML file .vstemplate. It needs to be something.vstemplate.

Related

How Do I Compile Copied and Pasted Files in a Visual Studio Project Solution?

I just created a new project in Visual Studio 2019 and copied a bunch of files into the source/repos/project directory but they don't compile. I am guessing that is because these files were not created using Visual Studio.
Is there an easy way to make sure that the Project compiles all files in the directory even if they were created elsewhere? Right now all the files that I pasted in are treated like hidden files and the build option is a greyed out "None" instead of "Compile."
The files in question are all folders, PHP files, CSS, Javascript, etc.
See screenshot
enter image description here

How can i load a template I have created in Visual Studio?

After creating a solution for a project, I exported it as a template. Now after exporting it automatically adds the template to my IDE and creates a ZIP file with all the project files and a .vstemplate extension file.
Now i am on another computer with visual studio and i wish to load this template and save it in the IDE, but i cannot find this option anywhere. The temporary solution i have is to open an empty web application and copy all the contents of the ZIP file not including the .vstemplate file. So my question is how can i load this template into my IDE?
When opening the vstemplate file in Visual Studio all i get is a text editor and XML data.
I am using Visual studio 2013 with Update 4.
Once you've exported your template, copy the entire ZIP file that was created to the folder C:\Users\[User Name]\Documents\Visual Studio 2013\Templates\ProjectTemplates. (You might want to use one of the provided subdirectories to keep your template organized.)
Restart Visual Studio, and then use the search bar in the New Project dialog to help you find the project template you just added.
For the record, it looks like using templates changes with VS2017. Your project template provider will have to publish via a new build mechanic, and it'll be a bit different than just dumping a .zip into a user folder:
Using Project/Item Templates:
https://learn.microsoft.com/en-us/visualstudio/extensibility/upgrading-custom-project-and-item-templates-for-visual-studio-2017
Create Project/Item Template:
https://learn.microsoft.com/en-us/visualstudio/extensibility/creating-custom-project-and-item-templates

VS2013 not adding Javascript generated from Typescript to project automatically

I'm using TypeScript for the first time. I'm using Visual Studio 2013 with update 4, Web Essentials with update 4, and have the latest version of TypeScript from Microsoft's website. However, following the tutorial doesn't work for me: when saving a TS file, it automatically compiles to JavaScript on the screen to the right of the code I typed, and a JS file is created in the folder. However, this file is not added to the project automatically. How can I set Visual Studio 2013 to automatically add generated JS files to the project?
How can I set Visual Studio 2013 to automatically add generated JS files to the project
Use a glob for your TypeScript folder i.e. modify your .csproj file to include:
<Content Include="client-src\**\*.*">
</Content>
Besides Basarat's answer which works, there's also another solution: not doing anything. TypeScript generates a JavaScript file, which automatically gets placed in the same folder as the TypeScript file. When in Visual Studio, right click the folder your TypeScript file is in, and select "open folder in file explorer". You should see that the folder holds both the TS file you made, and the JS file that got generated.
You do not need to add this JS file to your project folder inside Visual Studio: you can just reference it. If you have an MVC project with a Scripts folder that has a file called greeting.ts (the one you make in the TypeScript tutorial), the path would be "~/Scripts/greeting.ts". Instead, just use "~/Scripts/greeting.js" (ending with js instead of ts). Visual Studio is smart enough to figure it out from there. This works with bundles as well.

Visual Studio: How to automatically copy custom file to output directory only when publish website?

I got some files necessary for the hosting environment, e.g: robots.txt as in the attached image.
But I don't want to store them in Visual Studio solution, because they are not a part of my project, it will be confusing to have these under the solution folder or source control.
So, I am thinking is there anyway to let Visual Studio automatically copy these files from my custom location (e.g: D:\HostingPrepareForST\ ) to the output folder when I hit "Publish" to publish the website?

Visual Studio and TortoiseHg: folder not visible in VS

I created a C# project and added it to source control (mercurial). I can edit files in VS, commit it and push it using TortoiseHg. It goes to the server. When some one pulls they get the files.
In my visual studio I added a folder and a file inside that folder. I used TortoiseHg and it saw the new file in the new folder. I committed it and pushed it.
However, now someone pulled the latest code from the server - and they got the new file (it is visible through windows explorer), but when they open the solution in VS, they don't see the file.
Does someone have an idea what is wrong here? or things I should check? Thank you for the help.
P.S. I have visual studio 2010 express (so I can't use the VisualHg plugin).
Visual Studio caches changes to the solution and project until an explicit save or a build. In your comment:
In my visual studio I added a folder and a file inside that folder. I used TortoiseHg and it saw the new file in the new folder. I committed it and pushed it.
I see that an updated .sln or .vcproj file was not mentioned and checked in. Did you see an update to either of these files via TortoiseHg? If not, make sure to build or save your project after a change like this.
Did you make sure that the Visual Studio Project File or Solution file is being updated and committed?
VS solution contains projects and each project select managed files by metadata(***.vcproj file). It's not the way include all files from root directory.
So, your co-workers can see new added files by in following two ways.
1) share project file(***.vcproj)
2) manually add files in each person's VS instance.

Resources