Link to home
Start Free TrialLog in
Avatar of dotnetpro
dotnetpro

asked on

MSBuild Obfuscation

Experts,

I am using C# 2008 to write my WPF application and i publish using ClickOnce. I am using following updates to the .csproj file to obfuscate the .exe after compilation
 <Target Name="BeforeRebuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <CreateProperty Value="true">
      <Output TaskParameter="Value" PropertyName="Obfuscate" />
    </CreateProperty>
  </Target>
  <Target Name="AfterCompile" Condition=" '$(Obfuscate)' != '' ">
    <Exec Command="&quot;C:\Program Files\Microsoft Visual Studio 9.0\Application\PreEmptive Solutions\Dotfuscator Community Edition\dotfuscator.exe&quot; -q Dotfuscator.xml" />
    <Copy SourceFiles="$(ProjectDir)Dotfuscated\$(TargetFileName)" DestinationFiles="$(IntermediateOutputPath)$(TargetFileName)" />
  </Target>

But in the published version when i use ILDASM to look at the .exe its not obfuscated..I think its the Copy task that is not woking...Any ideas as to either how can else can i obfuscate my .exe or any way to check whether Copy is working or not ????
ASKER CERTIFIED SOLUTION
Avatar of saragani
saragani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dotnetpro
dotnetpro

ASKER

I am trying to make a strong case for that. But i had written a sample "Hello World" app and i tried to obfuscate...which actually did and now the same app is not obfuscated anymore....I am pretty sure it did at that time and not anymore is killing me...
Ok, now I understand, you are integrating DotFuscator into ClickOnce. I searched in google and it looks OK Maybe the Exec Command is wrong.
Ok..when i right click on the project and rebuild ...it opens the Dotfuscator CE edition and prompts me Obfuscate...i obfuscate and close the Dotfuscator window that's when the rebuild completes. But its supposed to sign, create manifests and publish the dotfuscated assembly where as it does that with the non-obfuscated one..
Do you know if there is any way to check/verify whether Copy task is executing right ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In the Dotfuscated folder created by the Dotfuscator.exe the target .exe is obfuscated. If i rebuild instead of Publish then i see in bin/Release, the .exe is obfuscated...Only when i publish it , its not obfuscated...I am still scratching my head..
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think that's what the Copy task in the XML is supposed to do.But not sure if that is happening because published exe is not obfuscated
It doesn't sound like it is doin what you want.
On your copy path your not adding a "\", so try replacing it with this.

    <Copy SourceFiles="$(ProjectDir)Dotfuscated\$(TargetFileName)" DestinationFiles="$(IntermediateOutputPath)\$(TargetFileName)" />
Driving now . Will try in a few minutes :))
Still the same.. Here is the sequence of events...
1 Built a sample App called ApptoDeploy
2 Updated the .CSPROJ file with XML  and saved.
3 Compiled project and changed to "Release" mode.
4 Created Dotfuscated.xml file by pointing the dotfuscator CE to the ApptoDeply.exe under obj/Release folder.
5 Then rebuilt the project which opened up the dotfuscator.exe application. I ran the dotfuscator which created Dotfuscated folder with ApptoDeploy.exe and Map.xml as contents of it.
5 Then published it to http://localhost/ApptoDeploy.
6 Checked the published version's Application Files and ApptoDeploy.exe.deploy as shown in ILDASM is still unobfuscated..


 Checked the ApptoDeploy.exe.deploy under ILDASM and it still shows
Turns out even the professional edition is not very ClickOnce efficient. But i appreciate every answer.
Answers were helpful but i had to resort to using Smart Assembly Obfuscator.