# Monday, November 12, 2007

If you happen to use Dotfuscator by PreEmptive Solutions then you have probably wondered how to integrate this into your automated Team Builds.  They happen to include an MSBuild task for calling the proper command-line functions but don't have much documentation about this feature.

Background Obfuscation Information:  In general, obfuscation prevents reverse engineering of your software by using different techniques to make the MSIL of your .NET compiled application less understandable.  Several different companies use many techniques for doing this including: string encryption, renaming of symbols, control flow manipulation, etc.  If you've ever used Reflector for .NET you know how easy it is to look at reverse-engineered "source code" for a .NET application.

  • Start by putting your Dotfuscator configuration file in the folder that contains your team build script (i.e. TFSBuild.proj) and it to source control.
  • Open up your team build script and edit it.  (Be sure to check it out first.)
    • Start by adding a reference to the proper custom targets file that is provided.  You should have a Dotfuscator Build Machine license installed on the TFS Build Server(s.)  If you got the wrong license version, just ask them for upgrade pricing.

      <Import Project="$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\4.0\PreEmptive.Dotfuscator.Targets" />

 

    • Next, add a section for the Dotfuscator Properties you will need.  You'll notice we have a keys directory that gets pulled down from source control during the build process.  We keep our strong name key in this direcotry and the keydir directory property is for resigning the assemblies after the obfuscation is complete.

        <!-- Properties for Dotfuscate Task-->
        <
      PropertyGroup
      >
          <
      ConfigPath>$(SolutionRoot)\..\BuildType\Dotfuscator.Configuration.xml</ConfigPath
      >
          <
      InputPath>$(SolutionRoot)\..\Binaries\Release</InputPath
      >
        </
      PropertyGroup
      >
        <
      PropertyGroup
      >
          <
      DotfuscatorProperties
      >
            <
      targetdir>$(InputPath)</targetdir
      >
            <
      keydir>$(SolutionRoot)\Keys</keydir
      >
          </
      DotfuscatorProperties
      >
        </
      PropertyGroup
      >
        <
      ItemGroup
      >
          <
      InputAssembly Include="$(InputPath)\*.dll;$(InputPath)\*.exe" Exclude="$(InputPath)\*.vshost.exe"
      />
        </
      ItemGroup
      >  

 

    • Finally, customize the AfterCompile target by adding the Dotfuscate task with appropriate property settings.  See more information about Customizable Team Foundation Build Targets.

        <Target Name="AfterCompile">
          <!--
      Perform obfuscation steps after assemblies are compiled.
      -->
          <
      Dotfuscate InputAssemblies="@(InputAssembly)" Properties="$(DotfuscatorProperties)" ConfigPath="$(ConfigPath)"
      >
            <
      Output TaskParameter="MappingFile" ItemName="DotfuscatorMappingFile"
      />
            <
      Output TaskParameter="ReportFiles" ItemName="DotfuscatorReportFiles"
      />
            <
      Output TaskParameter="OutputAssemblies" ItemName="DotfuscatedAssemblies"
      />
            <
      Output TaskParameter="SatelliteAssemblies" ItemName="DotfuscatedSatelliteAssemblies"
      />
            <
      Output TaskParameter="DebugSymbols" ItemName="DotfuscatedDebugSymbols"
      />
          </
      Dotfuscate
      >
        </Target
      >
  • Next, take some time to edit your Dotfuscator configuration file.  Notice the properties I am using in my sample project below and what is being set in the Dotfuscator properties collection in the Team Build script above.  Basically, I have just cleared the property values out to make sure that the MSBuild task populates them correctly.

    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <!
    DOCTYPE dotfuscator SYSTEM"http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.1.dtd"
    >
    <
    dotfuscator version="2.1"
    >
      <!--
    This is application generated code. Do not edit manually.
    -->
      <
    propertylist
    >
        <
    property name="targetdir" value=""
    />
        <
    property name="keydir" value=""
    />
      </
    propertylist
    >
      <
    global
    >
        <
    option>verbose</option
    >
      </
    global
    >
      <
    input
    >
        <
    asmlist
    >
          <
    inputassembly
    >
            <
    option>library</option
    >
            <
    file dir="${targetdir}" name="Shared.Library.dll"
    />
          </
    inputassembly
    >
        </asmlist>
      </
    input
    >
      <
    output
    >
        <
    file dir="${targetdir}\Dotfuscated"
    />
      </
    output
    >
      <
    tempdir
    >
        <
    file dir="${targetdir}\Dotfuscated"
    />
      </
    tempdir
    >
      <
    renaming
    >
        <!--
    <mapping>
          <mapoutput overwrite="false">
            <file dir="${targetdir}\Dotfuscated" name="DotfuscatorMapFile-KeepSecure.xml" />
          </mapoutput>
        </mapping>
    -->
      </
    renaming
    >
      <
    controlflow level="high"
    />
      <
    stringencrypt
    >
        <
    includelist
    >
          <
    assembly
    >
            <
    file dir="${targetdir}" name="Shared.Library.dll"
    />
          </
    assembly
    >
        
    </includelist>
      </
    stringencrypt
    >
      <
    signing
    >
        <
    resign
    >
          <
    option>dontuseattributes</option
    >
          <
    key
    >
            <
    file dir="${keydir}" name="StrongName.key"
    />
          </
    key
    >
        </
    resign
    >
      </
    signing
    >
    </
    dotfuscator>
     
  • That's it.  Finally, just customize it to your heart's content!

 

Feel free to let me know if I can improve this in any way!  I'm always looking to efficiently refactor our Team Build scripts.

 

Ed B.

posted on Monday, November 12, 2007 11:17:54 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2] Trackback

I'm excited to announce that we have finally released a free tool to help you visualize resource usage in your WPF applications.  Kudos to the team on a job well done!

Pistachio helps you by:

  • Seeing what resources are being used.
  • Finding unused resources.
  • Displaying the types of resources being used.
  • Filtering, Sorting, etc.
  • Cool Visualizations of Usage

If you were at either of my talks at Boston ReMix or Tulsa Tech Fest you got a pre-release preview but now it's all ready for you to use!  Please let us know if you have any suggestions or problems while using.  There are several more features being planned so let us know what's important to you.

DOWNLOAD HERE:  Pistachio - WPF Resource Visualizer

 

Ed B.

posted on Monday, November 12, 2007 5:26:20 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Thursday, November 01, 2007

Ever since I started at Infragistics, I had been working in the User Experience Group (under the Evangelism umbrella) primarily with WPF & WinForms.  As some of you know, I wasn't too fond with WPF at the beginning :) but now I love it.  [Shameless Plug:  Have you checked out Tangerine?  See my blog post about it.]

I have taken a new position now as what is usually referred to as the Configuration Manager (HR Title:  Configuration and Process Improvement Engineer.)

As some of you know, I have been working with Team Foundation Server since pre-beginning (is that a word?) like during the Betas.  [Strolls down memory lane... Anyone remember the Beta 2 to Beta 3 upgrade? whew... Ed K. remembers that day with the 3-hour phone call from the TFS Product Team.  Those were the days. I got a cool TFS All Stars shirt from it though!]  I digress.  Infragistics has decided to adopt TFS and planning to migrate pretty much all of our separate systems to it.  So, that's what I'm doing now in the Engineering department!  Although I'll be missing doing WPF and Evangelism work, I'm pretty excited about getting to do TFS stuff full-time.

If you were at Grant and I's talk at Boston ReMix or my talk at Tulsa Tech Fest, you got the preview of a community WPF application that we're working on to gather data from TFS and replace our Release Status Wall.  It's basically an application to visualize your release process.  As soon as we get something ready to preview, I'll definitely post up on here.  So I get to put my love of both WPF and TFS together!  Grant's a God-send when it comes to making applications look great. I'm really blessed to be working for a company that has a dedicated Visual Design team... We have 5 dedicated Visual Designers now... wow.

Another one of my goals with our new system of tracking development data is to provide more transparency to our customers in regard to feature tracking, bugs, etc.  I think it's important (as a previous customer) to be able to have that kind of transparency.  I'm thinking something along the line of Microsoft's Connect website.

So I look forward to being able to talk more about TFS and coming out with some exciting tools and information.  Don't worry, I still do WPF development too so you'll still see me from time to time blogging about it and speaking.  I just finished up a WPF magazine article yesterday even :)

 

BTW... I'll be in DevConnections next week in Las Vegas doing some WPF Evangelism stuff so be sure to hit me up if you'll be in town!

 

Ed B.

posted on Thursday, November 01, 2007 4:30:06 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback