Re: Dotfuscator and ClickOnce



<Target Name="AfterCompile">
<Exec Command="path\Dotfuscator /in:
$(IntermediateOutputPath)appname.exe /out: $(IntermediateOutputPath) "/>
</Target>

This does not work with the Dotfuscator Community Edition shipped with Visual Studio 2005.

v-lliu@xxxxxxxxxxxxxxxxxxxx (Linda Liu[MSFT]) wrote:

Hi Stewart,

After spending several hours on this issue, I find a better solution to
your problem.

Firstly, Visual Studio uses MSBuild to build and publish ClickOnce
applications. Please read the following MSDN documents for information on
MSBuild:

"MSBuild Overview"
http://msdn.microsoft.com/en-us/library/ms171452.aspx

"MSBuild Targets"
http://msdn.microsoft.com/en-us/library/ms171462.aspx

"MSBuild Tasks"
http://msdn.microsoft.com/en-us/library/ms171466.aspx

Secondly, every Visual Studio project imports the Microsoft.Common.targets
file, which describes the steps to build and publish an application in
common. The Microsoft.Common.targets file resides in the
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\. Open this file with Notepad
and you can see the detailed information on the tasks performed when you
build and publish an application with Visual Studio.

As you can see, there're targets called Build and PublishOnly in the
Microsoft.Common.targets file. Visual Studio uses these two targets to
build and publish projects. The Build target build the project and generate
ClickOnce manifests. So we need to do the obfuscation after the main
assembly is generated and before the ClickOnce manifests are created.

Fortunately, there's a AfterCompile target, which is built after the
Compile target (which means the main assembly has been generated), and
before the GenerateManifets target (which will generate ClickOnce
manifests). The solution is to add a task inside the "AfterCompile" target
to the project file to call the Dotfuscator command line. Open the project
file with Notepad and add the following snippet after the <Import
Project="$(MSBuildBinPath)\Microsoft.CSharp.targets"/>:

<Target Name="AfterCompile">
<Exec Command="path\Dotfuscator /in:
$(IntermediateOutputPath)appname.exe /out: $(IntermediateOutputPath) "/>
</Target>

Save the project file and reload the project in Visual Studio. Clear and
publish the project within Visual Studio. You should see the generated
executable is obfuscated and then published successfully.

In addition, you can execute the MSBuild command in Visual Studio 2005
Command Prompt to build and publish the project. It's equivalent to
building and publishing within VS and what's important is that you can see
detailed information when MSBuild builds and publishs the project which is
always useful. The command line looks like:
msbuild path\projectname.csproj /t:build, publishonly

Please try my suggetion to see if there's any problem.

Sincerely,
Linda Liu
Microsoft Online Community Support
.



Relevant Pages

  • Re: Dotfuscator and ClickOnce
    ... Visual Studio uses MSBuild to build and publish ClickOnce ... Fortunately, there's a AfterCompile target, which is built after the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Dotfuscator and ClickOnce
    ... Running Dotfuscator with Target ... Visual Studio uses MSBuild to build and publish ClickOnce ... building and publishing within VS and what's important is that you can see ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Dotfuscator and ClickOnce
    ... if you open the project's properties and do anything Dotfuscator gets kicked off ... Visual Studio uses MSBuild to build and publish ClickOnce ... The Build target build the project and generate ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Reading an Excel file using Jet.Oledb.4.0
    ... I am recompiling and running the program as a ... So I guess the question is, how do I register the Jet.OleDB.4.0 ... components on the target machine. ... because this is a common problem for users of dotNet Visual Studio ...
    (microsoft.public.data.ado)
  • Re: Visual Basic 6 Program Wont Start on Other Machine
    ... A colleague at work pointed out that ... the "depends.exe" tool included with Visual Studio 6 has been updated ... "profile" the DLL loads and calls while your program is running. ... not like the video card on the target. ...
    (comp.lang.basic.visual.misc)

Loading