Tool: automatic generation of .saproj files
Uniwares_AS
Posts: 168
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:
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?
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:
[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?
Comments
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.
Developer,
Red Gate .NET Tools
Probably one could easily turn this into an extension for VS to make it work even more transparent.
Developer,
Red Gate .NET Tools
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