Creating visual studio template projects - visual-studio-2017

I created a project template as described here: vs create template When I created a new project using the template, source files haven't added to project. I am using visual studio 2017 community edition. Actually source files (.h and .cpp) are visible in the solution explorer but they are not included in the project folder. So when I try to open them, ide gives me this message: "The document cannot be opened. It has been renamed, deleted or moved."
Is this a bug ? How can I fix it ?

It seems this is a bug. I solved it like this:
Visual studio automatically generates a .zip file containing the template project settings. However in that .zip folder, it doesn't include source files. I manually added every source files to the zip. Then I added fallowing lines to the automatically generated "MyTemplate.vstemplate" file.
<TemplateContent>
<Project File="yourProjectName">
<ProjectItem>source.cpp</ProjectItem>
.
.
.
</Project>
</TemplateContent>
and it worked.

Related

How do I rename a Qt Visual studio project?

I want to rename my Qt Visual studio project. I tried renaming the project folder and the vcxproj files. I replaced all the instances of the old project name inside the vcxproj files manually. I also replaced all the instances of the old project name inside the qrc files. I have done this before with other non-Qt visual studio projects, and it has worked successfully. However, with this project I am getting the following error.
MSB4181: the "QtRunWork" task returned false but did not log an error. (qt_globals.target 293)
Can someone please tell me how to fix this?

I'm using Visual studio 2019 and my project's name ends with .Sln insted of .cpp

I'm new to programming I use visual studio 2019 and when I'm creating a new project the project's name always end with .Sln instead of .cpp
.sln is the file visual studio uses to organize the project. I believe you will find one or multiple .cpp files in your project directory.
.sln is a diminutive for solution, it's a Visual Studio executable that has some basic configurations like the VS version you are using, the project id, name, and things like that, as you execute this, it will open your .vcxproj that has all the global configurations of the project, .cpp file names, etc. and will open your project. If you look in your project folder you should have at least a .cpp file.
SLN is the solution file. It is used to compile the solution and other informations. You can add classes (.cpp/.h) in your project where you can write C++ code.

Visual Studio 2017 Project Template + VSIX: Image not included when creating a new project?

Working on my first VS 2017 project template, following these steps:
Created an empty class library project, the project includes an image in the root
Exported template - verified that the .zip file contains the image
Created a VSIX project and added the zip as the project template asset - verified that .vsix contains the image (after renaming it to zip)
After installing VSIX and creating a project from New Project, all seems to be well, except the image is not included in the project, i.e. the file is not there.
If it makes any difference, this is a .NET Core project targeting multiple frameworks (i.e. the image file is not explicitly specified in the project).
The .vstemplate file does contain it as a project item:
<TemplateContent>
<Project TargetFileName="ClassLibrary.csproj" File="ClassLibrary.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="false" TargetFileName="icon.ico">icon.ico</ProjectItem>
</Project>
</TemplateContent>
Any ideas what I may have missed?
Thanks!
In order for items to copy to the template-created project they must also be included in the .csproj file and Visible not hidden.
Is your icon.ico in your .csproj file too?

Visual Studio 2015 Project Templates (C++) won't create project file in specific location

I'm trying to find how to create my own VC++ project template with all parameters set up for future development. But suddenly I appeared to stuck at a little problem: VS2015 won't create given structure inside of the project folder.
That's how my directory looks like inside of .zip file used for templating inside of Visual Studio:
Project/%ProjectName%.vcxproj
Project/%ProjectName%.vcxproj.filters
Project/%ProjectName%.vcxproj.user
Src/Main.cpp
MyTemplate.vstemplate
To be precise, it won't place .vcxproj file into the
%created_project_folder%/Project
directory, but directly into
%created_project_folder%/
directory instead, ruining file dependencies specified inside of project file. E.g. "include ../Src/Main.cpp" won't work because it will seek for file in wrong location.
I attached link to my .zip file below.
https://fex.net/#!654242360762
You can try to copy that onto #user#\Documents\Visual Studio XXXX\Templates\ProjectTemplates folder and then create project in VS. Project file will be created on the root instead of custom location.

How do you compile and run a project in Visual Studio when you have multiple source and header files involved in the same project?

I mostly worked with linux env, new to visual studio. (If you are in Linux, you would use the make utility...) How do you compile and run a project in Visual Studio when you have multiple source and header files involved in the same project? I have main.cpp, and few other source and corresponding header files, and when i built the project, I couldn't see an output although the project compiled fine and 'exited gracefully'. How do I tell Visual Studio that these files are part of the project?
To do that:
Select Project -->
Add Existing Item....
You should be looking in the same directory where you saved the project/solution.
Highlight the .h and .cpp files: date.cpp, date.h and main.cpp
Select "Add" to add the files to the project.
Result: Once I added the 'main.cpp' and other files in the project, it works fine and I am able to view the output.
References:
1 [http://www.cs.uregina.ca/Links/class-info/210/Lab1_VCIntro/]