What does the pipelinePreDeployCopyAllFilesToOneFolder target do? - msbuild

I've seen msbuild commands pass /t:pipelinePreDeployCopyAllFilesToOneFolder as a target. On searching the Internet, I've found many forum and question/answers posts about this target. That said, I've found no official documentation.
What does this target do?
Where does Microsoft document it?
This target usually goes along with a _PackageTempDir property.
My best guess is that the target and property together mean that, before deployment, copy all files to the specified package temp directory.

Seems like it's a Web Application specific default target.
As mentioned in this answer it is in the following file:
It's actually contained in the file that Sayed Ibrahim Hashimi mentions, which is the Microsoft.Web.Publishing.targets file (C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets).
You can check what its content here. (I found a copy on github)
Neither I could find the mentioned target among any documentation. However, there is a documentation of msbuild on github with some fancy figures. Also, there are other documentation fragments on Microsoft's documentation about Default build targets or Common target files.

Related

I want to use c++ code on .net NanoFramework how can i do it?

I have created a library and i get a folder called Stubs
in this folder i get a bunch of files, how can i build it and used as an interrupt on the C# code?
There is a blog post with detailed explanations on how to use Interop in .NET nanoFramework. Please see here.
Look at section "Adding the Interop library to a nanoCLR image". You have to add those files and the respective CMakelists.txt to the project folder and build a new image that includes them.

What is the proper way to document a CMake module?

A quick Google search (...actually many rather extensive Google searches) have not been able to explain how to properly document a CMake module.
What I'm looking for is a way to document custom CMake modules so that they work with the cmake --help-module <module_name> command. Is there any standard way of doing this? Can anyone point me to some good examples? The documentation process seems oddly.... not well documented. Haha.
How are modules that work with cmake --help-module documented?
Any help is appreciated.
Quote from an email response I got from Brad King (member of the CMake Developers email list):
There is no way to do this. The only reason --help-module exists
at all is because prior to 3.0 the documentation was generated by
the CMake binary itself, and people were used to the option being
available. It is only for builtin modules and only available for
legacy reasons, and may one day go away in favor of the man pages
and html docs.
The online docs, like those at https://cmake.org/cmake/help/v3.14
do publish a /objects.inv to support intersphinx:
http://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
This was done on request of some users so I haven't looked into how
that works, but one should be able to use sphinx to generate one's
own documentation and still cross-reference CMake's online docs.
If you get that working we'd welcome a MR to add docs describing how,
perhaps in
https://gitlab.kitware.com/cmake/cmake/blob/master/Help/dev/documentation.rst
It sounds like using Sphinx is the way to go.
Additional info:
How does Sphinx know to go parse that ".cmake" file? Does Sphinx recognize the "cmake-module" keyword in a special way and know what to do with it?
it’s from a Sphinx module that you can find the in the CMake sources Utilities/Sphinx/cmake.py. Or you can install this file using pip:
pip install sphinxcontrib-moderncmakedomain
When configuring Sphinx, you have to name the extensions to use in Sphinx's configuration file (conf.py) and add the name of the extension (sphinxcontrib.moderncmakedomain) to the extensions array.
Good news: You can use sphinx to document your CMake Modules, and at the same time use Doxygen to document your C++ (or other) source code.
I created an example project which shows how to use the sphinxcontrib-moderncmakedomain in combination with Sphinx and Doxygen to generate Documentation for your C++ Code AND CMake code:
https://gitlab.com/Pro1/doxygen-cmake-sphinx
It is using the sphinxcontrib-moderncmakedomain package and CMake itself to configure the sphinx conf.py and then run sphinx.
The example is heavily based on the official CMake Documentation from: https://gitlab.kitware.com/cmake/cmake/-/tree/master/Utilities/Sphinx

Where to install FindLib.cmake

I'm creating a library (called fmi2) which I intend to install on my local machine (via a package manager) and then link to with a bunch of other libraries.
I'll be providing a Findfmi2.cmake file so that I can call find_package(fmi2) from my other libraries, but where should this file be conventionally installed?
Here are some choices I've considered and their problems:
/usr/share/cmake-3.8/Modules/Findfmi2.cmake
Advantage: find_package(fmi2) will just work
Disadvantage: Only works for one version of cmake
/usr/share/cmake/Modules/Findfmi2.cmake
Advantage: Should work for any version of cmake
Disadvantage: This is not a default folder. We would need to add set(CMAKE_MODULES_PATH /usr/share/cmake/Modules) and this kills any portability.
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findfmi2.cmake
Advantage: Portable, just need to add set(CMAKE_MODULES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
Disadvantage: Not system-wide. Need to manually add this file to each library that uses it. This duplicates files in my framework.
You are authoring content in CMake. You don't need a FindModule. That is designed to find external non-CMake outputs.
This Stackoverflow post from ruslo should help you understand the difference between find_package() module mode and config mode. It also answers your question about paths for FindModules, i.e. they are copied into your CMake project, not discovered system-wide, unless they are part of the official FindModules bundled with CMake in the "Modules" directory.
Modern CMake documentation now finally contains good examples to create a config mode package: cmake-packages
If you want explicit full examples, though using slightly older syntax for the config.cmake files, ruslo has more on Github.

WiX creating obj file in strange place

In my WiX 3.5 project I'm including a wxs file via a link. I.e., the wxs file is not in the project folder, it is fairly far away in the folder structure, and is included using Visual Studio's "Add as a link" facility.
This is working fine. But it does have the strange side-effect that WiX creates the obj file for the included wxs in a strange location, creating several folders to somewhat (but not correctly) mimic the path structure between the WiX project folder and the folder where the wxs file is located.
Is there any way to avoid this, so WiX creates this obj file in the same place as the other obj files, or alternatively creates it next to the wxs file, and not half way in between?
I always thought this is what -out command-line parameter of candle.exe is for. Have you tried playing with it?
It turns out this is a bug in WiX 3.5, and has been documented in a blog entry here:
http://www.paraesthesia.com/archive/2011/02/07/wix-3-5-2519-0-incorrect-intermediate-object-path-for.aspx
The blog article also helpfully provides a work-around, although it didn't quite work for me. For my situation I had to add an extra backslash to the path, so instead of
<ObjectPath>obj\$(Configuration)</ObjectPath>
I needed to specify
<ObjectPath>obj\$(Configuration)\</ObjectPath>
Thanks to Travis Illig for the blog article, thanks to Edwin Castro on the WiX-Users mailing list for pointing me to the blog article, and thanks to Yan Sklyarenko for his help too.
EDIT:
The plot thickens - it's not a bug, it's a feature!
And it's not in WiX, per se, but in Votive / MSBuild.
https://sourceforge.net/mailarchive/message.php?msg_id=27244936
Anyway, the important thing is that it's easy to fix with the work-around suggested by Travis Illig in his blog article.

How do I find the current file in MSBuild

I know that the latest book out on MSBuild says this is not possible, but I am sure I have seen a property that points to the current file.
Does anyone know a way to find the current file? (ie When the main MSBuild file imports a secondary file. What is the path to the secondary file from inside that file.)
I am trying to register my file in HKEY_LOCALMACHINE\Software\Microsoft\VisualStudio\8.0\MSBuild\SafeImports, but the path to the file is not constant on each of my coworkers computers and it is imported from several different projects so doing a hard coded relative path is not a good idea either.
If there is a way to get the current working directory that will work too (the working directory switches with each import and I think I could save it off)
There is not a reliable means to identify the "current file". When MSBuild processes a file it can import several other files, the end result is a single in memory complete representation of the file. When the targets are executing they do not know which file they were declared in.
This is why reusable build scripts must be "parameterized" to accept the location to known relative locations. For example if you have a dependency on the location where your folder for 3rd party references are located, the build script which is driving the process must declare that property for you.
MSBuild 4.0 Only
If you are using MSBuild 4.0, i.e. Visual Studio 2010/.NET 4.0, (which can target .NET 2.0/3.0/3.5) as well. Then you now have these properties which can be used for this specific purpose:
MSBuildThisFile
MSBuildThisFileDirectory
MSBuildThisFileDirectoryNoRoot
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
In 4.0+ you can use properties like $(MSBuildThisFile) to do exactly this. See here