In general, is there a way to change the default parameters of the various json (and other) config files used by Visual Studio (2017).
My specific case is when working on a cmake project, I would like the CMakeSettings.json to have the vcpkg toolchain parameter set automatically, whenever I open or creates a new cmake project.
Related
Is there any way of passing the list of source files, that Visual Studio would build, to a makefile. Ideally Visual Studio would set an environment variable with a list of the files to compile. But unfortunately I have not discovered such a variable. I know I could write a script to parse the project file but I would really like to find a method which does not rely on a script. I would like to be able to set up the Visual Studio project so that different source files are built depending on the build configuration, using the Exclude from Build option. I would then like the makefile to only build the files that were not excluded. I am attempting to use Visual Studio as the development environment for a project which runs on different hardware and OS combinations.
P.S. Using Visual Studio is non-optional, and not my personal choice.
Create a MakeFile project within the VS solution.
This should be found under File -> New -> Project -> Visual C++ -> Other -> Makefile Project
Using Visual Studio 2017, there is a MakeFile template that can be used.
Additional instructions on how to do so can be found here
I need to use cmake to generate visual studio sln file, BUT I want to ensure, that this generated *.sln file will not be connected with original CMakeFiles.txt (I want to generate sln file once).
I know that this is not typical usage and the connection with source CMakeFiles.txt is in standard usage perfect, but in my case it is not wanted -- I want to distribute these sln files (solution with projects) to some colleagues, who do not have CMake.
Maybe there is another approach (except cmake), to create few visual studio project without annoying clicking in Visual Studio.
Thanks,
Radek
I need to use cmake to generate visual studio sln file, BUT I want to
ensure, that this generated *.sln file will not be connected with
original CMakeFiles.txt
By design CMake will generate solution files that depend on CMake so this part is not really possible with CMake alone.
Maybe there is another approach (except cmake), to create few visual
studio project without annoying clicking in Visual Studio.
There is a way to stop regeneration in the IDE. I use this in many of my projects most likely for the same reason you do. At least with older versions of Visual Studio the regeneration caused dozens of prompts. Although I believe Visual Studio 2013 only prompts 1 time now I still enable this. The following code (inserted near the top of my root CMakelists.txt) is what I use to enable the option to suppress IDE regeneration.
option (CMAKE_SUPPRESS_REGENERATION "Suppress the cmake macro that causes regeneration of build scripts during build" ON)
I needed to build my software for several different platforms using Microsoft Visual C++ 2010 and MSBuild. I added the platforms to the $(VCTargetsPath) directory and created the .props and .targets files. I then copied the files to my configuration management repository, defined a path to the parent directory for the copied files: $(CM_REPO_PATH), and wanted to redirect visual studio to use the files in the repository.
I am able to get the project to work when I create an environment variable on my machine called %MSBuildExtensionsPath% and point it to $(CM_REPO_PATH)\MSBuild. What I want, though, is to set the $(VCTargetsPath) and/or $(MSBuildExtensionsPath) within the visual studio project, not in an environment variable on every developer's machine.
When I add the property group to do this...
<PropertyGroup>
<VCTargetsPath>$(CM_REPO_PATH)\MSBuild\Microsoft.Cpp\v4.0</VCTargetsPath>
<MSBuildExtensionsPath>$(CM_REPO_PATH)\MSBuild</MSBuildExtensionsPath>
<MSBuildExtensionsPath32>$(CM_REPO_PATH)\MSBuild</MSBuildExtensionsPath32>
</PropertyGroup>
...the new platforms are not available (as if the project is still using the default $(VCTargetsPath), rather than the one specified). Is there a way to override the $(VCTargetsPath) from the project file?
Your initial statement is, that you want to build your project for a number of different platforms.
https://learn.microsoft.com/en-us/visualstudio/extensibility/visual-cpp-project-extensibility?view=vs-2017 describes in very much detail, how to achieve this in Visual Studio 2017. Hopefully the same is true for the version you are using.
The good thing about this is, you don't need to alter $(VCTargetsPath) at all.
Visual Studio 2010 ("Project Properties" dialog)
I've installed Visual Studio 2010 Ultimate and it has apparently imported the default directories for my Win32 C++ includes and libraries. Every new Win32 C++ project I create automatically adds my old include/library directories which screws up my build.
So my question is this: How can I edit $(IncludePath) in Visual Studio 2010?
or is $(IncludePath) specific to this project and only the result of the "Inherit from parent or project defaults" checkbox? (in which case the question turns into: How do I edit project defaults for that since it appears to be depreciated in Visual Studio options)
Thanks!
NOTE: The %include% environment variable is not defined in Windows. It does show up if you enter "echo %include%" in the VS2010 command prompt (not the Windows command prompt), but it's not the same values as what I'm trying to get rid of in the screenshots)
In VS2010, these paths are specified in one or more property sheets (the respective changes are discussed in an instructive article on the VS Project Team Blog).
You can add those yourself per-project, but the project also includes one specifying all the default values.
On my system it is located in C:\Users\<user>\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props.
You can access it from Visual Studio by opening the Property Manager window (View->Other Windows->Property Manager), and then doubleclick the property sheet. You can also add property sheets yourself from this window (which will take precedence over the default one).
It is also perfectly legal to remove the reference to Microsoft.Cpp.Win32.user.props. That is useful if you need to ensure the project is entirely self-contained: that it doesn't get include paths from the environment, for example. Then you just have to specify the paths in the project itself, or in a custom property sheet that is part of the project (recommended for ease of reuse)
VC++ Directories in VS2010 are project-specific. There are no global settings like in VS2008.
There is INCLUDE environment variable which corresponds to $(IncludePath), so check it first.
Formerly VS saved all global settings in Documents and Settings\\Local Settings\Application Data\Microsoft\VisualStudio\\VCComponents.dat so try to delete such file if it is present for all VS versions. I don't have such file for VS2010, but it's worth checking in your case.
Hope this helps.
I have a directory /media/fonts in my asp.net mvc project which contains fonts for my website. When I use the "Publish" tool in Visual Studio this folder is ignored even though it is included in my project. Other folders /media/images and /media/css are included just fine.
Is there any way to tell Visual Studio to not ignore this folder on publish?
Select your font files and Change Build action as Content from Properties Window.
You can fix this permanently by modifying the default Build Action for font file extensions (.eot, .ttf, etc)
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
The link has been assassinated by the cruel march of time, so here's a copy/paste of its contents:
The default build action of a file type can be configured in the registry. However, instead of hacking the registry manually, we use a much better approach: pkgdef files (a good article about pkgdef files). In essence, pkdef are configuration files similar to .reg files that define registry keys and values that are automatically merged into the correct location in the real registry. If the pkgfile is removed, the changes are automatically undone. Thus, you can safely modify the registry without the danger of breaking anything – or at least, it’s easy to undo the damage.
Finally, here’s an example of how to change the default build action of a file type:
[$RootKey$\Projects{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\FileExtensions.spark]
"DefaultBuildAction"="Content"
The Guid in the key refers to project type. In this case, {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} means “C# projects”. A rather comprehensive list of project type guids can be found here. Although it does not cover Visual Studio 2010 explicitly, the Guids apply to the current version as well. By the way, we can use C# as the project type here, because C# based MVC projects are in fact C# projects (and web application projects). For Visual Basic, you’d use {F184B08F-C81C-45F6-A57F-5ABD9991F28F} instead.
$RootKey$ is an abstraction of the real registry key that Visual Studio stores the configuration under:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0_Config
(Note: Do not try to manually edit anything under this key as it can be overwritten at any time by Visual Studio).
The rest should be self explanatory: this option sets the default build action of .spark files to “Content”, so those files are included in the publishing process.
All you need to do now is to put this piece of text into a file with the extension pkgdef, put it somewhere under
%PROGRAMFILES(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\Extensions
(on 64-bit systems) or
%PROGRAMFILES(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\Extensions
(on 32-bit systems) and Visual Studio will load and apply the settings automatically the next time it starts. To undo the changes, simply remove the files.
Visual Studio does publish font files. In a special case we renamed extensions from .ttf to .jpg and they got published.