If one will release a ClickOnce version, how can it be obfuscated by Dotfuscator?
To disable ClickOnce security settingsClick the Security tab. Clear the Enable ClickOnce Security Settings check box. Your application will be run with the full trust security settings; any settings on the Security page will be ignored.
In the Specific target page, select ClickOnce. Enter a path or select Browse to select the publish location. In the Install location page, select where users will install the application from. In the Settings page, you can provide the settings necessary for ClickOnce.
Application reference file used by ClickOnce, a Microsoft platform used to deploy and run remote Web applications; contains a local or remote link to an application; commonly used to enable links from the Windows Start Menu.
You can use the commercial version of Dotfuscator to automatically obfuscate a ClickOnce application by adding the deployment manifest ("foo.application") as an input to your Dotfuscator project. Dotfuscator will allow you to add any necessary exclusions to the assemblies contained in the ClickOnce application and will create updated deployment and application manifests containing the obfuscated assemblies.
The free version of Dotfuscator included in Visual Studio (including Visual Studio 2010) does not have the feature to automatically obfuscate ClickOnce applications. In order to get a functioning obfuscated ClickOnce application you will need to recreate or update the ClickOnce manifests since obfuscation changes the signatures of the assemblies.
You can use mage.exe or mageui.exe (included in the Windows/.NET SDK) to update the ClickOnce manifests. If you are going to use mage.exe you need to be aware that you cannot use the "Use .deploy file extension" option in your ClickOnce options as it does not recognize it.
Assuming your ClickOnce application is named "Foo" and is at version 1.0.0.0 the process you will want to follow is:
Update the application manifest and resign it:
mage.exe -Update "Application Files\Foo_1_0_0_0\Foo.exe.manifest" -CertFile "c:\Foo\foo.pfx" -Password password
Update the deployment manifest and resign it:
mage.exe -Update Foo.application -AppManifest "Application Files\Foo_1_0_0_0\Foo.exe.manifest" -CertFile "c:\Foo\foo.pfx" -Password password
You now have a valid application and deployment manifest using obfuscated assemblies. You can also use the MageUI.exe tool to accomplish the same tasks (and it knows how to handle assemblies with the .deploy extension) but it is not as easy to automate.
I have a solution similar to Joe Kuemerle's, but before the publish process. This works with publish in Visual Studio and MSBuild command line.
Add the BeforePublish target to the project file.
<ItemGroup>
<ClickOnceFiles Include="bin\Release\ClickOnce.*"/>
</ItemGroup>
<Target Name="BeforePublish">
<Exec Command="{path to dotfuscator}\dotfuscator.exe Dotfuscator.xml" />
<Exec Command="mage.exe -u bin\Release\ClickOnce.exe.manifest" />
<Exec Command="mage.exe -u bin\Release\ClickOnce.application -AppManifest bin\Release\ClickOnce.exe.manifest" />
<Copy SourceFiles="@(ClickOnceFiles)" DestinationFolder="obj\Release" OverwriteReadOnlyFiles="True" />
</Target>
The ClickOnce files are ClickOnce.application
, ClickOnce.exe
, and ClickOnce.exe.manifest
. My dotfuscator.xml
is in the same folder with the project file. The key is the last command, copy the ClickOnce files to the obj
folder.
I don't know whether this is only possible in later versions of Visual Studio but for me it works perfectly:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With