Red Gate forums :: View topic - Tool: automatic generation of .saproj files
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 5
SmartAssembly 5 forum

Tool: automatic generation of .saproj files

Search in SmartAssembly 5 forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
Uniwares_AS



Joined: 11 Oct 2007
Posts: 132

PostPosted: Thu Jan 06, 2011 1:32 am    Post subject: Tool: automatic generation of .saproj files Reply with quote

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:
[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?
Back to top
View user's profile Send private message MSN Messenger
Alex.Davies



Joined: 02 Dec 2008
Posts: 335
Location: Cambridge, uk

PostPosted: Fri Jan 07, 2011 12:29 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Uniwares_AS



Joined: 11 Oct 2007
Posts: 132

PostPosted: Fri Jan 07, 2011 5:58 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message MSN Messenger
Alex.Davies



Joined: 02 Dec 2008
Posts: 335
Location: Cambridge, uk

PostPosted: Fri Jan 07, 2011 6:32 pm    Post subject: Reply with quote

Ha, have you written a vs addin before? :p
_________________
Alex
Developer,
Red Gate .NET Tools
Back to top
View user's profile Send private message
Uniwares_AS



Joined: 11 Oct 2007
Posts: 132

PostPosted: Fri Jan 07, 2011 7:00 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message MSN Messenger
Uniwares_AS



Joined: 11 Oct 2007
Posts: 132

PostPosted: Mon Jan 10, 2011 6:50 pm    Post subject: Reply with quote

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

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
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group