Retrieve a Relative Path to a Directory from another Directory in NAnt - nant

I have a NAnt task create copies of MSBuild files. The copies are located in other directories than their originals.
The source files should remain where they are. Therefore, I'm using NAnt's <style> task to run an XSLT on the MSBuild files. It replaces the <Compile/> elements with <Compile><Link/></Compile> subtrees (attributes omitted for the sake of legibility).
I've encountered the following problem:
In the resulting MSBuild files, the Include attribute of the Compile elements should receive the relative path to the source file from the new location of the MSBuild files. As the original MSBuild files contain the relative paths to the files, what I am actually looking for is the relative path from the new MSBuild file location to the location of the original MSBuild files.
Workarounds that I know how to use, but which I'd like to avoid:
custom NAnt task
using substring to remove the mutual prefix of the directory paths (the NAnt base dir)
Is there any better way; possibly a NAnt function or an ingenious way to use several NAnt functions in conjunction to achieve this?

Related

Referencing files included in the FileList attribute in a manifest

I am writing a PowerShell module that will perform various configurations on our product including some xml transformations.
So, I need to include the XDT files in my module.
My module manifest will include the FileList attribute with a list of all the transformation files.
But the question is, how do I reference these files in the functions in the module?
Didn't find much in the documentation except that the FileList is just an inventory.
I thought of creating a variable with a path to the files (dynamic of course, depending on where the module is installed) but there must be a way to use these files...
This is a script module, not binary module and intended for V5
Thanks!

What do _._ files mean in nuget packages?

While looking at the contents of a Nuget package I came across the following file named:
_._
Shown by the Image below:
What does this file mean or do in nuget packages?
They are placeholder files to denote an empty directory.
Empty directories are often not well-supported in ZIPs so a file with that name is placed in there to ensure the directory is created.
From this link
They are placeholder files to denote an empty directory. Empty directories are often not well-supported in ZIPs so a file with that name is placed in there to ensure the directory is created.
This is important because the existence of an "empty" net46 folder
means that the package supports .NET Framework 4.6, but does not
require any assemblies (DLLs) in order to run on that version of .NET.
This is most likely because the implementation of the package is in
the GAC.

Install4j: Get the absolute path of the project file

I have the installer project with all the resources it uses added in my Gradle project (in path project_folder_path/install). But for some sql operations (which will run during the installation), I need to add some files located in other modules of my gradle project (for example in path project_folder_path/sql) to its distribution tree. So, is there any way to somehow get the file path of the .install4j file( or is there any variable existing) that I can manipulate later for finding the files required?
Relative files are resolve relatively to the .install4j project file. So you don't need a variable for that location, just add relative paths to the distribution tree.

Determining powershell scripts dependency tree

How do you determine the entire dependency tree for a given script in powershell? If your target script dot sources a number of files, which themselves dot source other files, what is the quickest way to identify and only deploy that tree?

MSTEST folder deployment question

Is there a way to preserve folder structure with MSTEST deployment?
I have a situation with some existing code where I have .config files in a subfolder (called "Configuration"). I can specify this folder using MSTEST deployment but, in it's infinite wisdom, MSTEST just copies the files from this folder to the run folder (TestResult\\Out), i.e. it does not create a subfolder called Configuration. This royally screws up the code and it fails. I don't really want to have to start using complicated pre-test scripts to create folders etc.
Any ideas gratefully received.
Matt
I think I had the same problem...
My tests used a folder called xsd and I wanted to deploy the folder to the test \OUT directory. When I did this, the files inside the xsd folder were copied to the test \OUT directory, but I wanted the folder xsd into the test \OUT directory...
To solve this I read this. (Wayback machine has an archive of this page here)
If you're using the DeploymentItem attribute, it takes a second argument for the name of the directory to copy the files into. If you use the same name as your folder it preserves everything.
To use your test case you'd do:
[DeploymentItem("Configuration", "Configuration")]
class TestClass
....
and it would work.
Yes, you can. read the article Do MSTest deployment items only work when present in the project test settings file?
It explains how to map deployment items.
In Visual Studio 2012 the output directory is the working directory which means that the DeploymentItem attribute isn't needed for the general case (where you don't have specific per-test or per-class deployment items). You can simply click Project | Show All Files and include the subfolder and files in Visual Studio with the 'Copy Always' or 'Copy if newer' attribute to your project and the files will be copied to your output directory with hierarchy intact. The same applies when running vstest.console.exe from the command line.
See here for more information about Deployment Items in Visual Studio 2012.