In Visual Studio 2019 version 16.11.15, I'm using the Performance tool to measure performance degradation that occurred in a new version of our program (a huge, mainly C program).
Usually I run both the old version and the newer version on the same test, and manually going through the performance tool file to see the difference.
I was wondering if there is a way to automatically compare between two .diagsession files - something similar to a diff command.
I am aware of this How to: Compare performance data files
, however they are talking about .vsp files.
Is this even possible on Visual Studio?
Related
As a beginning programmer, my projects tend to be small in terms of lines of code - most of the times they are console applications. While I understand that Visual Studio 2013 is meant for more professional usage, in my case it seems unnecessary that ~600 bytes worth of code produces me ~10 megabytes of output, the biggest culprit being the
SQL Database File.
Is there a way to compile my code directly into an executable file without any debugging left-overs and databases? My perfect project would contain source files, an executable file and project files needed by Visual Studio.
Thanks in advance for your help.
We have a Windows Desktop only product suite that consists of several .exe applications and (obviously) quite a bunch of shared libraries between these apps. There's about 20 exe apps and maybe also about 20 shared libraries that are each used by several of these apps (some libs are very specific, some are just your good(?) old FooUtils.dll) Most code is C++, some C#.
Currently, all these reside in a single Visual Studio 2005 solution and are all built and released together. That works quite fine and each developer always can edit / see / debug any code he needs to. About 15 devs (mixed C++ / C#) on that product suite.
Now the problem
Due to migration pressure (language features, new 3rd party components) it becomes increasingly urgent to migrate some of the apps (read .exeprojects) to newer visual studio versions. Some to VS 2010 maybe (3rd party dependencies) some to VS2015. And some we just have not the resources to migrate them from VS2005 yet (third party constraints, as well as time/budget constraints).
This means that several of the shared C++ libraries will have to exist for several visual studio versions. (As opposed to the exe projects - these would just be built/maintained for one chosen VS version.)
Now the question
Given a set of (internal) shared libraries that need to be created for multiple different Visual-C++-Versions and that should be easily editable and maintainable for all devs, how are we to keep the Utils.vcproj(2005) the Utils.vcxproj(2010) and the Utils.vcxproj(2015) in sync?
Mostly to avoid manually having to maintain all files contained in the projects, but also regarding project settings / .[vs]props settings for these projects.
Ideas we had so far:
Just accept annoying triple maintenance of 3 project files in 3 different solutions (ugh.)
Use one of the vc.. project files as the master project and automatically (how??!) generate the other vc..files from it.
Use tools like CMake, Premake, ... ?? to generate these shared-shared library projects. (That would mean introducing a foreign configuration tool for our devs)
If you want to avoid manually updating your project files in separate versions of Visual Studio, you'll have to have a master configuration for the project of one sort or another. The two options you listed are basically your options:
Use one project version as the 'master'. In this case, the master must be the oldest version (VS2005 in your case?). Visual Studio has a project upgrade feature, to convert older projects to newer versions. When you load up an older project in a newer version, it prompts you to upgrade. This process can be automated with some simple scripting. Using devenv.exe <project/solution file> /upgrade you can upgrade a project from the command line.
Use CMake/Premake/etc. These add a little bit of overhead, but making supporting new platforms and configurations a lot less painless. If adding new dev tools is cumbersome to your process, and you're only supporting Visual Studio, the first option might be more suitable.
I use Xorax IncrediBuild to build Visual Studio 2013 (or later) solutions and projects, they're mostly .vcxproj with a bunch of .csproj ones.
It took me a little bit of digging, but I've learned that:
When IncrediBuild is used with the regular Visual Studio, it uses the Devenv.exe by default.
Since version 5.0, BuildConsole.exe supports a new switch: /UseMSBuild to specifically instruct IncrediBuild to use MSBuild's build engine instead of the default Visual Studio's DevEnv.
So, in case of Visual Studio projects, there are two modes available:
BuildConsole.exe MyProj.vcxproj which uses DevEnv.exe
BuildConsole.exe MyProj.vcxproj /usemsbuild which uses MSBuild.exe
I'd like to learn if there are any differences between using the two engines.
I have made some tests and observed that:
IncrediBuild "Initializing..." phase takes slightly longer in case of DevEnv.exe.
BuildConsole.exe generates different output, obviously.
No (or insignificant) difference in build performance.
In case of building individual C/C++ native projects (.vcxproj) as well as whole solutions (.sln), what are advantages and disadvantages of using DevEnv.exe versus MSBuild.exe?
** disclaimer: I work at IncrediBuild **
We've determined together with Microsoft that in order to get builds that behave in the same manner as building from within Visual Studio (without IncrediBuild), DevEnv should be used. MSBuild executes builds in a slightly different manner than VS both in the build output it produces and in the way it behaves when executing custom steps and some other minor things. If a user wants IncrediBuild builds to behave in the same manner as he is used to when building from Visual Studio, the default way should be used (IncrediBuild executing DevEnv). If a user is used to execute his builds using MSBuild, whether from the command line or through TFS, the UseMSBuild switch should be used. We wanted to allow users to choose the way they would like IncrediBuild to work depending on the way they are used to do that, same as Microsoft supporting both DevEnv and MSBuild.
Additional comments:
The initialization stage is indeed longer when using Devenv, since devenv loads and parses the solution and .vcxproj files in a different manner than msbuild. The more Projects a solution has – the longer this phase should take. The increase of time it takes this phase to complete usually greatly offset by the speed increase in the actual build time – when building several projects at the same time.
Devenv is highly recommended for our Predicted Execution feature which can provide up to 20% of additional build acceleration due to the above way of work which would be not possible using MSBuild.
Microsoft is pretty explicit about it:
For build-related tasks, it is now recommended that you use MSBuild instead of devenv. For more information, see MSBuild Command Line Reference.
A note in the Devenv documentation since VS2010, the first version of VS that started supporting building C++ projects with MSBuild and also changed the default project file extension from .vcproj to vcxproj.
The wisdom of this kind of advice can only be inferred when they are not explicit about it. One you ready saw, Devenv.exe is a pretty heavy process with many DLL dependencies, it takes a while to get going. Another you could fret about with the way you are doing it now, original guidance was to use Devenv.com instead of Devenv.exe. Those dependencies are also troublemakers, the kind that tend to get in the way or just plain fall over when Devenv.exe runs in an unusual runtime environment like a service. Sample story-from-hell is this Q+A, three answers and none look correct. There are others.
Plain advice is to use the recommended way.
Microsoft Visual Studio uses XML to save its .vcproj project files. So diffing XML project files should be easily.
Unfortunately, if you change any of the project file's properties, Visual Studio insists on randomly shuffling the XML nodes of the project file! This makes textual diffing and merging of project file changes basically impossible. Changing one compiler setting can make my visual diff tool think I've changed 50% of the lines in the file! I've even tried some XML diff tools, but they just show a more structured view of the same mess.
Does anyone have any suggestions for maintaining .vcproj files in source control? Or a way to convince Visual Studio to not rearrange the XML nodes in the .vcproj file?
(I have also investigated using tools like CMake to generate .vcproj files from a more diff-friendly text file, but CMake has its own problems.)
This seems to come up every now and then.
Merging vcproj files - SCM's hell
Perhaps it is a problem ripe for a plug-in or other normalizing tool.
It would be a great side-business, until MS decides to fix it. Then you're out of luck - unless of course they offer to buy your IP.
Anyone want to start an open source project, or commercial product? I'm game.
I might have a go at a stand-alone normalizing tool, then see if I can turn it into a plugin.
We are seeing this here at work now, with project files where the configurations are reordered on several peoples computers, and it is very frustrating...
*Note: We all use VS 2008 Pro, not Team
At first it looks like they are randomly reordered, but there is in fact a pattern and it is not random at all.
For one group the configurations are ordered by Platform, then by Config:
Debug|Win32
Debug|x64
Release|Win32
Release|x64
Debug DX11|Win32
Debug DX11|x64
Release DX11|Win32
Release DX11|x64
...
For the other group the configurations are ordered by Config, then by Platform:
Debug|Win32
Release|Win32
Debug DX11|Win32
Release DX11|Win32
Debug|x64
Release|x64
Debug DX11|x64
Release DX11|x64
...
Looking through perforce history, this is consistent with multiple projects submitted by the same sets of people, and there is about a 50/50 split, so it is not just happening for one person.
Is this the same issue that you are all seeing?
If so, I hope this pattern helps find a solution that does not involve a macro/extra diff step...
It has to be a setting somewhere, or a side effect of clicking something, since it is 100% reproducible per each of these machines. Even if it is something silly like which option you choose for your initial environment layout (VC++, VB, General Development, ect...)
I use WinMerge as my diff-tool and I enabled the moved block detection. It doesn't quite fix the issue, but it makes visualizing the differences a little bit more bearable.
I think I've found the reason for this shuffle. At least in VS2008.
If you install the x64 compilers, VS will order projects as:
Debug|Win32
Debug|x64
Release|Win32
Release|x64
If you don't it will order them like:
Debug|Win32
Release|Win32
Debug|x64
Release|x64
So make sure all your peers have the same compiler set installed, so it won't shuffle.
Tested it and this behavior appears to be reproducible.
Which version of Visual Studio are you seeing this in?
I do a lot of work with .vcproj files (we maintain versions of the project files for our libraries in multiple Visual Studio versions, and I'm always diffing and merging the things) but I've never seen this behaviour.
My team at Adobe has seen the same thing in vs2008. Just a basic Debug/Release, win32/win64 project gives you 4 configurations and random shuffling. Several people have tried to figure out when and why devstudio reorders, but current thought is the sort key is a keyword hash - hence semi-random. We've given up and in code reviews just summarize the "real" changes.
I'm running Visual Studio 2008 with the stuff-of-nightmares awful MS test framework. Trouble is that it's sending my CPU to 100% (well 25% on a quad-core).
My question is why can't Visual Studio run on more than one core? Surely M$ must have a sufficient handle on threading to get this to work.
I have VS2008 running on all 4 CPUs. Just set this environment variable / project flag.
/MP
(It can be set in C/C++ Settings, Advanced. In project settings)
Edit: The MP flag can also accept a number, e.g. /MP2 which means it will only run on 2 cores. Leaving it as just /MP means it will run on the maximum amount of cores.
Edit2: The MP flag is probably for the compiler only.
You can ask VS to compile multiple projects in parallel as well as compiling parallelly (!?) within a project.
Tools > Options > Projects and Solutions > maximum number of parallel projects build.
This will build C++ and C# in parallel as well!
In case anyone comes across this old question, VS2012 introduced parallel builds as a standard feature. Quote from the article:
Visual Studio 2010 included an option for "maximum number of parallel
project builds." Although there was no indication of any restriction,
this IDE option only worked for C++ projects. Fortunately, this
restriction no longer applies to Visual Studio 11. Rather, there's now
full support for parallel builds in other languages as well. To view
this, run a copy of Process Explorer at the same time a solution with
numerous projects is building. You'll see that multiple MSBuild
instances are created -- as many as specified in the "maximum number
of parallel project builds."
Now that Visual Studio 2010 has been released for a bit, consider upgrading to make use of the parallelTestCount attribute in MSTest's .testsettings file, as described at How to: Run Unit Tests Faster Using a Computer with Multiple CPUs or Cores.
There are a few limitations, such as:
Only simple unit tests are supported (i.e. excludes coded UI tests and ASP.NET-hosted tests)
Tests must be thread-safe (all tests are run in the same process)
You can't collect code coverage (among other data & diagnostics) at the same time
Example, using 0 to mean auto-detect (the default is 1):
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings
name="Release"
id="{GUID}"
xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>
These are default test settings for a local test run.
</Description>
<Execution parallelTestCount="0">
(...)
</Execution>
</TestSettings>
A few blogs have noted that you might have to close and re-open your project for Visual Studio to notice you added/changed that attribute. Also, if you edit the test settings file using the GUI, you'll probably have to re-add the parallelTestCount attribute.
We also added multiple core support for doing multi-threaded builds on the command line for those of you with a lot of projects and long build times. Enabling multiple core support requires only a few new properties, and MSBuild manages all of the work to schedule projects efficiently and effectively. The MSBuild team has tested this ability to scale by building some projects on a 64-CPU machine.
that is from somasegar blog
So they sort of started doing it, well at least for the build.
The /MP flag is only for builds, we at least it is according to this msdn
Now I would love to be wrong about it, but im pretty sure its just for builds. Which of course is still very useful.
I'm sure it's very hard. Huge existing GUI-heavy non-threaded code base to multi-threaded. Sounds like a 10 to me.
But it seems to use multi-cores to me. The Intellesense seems threaded. The build system has multi-project building and for C++ multi-file building as well.
You problems with these tools sounds a bit deeper then how well they use you CPUs.
For Visual Studio 2010 Go to Tools > Options > Projects & Solutions > Build and Run.
You will then see an entry to enter a number for the 'maximum number of parallel project builds'; my PC has an i7-3770 CPU, a Quad Core with HyperThreading, so it is set to 8.
For information on different versions of Visual Studio go here and select your version: https://msdn.microsoft.com/en-us/library/cyhcc7zc(v=vs.100).aspx
e.g. for Visual Studio 2010 this property only affects C++ builds:
Specifies the maximum number of Visual C++ projects that can build at the same time. To optimize the build process, the maximum number of parallel project builds is automatically set to the number of CPUs of your computer. The maximum is 32.
But for Visual Studio it's for C++ and C#:
maximum number of parallel project builds
Specifies the maximum number of Visual C++ and Visual C# projects that can build at the same time. To optimize the build process, the maximum number of parallel project builds is automatically set to the number of CPUs of your computer. The maximum is 32.