Replace token in text file with content from another text file in MSBUILD - msbuild

I have 2 MULTILINE text files, I want to combine them into a third file in an Msbuild script.
Ideally, I would have a token in one file, say %REPLACEME%, somewhere in the middle of that file, and I would want it replaced with the contents of the 2nd file (which contain multiple lines of text).
I want to do this in MSBUILD, although a Windows Shell solution would suffice, and so would the usage of some 3rd party utility (preferably small, and a single exe).
The solution is trivial if the content of the replacement text file is just one line .. but that is not the case.
Note that I want to AVOID using Powershell, I also want to avoid building my own MsBuild Tasks.
Thanks

You can use the MsBuild Community Tasks which have a RegexReplace task. I use it for my builds without any problem

Related

batch annotation for similar pdf files

I have many pdf files with same layout in which I need to fill in some details with plain text and sign in certain places with company stamp.
I am trying to automate things, so I am after a way to fill in the details + stamp the first file and then "copy-paste" that operation to all files.
I managed to find:
online websites allowing me to annotate one file at a time
documentation on how to use pdftk and additional tools to create a script, but it can take a lot of manual operations via command line (e.g. scaling the signature jpeg file, positioning it, adding text in right location etc.) which is very tedious.
Is there any way to annotate the first file using visual tools (like #1) and then extract a script of commands to perform these annotations from command line ?
I can then use that script on multiple files.
Thank you,
-Moshe

how do I output my code to a single file?

I need to dump all of my code for my project into a single text file. Is this possible in Visual Studio 2010? I haven't been able to find any options for this in VS. Is there a third party program that can do it? Every search I've done just turns up "how to print from VB", but does not address printing my actual code. Even if I have to do it module by module, that would be acceptable, but copying and pasting is a bit much.
Just FYI, I'm not talking about printing output from my program. I'm talking about printing the program itself.
Thanks.
This can be done outside of visual studio. Start a command prompt, cd to your project directory and:
type *.vb >filecontent.txt
If you have multiple project folders, you'll need to do this for each one as the type command doesn't have a /s subfolder type of parameter.
Alternatively, you could create a batch file that changes to each folder and performs the type command to output the file contents.

2 .msi files from one WiX Votive project

As the title says, I want to output 2 .msi files from one project (one is per-user, and the other is per-machine). I have seen in this thread that it can't be done in some conventional way, but perhaps there is a way to do so as some kind of hack in post-build.
I only need to rerun compilation and linking after the original build with slightly changed command line (actually, I need only different Product.wxs file). However, my light and candle command lines are huge, and I would risk making my project hard to maintain if I would hard-code them.
So, in conclusion, I need to know if there is a way to write a command line that would behave the same as Votive does when creating its build command line (getting all the files in project, linking them, passing project dependencies...), only in post build.
P.S.: I also had an idea of getting the whole command line from Votive, and only changing the Product file, that would also help, so if someone has suggestion on how to do it...
Create multiple configurations of your solution / project and set a preprocessor variable to some value for one of the configurations. In your wix source, conditionally include whatever else it is that needs included based on your preprocessor variable.

How can you _create_ a text file in Wix?

Is there any way to create a new text file and write to it using Wix? I have come across elements that will allow me to work with Xml files and Ini files, but nothing for a plain text file.
The root of the problem stems from the fact that we're using a third party library that reads from its own custom configuration file, which really ties my hands as to what the text file can look like. The configuration file is similar to an Ini file, minus the "sections." And I've noticed that Wix handles Ini files by always placing them in the system folder, which won't work for our needs.
The data that needs to be written to the configuration file is gathered at run-time, so there's no opportunity to simply lay down a pre-configured file.
I would be willing to accept a Wix extension to accomplish the same result if one exists, but haven't come across one yet.
There is no built-in feature in Windows Installer for this. You'll have to write code to do it and invoke that code with a custom action.
The IniFile element can write .ini files anywhere; use the #Directory attribute to specify which directory it should go in. If the library ignores [section] lines, you can use anything as the #Section attribute value.
You might want to have a look at this project. It contains the collection of WiX extensions and custom actions, and I suppose it also has CA to read and write text files. Try it out - it is claimed to be tested and proved by using in enterprise installations.

How do I effectively use Batch Scripts?

I would like to create some batch scripts to move some files around. But i was wondering if there are any good resources on how to do this? Do you just use Command Line arguments?
At its simplest level, a batch script is a text file with a .bat extension, and consists of the same commands you would enter at the command line, separated by carriage returns.
Thus, the file:
md C:\HelloWorld
Is a batch script that attempts to create the directory "HelloWorld" on your C: root.
Batch scripts can be much more complex, involving variables and flow control logic, but before you travel that road, you may want to investigate powershell and WSH.
Edit Oops... fixed the link to powershell.
Basically, you just do command-line argument. But there are certain types of variables supported, and also command-line arguments to the batch file, which you can use.
http://www.computerhope.com/batch.htm