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 ????
.NET ProgrammingC#

Avatar of undefined
Last Comment
dotnetpro
ASKER CERTIFIED SOLUTION
Avatar of saragani
saragani

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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...
Avatar of saragani
saragani

Ok, now I understand, you are integrating DotFuscator into ClickOnce. I searched in google and it looks OK Maybe the Exec Command is wrong.
Avatar of dotnetpro
dotnetpro

ASKER

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..
Avatar of dotnetpro
dotnetpro

ASKER

Do you know if there is any way to check/verify whether Copy task is executing right ?
SOLUTION
Avatar of saragani
saragani

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of dotnetpro
dotnetpro

ASKER

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
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of dotnetpro
dotnetpro

ASKER

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)" />
Avatar of dotnetpro
dotnetpro

ASKER

Driving now . Will try in a few minutes :))
Avatar of dotnetpro
dotnetpro

ASKER

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
Avatar of dotnetpro
dotnetpro

ASKER

Turns out even the professional edition is not very ClickOnce efficient. But i appreciate every answer.
Avatar of dotnetpro
dotnetpro

ASKER

Answers were helpful but i had to resort to using Smart Assembly Obfuscator.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo