msbuild - tag propertygroup has attribute Label but not documented - c++

I need to manually modify my .vcxproj and I'm trying to understand the MSbuild schema using the documentation.
In my existing .vcxproj, I have the tag <PropertyGroup Label="Globals"> but in the documentation there is no mention of the Label attribute.
This is for an existing Visual Studio C++ project and there's no error when I launch it.
What does the Label attribute do?

It is nowhere fully documented; the Target element documentation mentions it, but it has just
Optional attribute.
An identifier that can identify or order system and user elements.
A quick glance at the source code also reveals it is not actively used by the build system itself: it's just there, you can assign values to it and get them back, that's it. As such it can serve as a means of adding a description to the xml (instead of using a comment). This description can also be retrieved programmatically by the build system. Which is the only use I have actually seen by a tool, namely Visual Studio: as you figured it generates project files which contains some labels. VS uses these to determine where to find/insert code produced by it's user interface. Good example is the PropertySheets label: it's just an ImportGroup, you can have an arbitrary amount of those, but only the ImportGroup with the label PropertySheets will be displayed and modified by the Property Manager in VS. Likewise for the ProjectConfigurations ItemGroup, the Globals PropertyGroup, the Configuration Items etc.

Related

Is there a way to make a property for a vcxproj in the Property Pages not be bolded using Visual Studio 2013?

I know that when a property appears bold in Property Pages it indicates that it has been modified.
https://msdn.microsoft.com/en-us/library/675f1588.aspx
I have an API that we ship samples with, and I want all of the settings across all of them to be consistent and the same.
Unfortunately, some sample vcxprojs appear to have the right setting and are not bolded, while others somehow had a wrong setting and after changing it to the right one, it's obviously still bold.
I want all of the samples Property Pages to be consistent across all of the samples, even the bolding of text. I realize this is really just an OCD cosmetic type of an issue, and there is no technical problem behind it.
The .vcxproj file is just an XML file. I'm assuming that bold means that there is a setting specified in the file, even if it's the default.
So: edit the file in a normal text editor. Remove the setting, so that it uses the default value, and so that it no longer appears in bold in Visual Studio.

Boost.Log Configuration Files

I'm adding logging to an old C++ program. After some research, I've decided to use Boost Log . The documentation is filled with examples of creating sinks and filters. However, I couldn't find any example of a log configuration file.
Is there a way to configure logging from a file that doesn't have to be compiled? Similar to what log4net has? Or Python (well, since Python isn't compiled, anyway...) ?
Eventually I found the official documentation, either it was added recently, or it is well hidden so that I didn't see it before:
http://www.boost.org/doc/libs/1_57_0/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.setup.settings_file
Unfortunately, I can't find an exhaustive answer neither, but some observations:
Certainly it is possible to use a configuration file:
boost::log::init_from_stream(std::basic_istream< CharT > &)
Example of the file (from Boost log severity_logger init_from_stream):
[Sinks.MySink]
Destination=Console
Format="%LineID%: <%Severity%> - %Message%"
From the following link you can identify additional valid setting keys and values (e.g. Destination=TextFile, Filter=, AutoFlush=, FileName=)
http://boost.2283326.n4.nabble.com/log-init-from-settings-problem-with-applying-format-and-filter-td3643483.html
Constants in boost's parser_utils.hpp give another idea of keywords that are by default supported by the configuration file (E.g. section [Core] with key DisableLogging).
Providing settings for user defined types is described here (with a corresponding snippet of the configuration file at the end of the page):
http://www.boost.org/doc/libs/1_57_0/libs/log/doc/html/log/extension/settings.html
It seems to me that it is difficult to find a description of the configuration file format entries because the valid entries are derived from the source code implementing the sinks, filters etc. This implementation may be even user defined so it is impossible to give explicit configuration format description.
Maybe you can try to create your configuration in a programmatic way and when transforming it to the form of the configuration file, you can open separate questions for the particular properties that you are not able find out how to set them.

Is it possible to get a report of unit tests run in TFS builds, grouped by solution?

We have a few thousand native and .NET unit tests. In Visual Studio 2012, I can run and see the results, grouped by the C++/C# project.
I'd like to get something like this view, preferably grouped by solution (product) and then project (.dll), to the business people. At the bare minimum I'd like to at least have number of tests run and failed per solution.
Is there any proper way to do this with TFS?
I've looked everywhere and keep running into walls,
TFS build test results don't seem to store any information about the test categories, so I can't use those to group by solution
.vsmdi lists and .testsettings files have been phased out in VS 2012 and TFS 2012. We had separate lists for each solution before...now it's just *test*.dll
Test Plans and Custom SSRS reports seem to be completely useless for this much granularity of test results (why?). TfsTestWarehouse has barely anything - just enough for total tests passed/failed per build.
Parsing TRX files and writing HTML reports seems to work best using tools like trx2html, but I still can't run tests by solution.
TRX files are just XMLs, there's no need to parse them. You can write an XSLT transformation to present the data in the format you need. A nice thing about XSLT is that it has built-in aggregation, grouping, sorting etc capabilities.
In case TRX files themselves do not contain solution information (which is likely), then you'll have to do a two-stage report generation: prepare the data, generate the report.
The preparation would be a relatively simple command line tool, which would go over your sln files and build a map of which projects belong to while solutions (search the web, i bet there're already a bunch of scripts for that).
And the generation part would be using that mapping as an argument to the transformation and report generation to properly aggregate the data.
I know, it's a bit of a generic response, but hope it helps at least a bit.
I ended up solving this by adding the Project and Solution information in a custom Assembly Attribute (i.e. to the test .dll) at build time, through a custom MSBuild task. Here are roughly the steps I followed (from memory).
First, I created the custom Attribute:
[AttributeUsage(AttributeTargets.Assembly)]
public class ProjectAttribute: Attribute {
public string Project { get; set; }
public string Solution { get; set; }
public ProjectAttribute(string project, string solution)
{
this.Project = project;
this.Solution = solution;
}
}
This custom attribute was defined in an Assembly that was referenced by all unit test projects.
I then created a very simple/rudimentary inline MSBuild task, CreateProjectAttribCs that would dynamically create an extra C# file with one line. Something like:
[assembly: ProjectAttribute(Project="$(ProjectName)") Solution="$(Solution)"]
And I then added this file to the <Compile> Item Group, inside a custom MSBuild target called before Compile (again, just going from memory):
<Target Name="CreateProjectAttribCs" BeforeTargets="Compile">
<CreateProjectAttribCs File="ProjectAttribute.cs" />
<ItemGroup>
<Compile Include="ProjectAttribute.cs" />
</ItemGroup>
</Target>
<Target Name="CleanupProjectAttribCs" AfterTargets="Compile>
<Delete Files="ProjectAttribute.cs" />
</Target>
For C++ projects I'd added the Project and Solution info to a String Table resource "injected" in a similar way to the ProjectAttrib.cs file.
One major annoyance with all of this was that developers would have to add this custom MSBuild .targets file (which would contain the custom targets and the assembly reference) by editing the .csproj or .vcxproj.
To circumvent that a bit, I also created a custom Visual Studio Project Template for our team's unit tests so that everything was already added and my fellow devs would never have to see the innards of an MSBuild project.
The hardest part was adding the Project/Solution info. Once I had that it was easy to read the custom attributes on the test assemblies or String Table resource in a native .dll, and add the info to data parsed/transformed from the test results to a custom test result database and report.

Using a dialog box to graphically retrieve user input

I am not new in C++ but this is my first time developing a Win32 program. It has to be graphical and so I have been attempting to get user input using an input/dialog box with no success.
I have read this topic on MSDN and found it helpful, but I get an error about IDD_PASSWORD and IDE_PASSWORD not being defined. Declaring them in resource.h and giving arbitrary values (like 110, 111) yields no results. Other attempts I have tried to modify the auto-generated about box, which also yields no results after modification, I noticed that if i change the value of IDD_ABOUTBOX in resource.h from 103, this also does not work. I also tried using the .rc under Resource View, but still no results.
So I'd like to know if the resource box templates have predefined constant numbers that i have to use, if so where because I searched that too or if there is another way to obtain user input in a windowed application. I just want to obtain an integer, that's all.
There is nothing magic in the numbers assigned to resources. The numbers are what the code actually uses to identify the resources. Visual Studio just allows you to assign symbolic names to those numbers through the use of C macros (i.e., #define) to make your code easier to read. These values are all defined in the file resource.h by convention, and although you can modify that file manually, you usually should not do so—let the Visual Studio Resource Editor handle that for you.
The problem you're running into is that you actually have to create those resources first before the numbers will mean anything. When you create a new Win32 project, Visual Studio will automatically create an about box dialog and give it the symbolic ID IDD_ABOUTBOX. However, there is no such IDD_PASSWORD dialog created by default in a new project, and there isn't one built into Windows.
You can create this dialog yourself using the Dialog Editor (part of Visual Studio's Resource Editor), which is pretty easy to do as it allows you to drag controls around on the dialog where WYSIWYG. When you add a new dialog box to your project's resources, you will be given the option to name it anything you like. You can use IDD_PASSWORD if you want, or any other name. A numeric ID will be assigned automatically based on an algorithm; generally the lowest available number is used.
The article you linked to is assuming that you have already added a dialog to your project with the symbolic name IDD_PASSWORD (which is probably a mistake on the part of the author). All it shows you is how to display that dialog once it exists as part of your project's resources.
It's going to be somewhat difficult to learn Win32 programming just by reading the MSDN documentation. I strongly suggest getting a book that explains it more clearly and in a more logical order. The canonical text is Charles Petzold's Programming Windows, 5th Edition. Note that you will need to make sure you get the 5th edition, as the newer editions digress from their Win32 roots and start talking about completely unrelated things like C# and Silverlight.
If you absolutely must learn by trial-and-error and MSDN, start reading about dialog box resources here.

"Conditional" macros in visual studio 2010 property manager

The property manager allows having different property sets for different configurations - for example, release and debug.
However, it still means you have to manually assign each property file to each configuration.
Is there some method to automatically assign a property set to a project based on some parameters (like configuration or platform)
a specific example:
I have a solution with many sub-projects.
this projects depend on various external libraries.
for each external library I have a .props file with the relevant directories and other parameters (include , lib, dll's...)
In some cases the directory names can be easily constructed using the default macros such as $(Configuration), $(Platform), etc.
However some libraries come with a less standard \ consistent naming convention.
for these cases I create .props file which are specific to a configuration (Debug\Release) - but it requires assigning the manfully to each project, which is tedious and error prone.
This is possible, at least in principle, see this post, for example. However, I did not find a practical way to use the whole power of MSBuild in combination with c++ projects from within the IDE. Whatever smart MSBuild expressions you write down in your property sheet, once you fire up the property manager dialog in the IDE everything gets overwritten with either defaults or the values inferred from there. This is an odd behaviour and completely different from other project types. Looks like they just wanted to keep the old pre-MSBuild style of editing VCProjects...
You can record a macro and use VBA to create/generate these with a button click.