Home > Blockchain >  Apply properties to every project you create in Visual Studio
Apply properties to every project you create in Visual Studio

Time:07-04

I'm trying to learn C 20 but I need to enable std:c latest everytime I create a project in Visual Studio 2022. Is there a way I can enable it for every project I create? Thanks in advance.

CodePudding user response:

Yes, you can achieve this by using a .props file that enables modification for default values or create your own template project.

If you want to enable full modification use the .props file. If not, use a new template.

Props file: File path is usually in the directory:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props

or in VS2022:

C:\Program Files\Microsoft Visual Studio\2022\Preview\Msbuild\Microsoft\VC\v170\Microsoft.Cpp.Default.props

Add for your desired condition or remove the condition:

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
   <ClCompile>
      <LanguageStandard>stdcpplatest</LanguageStandard>
   </ClCompile>
</ItemDefinitionGroup>

Read more in the docs to understand the project XML format: enter image description here

  • Related