Tool: automatic generation of .saproj files

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, Alex.Davies, melvyn.harbour

Tool: automatic generation of .saproj files

Postby Uniwares_AS » Thu Jan 06, 2011 1:32 am

Hi all,
since I am working with SA often on larger solutions where some assemblies have references to 20 or more other assemblies, I also swear often enough about the way SA uses its project files.

Not much fun when you have to update a bunch of project files with references and settings, then do a build on the build server just to find out that some settings didn't work out, or some references are not found, etc.

So, to set an end to my personal dilemma, I looked for a solution and came up with one that will generate the .saproj file automatically on every build.

It basically works by using VS2010's Text Templating (T4) functionality combined with assembly level attributes.
You can define the SA settings for your assembly like this in your AssemblyInfo.cs file:
Code: Select all
[assembly: SA.Obfuscation(FieldsNameMangling=2, NameMangling=2)]
[assembly: SA.ExceptionReporting(AlwaysContinueOnError=0, EmailToBeNotified="test@example.com", ReportExceptions=1, Template="res:{SmartExceptions}.NoUI.dll")]
[assembly: SA.OtherProtections(AddIncorrectMetadata=0, AddMetadataStream=1, SuppressIldasm=1 )]
[assembly: SA.StringsEncoding(Compress=1, Encode=1, UseCache=1, UseImprovedEncoding=1 )]
[assembly: SA.OtherOptimizations(ManageMemory=1, SealClasses=0 )]
[assembly: SA.Debugging(CreatePDB=1)]


Only needs to include a reference to a type-only assembly which defines the SA.* attributes

Before building, the .tt file recreates the .saproj file by reading project information from the current project, resolves assembly references, etc.

This is still work in progress and I am wanting to see if there is interest in a tool like that.

Current features are:
* automatic SA project creation
* detection of code signing and appropriate SA settings
* setting company and application names from the assemblyinfo
* setting SA options through attributes in the AssemblyInfo.cs
* resolution of all references and inclusion into project with full info and path, excluding system references
* a static reference include file (used for standard SA references but can accommodate others too)

Not supported (yet) is:
* exception lists for pruning and obfuscation
* C++ and web projects

I didn't test it yet with VB but it should work too.

If you need any advanced SA features you still can use the tool and modify the created project file by hand or load it into the SA GUI app.

Anyone interested?
Uniwares_AS
 
Posts: 132
Joined: Thu Oct 11, 2007 3:29 pm

Postby Alex.Davies » Fri Jan 07, 2011 12:29 pm

That's cool, I'd be keen to take a look at it, I've never used T4.

You don't need to do the exclusion lists for pruning and obfuscation, I would use custom attributes in the code for that.

If you made it work reliably, I'd definitely sticky your forum post and maybe if you wanted we could link to it from the online help.
Alex
Developer,
Red Gate .NET Tools
Alex.Davies
 
Posts: 335
Joined: Tue Dec 02, 2008 12:23 pm
Location: Cambridge, uk

Postby Uniwares_AS » Fri Jan 07, 2011 5:58 pm

Sure, I'll prepare a download package with description. I was thinking about using attributes for exclusions, probably the best solution anyway.
Probably one could easily turn this into an extension for VS to make it work even more transparent.
Uniwares_AS
 
Posts: 132
Joined: Thu Oct 11, 2007 3:29 pm

Postby Alex.Davies » Fri Jan 07, 2011 6:32 pm

Ha, have you written a vs addin before? :p
Alex
Developer,
Red Gate .NET Tools
Alex.Davies
 
Posts: 335
Joined: Tue Dec 02, 2008 12:23 pm
Location: Cambridge, uk

Postby Uniwares_AS » Fri Jan 07, 2011 7:00 pm

When I look at the amount of addins available for VS2010 I get the impression that it cant be so hard, but then again I might be wrong. But probably I will give it a try when I have a spare hour or so.
Uniwares_AS
 
Posts: 132
Joined: Thu Oct 11, 2007 3:29 pm

Postby Uniwares_AS » Mon Jan 10, 2011 6:50 pm

Ok, took a bit longer as I had to resolve some reflection dll locking problems 8)

Here it is, read the HowTo.txt included in the zip for instructions. And requests or complaints please PM me.

http://df.uniwares.com.br/amanda/CTA75SE8LD
Uniwares_AS
 
Posts: 132
Joined: Thu Oct 11, 2007 3:29 pm


Return to SmartAssembly 5

Who is online

Users browsing this forum: No registered users and 0 guests