stumit63
stumit63

Reputation: 61

How to stop Visual Studio from including x86 target in new projects

I remember when VS templates only included x86 targets and you had to add an x64 target manually. Now it generates both. Now I would like the reverse; x64 target generated and add x86 if needed. It's easy to delete the x86 configuration, but hey, I am a human so I'm lazy.

To me, the whole XML template tree is a bowl of spagetti. An answer to this question may help it become clearer.

Upvotes: 2

Views: 673

Answers (1)

stumit63
stumit63

Reputation: 61

I solved it by creating a new template and then modifying its .vcxproj file. Here are the steps to create a console app with x64 platform only.

  1. Create a new console project.
  2. Export it as a template. I called it console_64.
  3. Go to "C:\Users<user>\Documents\Visual Studio 2019\My Exported Templates". Here you will find the template zip file, in my case, console_64.zip.
  4. Extract the .vcxproj file.
  5. In the project file, delete all XML nodes that refer to Win32. These will be <ProjectConfiguration>, <PropertyGroup>, <ItemDefinitionGroup> and <ImportGroup> nodes.
  6. Save the file and update the zip overwriting the existing .vcxproj file in there.

Start a new VS session and voila! I now have a template, console_64, that creates a console solution with only the x64 target.

It will only save me a handful of mouse clicks per year yet I'd still like to know how to do it globally.

Upvotes: 3

Related Questions