Using post sharp with web projects?

Questions about integration in Visual Studio, MSBuild or other IDEs or build tools.

Re: Using post sharp with web projects?

Postby gfraiteur on Thu Jun 07, 2007 2:04 pm

Don't be afraid, there is not a single drop of IL in this task. It's just about adding a PostSharp step after CSharpCodeProvider (develop what is called a 'PostSharp Host').

I've learnt IL from the specs. Another good way to learn is to execute the sample PostSharp.Samples.Explorer and see how a .NET assembly looks like inside.
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Using post sharp with web projects?

Postby JonCubed on Wed Sep 26, 2007 7:05 am


Gael can you explain it a bit more? What would I be required to do to add it to a VB web program?
Jonathan Kuleff
JonCubed
 
Posts: 1
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Jonathan Kuleff

Re: Using post sharp with web projects?

Postby gfraiteur on Wed Sep 26, 2007 9:35 am

It would be needed to create its own code provider that calls the VB code provider for most of the job, but then invokes PostSharp. For information about invoking PostSharp, see the projects PostSharp.Console or PostSharp.MSBuild.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Using post sharp with web projects?

Postby louis210 on Tue Feb 26, 2008 10:09 pm

Gael,

I've read the various blogs, FAQs, and forums on postsharp.org and have spent most of the past two days scouring the internet trying to figure out how I can use PostSharp to integrate tracing calls into methods on .aspx pages.

Using your demonstration video as well as various tutorials, I've created a very nice tracing attribute to work with log4net that works perfectly. I understand that there may be no "automated" way right now for PostSharp to be part of the compilation process when an aspx page is changed, but is it at all possible to tell VS (or use MSBuild) to manually recompile the web pages using PostSharp?

Merci beaucoup,
Louis
louis210
 
Posts: 6
Joined: Tue Feb 26, 2008 9:55 pm
Full Name: Louis

Re: Using post sharp with web projects?

Postby gfraiteur on Tue Feb 26, 2008 10:12 pm

I guess you can pre-compile the website and PostSharp it using the command-line utility. See http://www.postsharp.org/blog/2008/01/u ... ation.html. I ignore if it is possible to automate this step in Visual Studio. Any feedback would be welcome.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Using post sharp with web projects?

Postby louis210 on Tue Feb 26, 2008 11:30 pm

I've successfully precompiled the website such that I now have a bin directory with
  • App_Code.dll
  • App_global.asax.dll
  • a series of files that look like
    App_Web_[original aspx filename].aspx.[8-digit hex code].dll
  • (one for each original aspx page)
  • App_Web_site.master.[8-digit hex code].dll
So far, so good.

However, it looks like the command-line parameters for PostSharp.exe require a project name such as *.csproj. Of course, a web app doesn't have such a file; it's just a bunch of pages sitting in a directory.

So, let's say that I want to PostSharp one of the DLLs, App_Web_default.aspx.[8-digit hex code].dll. What would be the appropriate way to call PostSharp.exe without a project file?
louis210
 
Posts: 6
Joined: Tue Feb 26, 2008 9:55 pm
Full Name: Louis

Re: Using post sharp with web projects?

Postby gfraiteur on Wed Feb 27, 2008 8:33 am

You should use the default project file.

Please, read the blog item I referred to.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Using post sharp with web projects?

Postby louis210 on Wed Feb 27, 2008 5:39 pm

My apologies...I misunderstood the purpose of the Default.psproj file. I should have caught that. I guess I needed more coffee!

I've got it working now and have written a couple batch files to speed up / automate the steps.

Where would be a good spot to post a generic walkthrough of how to process web pages with PostSharp as well as the text of the batch files?

Thank you again,
Louis
louis210
 
Posts: 6
Joined: Tue Feb 26, 2008 9:55 pm
Full Name: Louis

Re: Using post sharp with web projects?

Postby gfraiteur on Wed Feb 27, 2008 5:47 pm

I suggest you have a look at the interface IAssemblyPostProcessor. I will try to base a generic solution base on that.

It's quite work to make a generic and deployable solution, but it is pretty easy to make an ad-hoc workaround.

Let me know how it'll result.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Using post sharp with web projects?

Postby gfraiteur on Wed Feb 27, 2008 10:30 pm

It was easier than expected.
You can download a first version of the code from http://postsharp-user-plugins.googlecod ... rp.AspNet/ (using an SVN client).

I will document and blog about this once the code will cleaner and more stable.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

PreviousNext

Return to Integration with IDE and Build Scripts


cron