Author Topic: Creating/Automating a manifest file with VS Post-Build and LiFP  (Read 2635 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Creating/Automating a manifest file with VS Post-Build and LiFP
« on: October 12, 2015, 04:09:57 PM »
A recent thread reminded me that I wanted to take a closer look into Visual Studio, specifically the building process.

I noticed something right away that I thought I'd offer up as a quick tutorial/discussion.

Using this as the basis of our discussion, I thought I'd help streamline the process of creating the manifest. The tutorial calls for you to manually create a text file but doing anything manual is boring and subject to failure (I avoid manual--and automate as much as I can with my build process--because I tend to screw up a lot). Instead of creating the text file in the directory specified (C:\ProgramData\Autodesk\Revit\Addins\2015\) I added a "new item" to Visual Studio in the Solution Explorer (a text file). This just creates the file in my projects directory and allows me to edit in right from VS. I then I went to my project properties and added a post-build event. Something like:
Code: [Select]
xcopy $(ProjectDir)\HelloWorld.addin C:\ProgramData\Autodesk\Revit\Addins\2015\HelloWorld.addin but I'd still be doing some manual editing of the manifest file. *BLEH!* Right away I can see how being limited to native Windowd CMD line tools we will limit our options severely, so here is a little trick you can use in your projects with very little effort on your part.

1. Go grab my LiFP tool and install it (LiFP is just a simple pre-processor which works on any text file).
2. In your manifest: change the "Assembly value" to something like: "<Assembly>[PROJDIR]HelloWorld.dll</Assembly>"
3. In your projects post-build we can use LiFP to automatically change this value for us with the following post-build command:
Code: [Select]
LiFP.exe -d [PROJDIR],$(ProjectDir) -i $(ProjectDir)\HelloWorld.addin -o C:\ProgramData\Autodesk\Revit\Addins\2015\HelloWorld.addin
What this does is use LiFP to swap the text "[PROJDIR]" with the built in Visual Studio Macro "$(ProjectDir)" value when it creates the manifest file in the C:\ProgramData\... folder.

Nice huh?
« Last Edit: October 12, 2015, 04:13:30 PM by John Kaul (Se7en) »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CADbloke

  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: Creating/Automating a manifest file with VS Post-Build and LiFP
« Reply #1 on: October 13, 2015, 05:44:13 PM »
A recent thread reminded me that I wanted to take a closer look into Visual Studio, specifically the building process.
Ah, yeah, sorry about that.


Code: [Select]
LiFP.exe -d [PROJDIR],$(ProjectDir) -i $(ProjectDir)\HelloWorld.addin -o C:\ProgramData\Autodesk\Revit\Addins\2015\HelloWorld.addin
What this does is use LiFP to swap the text "[PROJDIR]" with the built in Visual Studio Macro "$(ProjectDir)" value when it creates the manifest file in the C:\ProgramData\... folder.

Nice huh?
Yes, nice. I like that.

I couldn't find anything about LiFP.exe - what / where is it?

...edit... This may be helpful for those looking for Command Line ways of replacing text... http://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-envir/20999154#20999154
« Last Edit: October 13, 2015, 06:17:55 PM by CADbloke »

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Creating/Automating a manifest file with VS Post-Build and LiFP
« Reply #3 on: October 14, 2015, 07:51:39 AM »
Okay, back on a PC now so I can attempt to make a better reply.

LiFP (Lisp File Preprocessor) is a preprocessor I assembled for the lisp language. I built it to hopefully spark some more team based development projects here on theSwamp and offer a small addition to the lisp language/tools; The VLIDE is a horrible editor/IDE and I was building my own little editor which I needed a "build system" for, LiFP was going to be that backbone. The editor project died a horrible death but LiFP lives on. Although the tool was designed for the lisp language it works on any plain text file (you can use it on source code, text files, html files, etc., etc.).

The powershell suggestion on SO, you linked to, is a pretty good one but I like the power of mine (far many more possibilities with LiFP then powershell+"replace").

If you want to try the method I used in my OP, use the LiFP installer in the thread I linked to above (the 1.7 release will work fine for a test...if you like it, you can replace it with the 2.0 release later).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org