question

BishopMinter-1198 avatar image
0 Votes"
BishopMinter-1198 asked RLWA32-6355 commented

I want to change the default settings for Visual Studio 2019

I would like to change the default settings in VS 2019. Specifically, I want to change

C/C++ settings:

the default Conformance Mode setting from Yes(/permissive-) to No(/permissive)
the default Preprocessor Definitions setting from WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
to WIN32;_DEBUG;_CONSOLE;_USE_32BIT_TIME_T;%(PreprocessorDefinitions)

Configuration Properties:

the default Working Directory setting from $(ProjectDir) to ..
the default Include Directories setting from $(VC_IncludePath);$(WindowsSDK_IncludePath);
to C:\DS\TEST\src\CPP;C:\DS\TEST\src\Header;$(IncludePath)

I've made a Property Sheet with the following settings:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">;
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>C:\DS\TEST\src\CPP;C:\DS\TEST\src\Header;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<ConformanceMode>false</ConformanceMode>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_USE_32BIT_TIME_T;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<PropertyGroup Label="Debugging Properties">
<LocalDebuggerWorkingDirectory>..</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<ItemGroup />
</Project>

When I create a new VS 2019 project I load this Property Sheet. When I open the Property Page for the project, the Configuration Properties, Include Directories and Working Directory, reflect the changes in my Property Sheet. The C/C++ settings, however, do not reflect the changes in my Property Sheet. The default settings are still there. If I change the settings in the Property Page to <inherit from parent or project defaults> for both settings the changes in my Property Sheet now show.

I would like for all 4 settings in my Property Sheet to reflect in the project Properties Page once I load the Property Sheet.

How can I accomplish this?


c++vs-setup
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered RLWA32-6355 commented

I don't recommend messing with Visual Studio's defaults for building C++ projects.

I think it is far safer to follow one of the following paths -

  1. Create your own custom project template. In your template set the properties that you want in the template's .vcxproj file. When a new project is created from your template it will have your desired settings in the project property pages. Consequently, you won't need a property sheet since all your desired setting will be contained in the .vcxproj file.

  2. Create your own custom project template. Don't set any properties in the template's .vcxproj file that you would obtain from a property sheet. Include a custom property sheet containing your desired settings in your template project. When a new project is created from this template it will have the desired settings that are present in the property sheet that is also part of the project. This option is more complicated and requires a better understanding of the build system than option1.

Refer to creating-project-and-item-templates


· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ok so I created a template and it works completely... almost. It loads every aspect I want in the new project save one. The working directory in the Debugging section. I want to change the working directory from $(ProjectDir) to .. but I cannot find an option for changing this either in the .vstemplate file nor the .vcxproj file. We're almost there. Just need this one last thing.

Ideas?

0 Votes 0 ·

Revisit the XML that was added to a property sheet for Debugging Properties at visual-studio-2019-settings-not-importing.html. Add that XML to the .vcxproj file in your template.


0 Votes 0 ·

Like a charm!

And BTW, for what it's worth, you are a wealth of knowledge and your help has been a tremendous boon to the progress of this project. You have my sincerest gratitude.

0 Votes 0 ·

Hit a small hiccup. My project directories have gotten messed up somehow. My include path is correct but when I create a new project it adds an extra folder to the path name. I'll explain:

My include path: C:\Main\TEST\src\CPP for my files

When I create a new project I tell VS to put it in C:\Main\TEST\

This is how I've been doing it this whole time. Even when I used the property sheet this was working as intended. But now when the project opens it doesn't open any of my files because it's looking here: C:\Main\TEST\TEST\src\CPP. It's adding another TEST folder for some reason. But when I tell VS to put the new project in C:\Main instead of C:\Main\TEST it will successfully open the files from the include path. But now the project is in C:\Main instead of C:\Main\TEST where I want it.

Where did I go wrong?

0 Votes 0 ·
Show more comments
PengGe-MSFT avatar image
0 Votes"
PengGe-MSFT answered RLWA32-6355 commented

Hi, @BishopMinter-1198

Welcome to Microsoft Q&A!

According to the inheritance tree in Property inheritance in Visual Studio projects, I created two projects for testing.I am afraid that if you want to match the settings in the project property page with the settings in the property sheet, you need to select <inherit in the project properties from parent or project defaults>.

I found custom c++ build, you can refer to this document.

Sincerely,
Peng


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@PengGe-MSFT I previously worked with @BishopMinter-1198 on property sheets as discussed here - visual-studio-2019-settings-not-importing.html. Will any use of the custom c++ build props files override the properties that are set in a .vcxproj file that is created by a new project template for C++?


0 Votes 0 ·

When a new project is created Visual Studio will create a folder for the solution file and a subfolder for the project files and source. This is the cause of the extra TEST folder that you have seen. This can be avoided by checking the box to place the solution file and project files in the same folder.
143126-folderpath.png

Having said that, the better answer is to not use hard-coded paths in the project template for the Additional Include Directories if they are created relative to the the new project's folder location. For example, if your project template creates folders and files under the folder containing the project file (.vcxproj) then use a VS macro like the following in the project template -

143096-includes.png

By using $(ProjectDir) the include paths will always be correct regardless of whether or not you allow VS to create a folder for the solution file.

0 Votes 0 ·
folderpath.png (18.9 KiB)
includes.png (21.6 KiB)