Visual C++ 2010 "system property sheet" and "user property sheet", key difference? - visual-studio-2010

I'm reading Inside MSBuild 2nd-edition from MS Press. When it comes to chapter 10 introducing the concept of "user property sheet" and "system property sheet", I come up with a question: What determines whether a property sheet is "user" or "system"?
As told by the book(p284), user property sheet and system property sheet are displayed with different icons inside Visual Studio 2010 IDE.
So,
Upgrade from VC 6.0 and Microsoft.Cpp.Win32.user are "user".
Application and Core Windows Libraries are "system".
I first thought that
.props from %LOCALAPPDATA%\Microsoft\MSBuild\v4.0 are "user "
.props from C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0 are "system"
but that's not the case, because Upgrade from VC 6.0 is from C:\Program Files (x86) while it is a user property sheet.
Then what's the key determination factor?

Well, maybe the author has answered it as I have guessed, but in a vague and ambiguous way. On page 284, there is:
The System Property Sheets are pulled into a Visual C++ project via
the following two imports, which you can find at the beginning of your
project file (note that these are not successive lines in the project
file; they are separated by other lines).
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
The reader has two ways to interpret this statement:
It emphasizes how "system property sheets" gets into .vcxproj. But the definition of "system property sheets" is stated elsewhere.
The two specially named(Microsoft.Cpp.Default.props and Microsoft.Cpp.props) import statements defines what is called "system property sheet". (very implicit)
Perhaps the authour means both.

Related

Project Defaults in Visual Studio 2010

I have discovered Property Manager in Visual Studio 2010. However there are two project properties that I haven't found how to set a default value for. Under Project Defaults in the project property pages dialog window, there is Configuration Type property whose default value is Application (.exe). I would like the default to be Dynamic Library (.dll). The other property is Character Set whose default value is Use Multi-Byte Character Set but I would like it to be Use Unicode Character Set.
Please note that I have also discovered the file Microsoft.Cpp.props but it contains a warning not to edit the file's contents - so I would prefer not to.
Is it possible to set the defaults I desire and if so, how do I do it?

What's purpose of <Use64BitIISExpress /> element in csproj file

When I edit Web application project, Visual Studio 2017 (15.3.1) adds <Use64BitIISExpress /> element under Project/PropertyGroup in csproj file.
I can't find any documentation, what is the purpose and if it affects something, when presented (as it is, without any attributes).
Only result I was able to find was mention about registry value of the same name.
Does someone know what this element serves for?
Was it introduced in some of recent updates of Visual Studio 2017?
I noticed this entry, not surprisingly, after I made a change to the Properties page of the my Project. Under the Web section of the Properties page, you'll see a section called "Servers". After I changed the "Project URL" to use the correct port number for debugging, this entry appeared (not because I changed that option specifically, but it's when I noticed it appearing).
<Use64BitIISExpress />
In this section you can select either "IIS Express" or "External Host". Next to that dropdownlist, there is another dropdownlist for "Bitness". Mine was currently set to "Default", which displays the entry in the Project file as an empty element. After changing the "Bitness" to "x64", my Project file entry changed to:
<Use64BitIISExpress>true</Use64BitIISExpress>
Changing my "Bitness" to "x86" results in:
<Use64BitIISExpress>false</Use64BitIISExpress>
Returning "Bitness" to "Default" makes it again an empty element:
<Use64BitIISExpress>
</Use64BitIISExpress>
I understand this doesn't address your question of "where is the documentation?". I, too, could not find any relevant MSBuild documentation for this attribute. But, I thought it worth noting where the attribute is coming from and how it acts based on selected options from the Project properties while we anxiously await some formal, official documentation.
The purpose of that (pretty obvious) is to start IIS Express in 64bit mode. It is the equivalent of setting 64bit only on the Application pool in IIS.
If your project has a dependency on a DLL that only runs under 64bit mode then this is when you need to set it. This has been available since VS2013
Probably is useful if you prefer to do do F5 debugging instead of
process reattaching for your pure 64bit applications
This started showing up in the config files since VS2017 due to all the changes happening with Visual Studio portability. (VSCode, Visual Studio Mac, Xamarin, etc)

How does Visual Studio determine which item templates are available in a project?

I would like to have the Add->View... context menu item available in a project that starts out as a class library, just as it is available in a project that starts out as an MVC 4 project. I have given the .csproj file a cursory read through, but I don't see anything saying, "This is an MVC project", so how does VS know this?
I have since learnt that VS looks at the ProjectTypeGuids element in the project file, and that I must add the GUID E3E379DF-F4C6-4180-9B81-6769533ABE47 to the front of this elements value. Maybe my question is clearer now that I can say I'm trying to find out what the association is between these GUIDs and the item templates available in a project.

Problem with file name folding in Visual Studio Solution Explorer ("File Nesting")

(Edit for search-ability: called "File Nesting")
I'm not sure if "folding" is the correct term, but the feature I'm referring to is shown in the 1st image below, versus the 2nd one which does not have an expandable tree list node for the code behind file.
Folding:
No folding:
My questions are:
What is the correct name of this feature?
How do I set it?
Why does my Solution Explorer not have this feature enabled when I try to convert my Web Site Project to a Web Application Project?
References:
Upgrading VS 2005 Web Site Projects to be VS 2005 Web Application
Edit
Thanks Sean, but as you can see below, my Nest Related Files button does show up in this project for some reason:
Should have button shown below:
Edit:
I figured out the reason: I accidentally created a C# Web Application Project, and then added VB ASP.NET files to it.
It's called File Nesting.
When a website project is selected in Solution Explorer, the third button in the Solution Explorer toolbar is for "Nest Related Files".
A website project or project file must be selected in Solution Explorer (rather than the root Solution), for the button to appear in the toolbar. The command/tool button is not available when C++/C# projects are selected in Solution Explorer. I don't have a web app project to test but can only conclude that the command is not applicable to web app projects either.
see this related question for a possible registry hack (changing 9.0 to 8.0 in the question's reg script):
Visual Studio 2010 related file nesting
When you are not using a website project, the nesting button in the solution explorer won't appear—but you can still nest files in .NET 5.0 projects.
Here's how you do it:
Open the project's .csproj file. Visual studio can open it in its own viewer, or else you can use your favorite XML or text editor.
Locate or create an appropriate Item Group element. If there's already one that includes some of your files, put it in there for cleanliness and consistency. If there isn't, create a new one.
Create a new Content element for the file you wish to nest. This element's Include attribute should be the name of your desired file.
Add a new DependentUpon child element to your content element. This element's text value should be the name of the file you wish to nest your target file underneath.
Save the project file and Visual Studio will likely prompt you to reload the project. If you did it correctly, your target file should now be nested under your desired file.
There's shockingly few questions and answers that address this situation. The above answer didn't help me, so I figured that I would share what did for posterity.

How to set $(OutDir), $(TargetName), $(TargetExt), and %(Lib.OutputFile) with Visual Studio?

I'm trying to build gtest on Visual Studio 2010. After converting the solution file, I tried to build, and I got the following warning messages.
Warning 1 warning MSB8012:
TargetPath(C:\Users\sucho\Desktop\gtest-1.5.0\msvc\gtest/Debug\gtest.lib) does not match
the Library's OutputFile property value (C:\Users\sucho\Desktop\gtest-1.5.0\msvc\gtest\
Debug\gtestd.lib).
This may cause your project to build incorrectly.
To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property
values match the value specified in %(Lib.OutputFile).
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets
The message says I need to setup variables $(OutDir), $(TargetName) and $(TargetExt), together with property values specified in %(Lib.OutputFile).
How can I do that with Visual Studio (especially VS 2010)?
I see it. Right-click the gtest project, Properties, Configuration properties, General. Ensure that the Debug configuration is selected (upper left combo). Change the Target Name property to
$(ProjectName)d
Note the added "d" to change the name from gtest to gtestd. The warning is otherwise benign.
I think no one has the right answer, i solved this way: in project properties pages, check if linker->General->Output file match configuration properties->General->target name & configuration properties->General->target extension.
You don't need to add any 'd', of course, is more simple set to Inherit from parent or project defaults, for all 3 variables.
Example:
Linker → General → Output File = "myproject.exe"
then:
Configuration Properties → General → Target Name = "myproject"
configuration properties → General → Target Extension = ".exe"
The warning is spurious -- assuming you're using Google Test, it works just fine
You can make it go away however. Right click on the offending project and select properties. Select "Librarian" in the tree view on the left hand side, and change the "Output File" item on the right by clicking on the box next to output file, and selecting "Inherit from parent or project defaults".
The background to this is that Microsoft changed the meaning of the $(TargetName) macro. It used to mean "whatever filename you put in Linker | Output File, minus the extension". They changed it to "by default, the name of your project". (This is something you should never do, in my view; they should have added a new macro).
Whereas VS2008 and earlier were able to parse the file name out of the Linker setting, apparently they were not able to parse it out in the migration to newer versions, leaving our configurations broken.
The warning itself is probably not important, but if you use $(TargetName), say by passing it to a batch file, this change will break your batch process.
For us, the solution has been to copy the file name (minus extension) from Linker | Output File to General | Target Name, and then set Linker | Output File to "inherit from parent/default". This is because we use suffixes like "d" (for debug), "u" for Unicode, _64 for 64-bit and so forth.
On the other hand, if your output file always matches the name of the project, then all you need to do is set Linker | Output File to "inherit default" and you're done, in principle - providing that the output directory you want for your compiled file matches General | Output Directory.
This change is absolutely infuriating because it involves moving literally hundreds of settings around, all due to sheer laziness on Microsoft's part, as far as I can see.
I was just trying to compile an application in Visual Studio 2019 that I had last compiled in Visual Studio 2005. I encountered the same warning.
I thought I would show what I did visually with screen shots.
Solution Name v Target Name
As you can see, my variables were both set to Import Text:
I could have just set the $(TargetName) to ImportText to solve my issue. However, we will leave those values as they are.
Linker / General Output File
This is how I had the output file setup:
Notice that I had overridden the output target name as ImportText. This was over 10 years ago and I did not have as much experience.
General / Target Name
So all I had to do was make the same adjustment here:
Now it compiles file.
This kind of errors typically arise when upgrading old project to new version of Visual Studio (like in your case to VS2010) and also if project settings may have been manually changed (for example changing executable name). We know VS2010 uses these macros $(ProjectName) $(TargetName) $(OutDir) $(TargetExt) to control release/debug outputs but it is often mystery where to change them. We than typical resort to changing the name of output files directly through Project >> Properties. This means we now have to change the output files separately for debug and release build and if there was any dependencies, we will get error like This may cause your project to build incorrectly..
These macros/properties are VS2010 defaults but you can set them yourself in .vcproj files by editing it in notepad. Note search first for the property in the .vcproj file first, if its there than change its value, if not define it like below.
<PropertyGroup Label="My Values">
<ProjectName>New_Project_Name</ProjectName>
</PropertyGroup>
Above I have defined a new <property group> to keep these values but you can define them anywhere. I define this at the top of the file right after debug/release configuration group so its visible everywhere. Make sure your project properties are setup properly to use them correctly (they should be what is VS2010 default settings). If you have changed them you should copy it from new test project. You can of course add the other Macros you want to set values for in the above group as well.
You can also verify the new values of this macros through project properties. For example click in Configuration Properties >> General and than in 'Target Name' box. Select edit. It will bring up a dialog box with the button 'MACROS >>'. Click that and it will show you what the value of each macro is. It should correctly reflect the new values that you set in .vcproj file.
Just as Hans Passant posted, you need to modify the TargetName property manually. This is different between VS2005/2008 and VS2010. Please refer to http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/3c03e730-6a0e-4ee4-a0d6-6a5c3ce4343c

Resources