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)|$(Platfo rm)' == 'Release|AnyCPU' ">
<CreateProperty Value="true">
<Output TaskParameter="Value" PropertyName="Obfuscate" />
</CreateProperty>
</Target>
<Target Name="AfterCompile" Condition=" '$(Obfuscate)' != '' ">
<Exec Command=""C:\Program Files\Microsoft Visual Studio 9.0\Application\PreEmptive Solutions\Dotfuscator Community Edition\dotfuscator.exe&qu ot; -q Dotfuscator.xml" />
<Copy SourceFiles="$(ProjectDir) Dotfuscate d\$(Target FileName)" DestinationFiles="$(Interm ediateOutp utPath)$(T argetFileN ame)" />
</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 ????
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)|$(Platfo
<CreateProperty Value="true">
<Output TaskParameter="Value" PropertyName="Obfuscate" />
</CreateProperty>
</Target>
<Target Name="AfterCompile" Condition=" '$(Obfuscate)' != '' ">
<Exec Command=""C:\Program Files\Microsoft Visual Studio 9.0\Application\PreEmptive
<Copy SourceFiles="$(ProjectDir)
</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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Ok, now I understand, you are integrating DotFuscator into ClickOnce. I searched in google and it looks OK Maybe the Exec Command is wrong.
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..
According to this, your xml is correct:
http://www.windowsdevelop.com/clickonce-setup--deployment-projects/needed-tutorial-with-vs2005msbuild-dotfuscator-ce-satellite-assemblies-16985.shtml
http://www.windowsdevelop.com/clickonce-setup--deployment-projects/needed-tutorial-with-vs2005msbuild-dotfuscator-ce-satellite-assemblies-16985.shtml
ASKER
Do you know if there is any way to check/verify whether Copy task is executing right ?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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) Dotfuscate d\$(Target FileName)" DestinationFiles="$(Interm ediateOutp utPath)\$( TargetFile Name)" />
<Copy SourceFiles="$(ProjectDir)
ASKER
Driving now . Will try in a few minutes :))
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
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
ASKER
Turns out even the professional edition is not very ClickOnce efficient. But i appreciate every answer.
ASKER
Answers were helpful but i had to resort to using Smart Assembly Obfuscator.
ASKER