Re: Dotfuscator and ClickOnce



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
    ... file in the ClickOnce application's application files when publishing the ... GenerateManifests target won't be skipped after the BeforePubish target is ... If I do this while running in the IDE won't the publication process copy them to the web site? ... MSBuild command doesn't do this work(VS IDE copies the ClickOnce ...
    (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: Dotfuscator and ClickOnce
    ... This does not work with the Dotfuscator Community Edition shipped with Visual Studio 2005. ... Visual Studio uses MSBuild to build and publish ClickOnce ... Fortunately, there's a AfterCompile target, which is built after the ... building and publishing within VS and what's important is that you can see ...
    (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: Thinking Clearly
    ... I agree and thank Brian, I wasn't aware of that excellent link. ... Actually it's msbuild that's the key that unlocks everything. ... Visual Studio installed - msbuild comes as part of the WinFX SDK. ... of benefit to, and easily consumable by, Highlander developers. ...
    (borland.public.delphi.non-technical)

Loading