With Web Deployment Project

Last post 03-28-2008 1:37 PM by Vinny Davi. 14 replies.

Sort Posts:

  • With Web Deployment Project

    05-18-2006, 4:58 AM
    • Loading...
    • ZeroCoolJr
    • Joined on 05-18-2006, 8:38 AM
    • Posts 2
    Hi!

    Does the Web Application Project supports compiling pages on its own dll?

    I tried using the Web Deployment Project with a WebSite Project and it seems it can compile the pages into their own dll. But with the Web Application Project, the option "Create a separate assembly for each page and control output" doesn't work. It this how it is supposed to work? By the way, the output of the Web Deployment Project is only the Primary Output of the Web Application Project excluding the Content Files. I thought the output of the Web Deployment Project is the deployable part?

    Please point me to the right direction or to where I can get some information about this.

    Thanks.
  • Re: With Web Deployment Project

    05-19-2006, 11:07 AM
    • Loading...
    • BradleyB
    • Joined on 11-06-2002, 3:53 PM
    • Posts 225

    Excellent question.  Web Deployment Projects leverage two utilities aspnet_compiler.exe and aspnet_merge.exe.

    aspnet_compiler.exe ships with the 2.0 Fx and pre-compiles an entire web site using the same compilation system as ASP.NET.  Instead of just caching the pre-compiled bits into the ASP.NET temporary files folder it puts the files into re-deployable folder.

    aspnet_merge.exe is a utility that ships with Web Deployment Projects.  Because the aspnet_compiler.exe produces numerous assemblies, this utility offers various options to merge the aspnet_compiler generated assemblies into a smaller set of assemblies or even a single assembly.

    So how does this relate to Web Application Projects?

    Web Application Projects allows you to pre-compile the code behind and other classes with Visual Studio 2005 into a single assembly and supply this assembly as an input in the ASP.NET compilation process by putting it in the ~/bin folder.

    When using WAP there are two stages to the compilation process.  (This is the same as VS03).  The first stage is to use VS to compile all the code behind and other classes into a single assembly and deploy it to the ~/bin folder.  All the code in the .aspx, .ascx, .master, etc.. is always generated and compiled by ASP.NET, either dynamically during an http request or when using the aspnet_compiler.exe. 

    When ASP.NET is generating the code for each page, it’s looking at the “<%@ Page” directive and either seeing CodeFile="file" or CodeBehind="file".  This is a key distinction.  If it’s a CodeFile attribute ASP.NET knows it’s responsible for the compilation of the code behind code.  This is what is used for Web Site projects included in VS05.  If it’s a CodeBehind attribute ASP.NET knows the code behind has already been compiled and all it has to do is derive the page class from an already compiled code behind assembly.  This is what is used in Web Application Projects and VS03.

    Finally, I’m going to attempt to answer your question about Web Deployment Projects and assemblies per page.  The ability to produce an assembly per page is a feature of the ASP.NET compilation system.  When it is compiling pages it has the ability to batch pages together when generating an assembly or to generate an assembly per page.  That is provided ASP.NET is doing the compilation.  In the case of Web Application Projects the code behind for the pages have already been compiled into a single assembly.  All ASP.NET has left to do is to generate the code for each page/control and generate the assemblies for those.  If you’ve decided to make the deployable site updateable then the aspnet_compiler won’t even do that so the pages/controls can be edited and dynamically recompiled on the site.  If it’s not updateable you can still get an assembly per page containing just the page class generated by ASP.NET and not the code behind since it’s already been compiled by VS.

    I apologize for such as long winded reply but understanding what is being compiled when really helps understand the deployment options.

    Hope this helps
    Brad.

     

  • Re: With Web Deployment Project

    05-21-2006, 9:55 PM
    • Loading...
    • ZeroCoolJr
    • Joined on 05-18-2006, 8:38 AM
    • Posts 2
    Brad, thanks for the explanation on the difference between these two projects. But I still don't get exactly if it is possible to generate separate assemblies per page on a Web Application Project. As far as your statement is concern, it's possible, but how I may going about it? I was hoping there is that same option as with the Web Deployment Project on a WebSite Project...

    By the way, I was hoping that instead sending the whole website for an update, I only need to send the pages/dlls that are only updated cutting unnecessary downloading/uploading files. Or do you have any suggestion implementing this `plug n play` sort of deployment? Or is this possible with ASP.NET without a downtime or a server restart?

    Thanks,
    Win
  • Re: With Web Deployment Project

    05-22-2006, 1:52 AM
    • Loading...
    • jcnovoa
    • Joined on 02-26-2003, 9:42 PM
    • Posts 10
    Same here... as a side-effect of using a single assembly in the build, you can't use multiple languages (i.e. C# & VB.Net) to put pages together in a WebApplicaiton as you could in a WebSite application. Can we have the cake and eat it too by using the old format yet enable single page assembly generation?
  • Re: With Web Deployment Project

    05-22-2006, 7:57 PM
    • Loading...
    • BradleyB
    • Joined on 11-06-2002, 3:53 PM
    • Posts 225

    Web Application Projects always compile the entire project into a single assembly.  The only way to truly get an assembly per page (complete with it's code behind file) is to use a Web Site project and a Web Deployment project.

    I suspose that if you use inline code for all your pages and not code behind the yes you could generate a seperate assembly for every page in a WAP project but that kind of defeats the purpose.

    As far as multiple languages, That's a cool feature of Web Sites and dynamic compilation.  I know that some developers are factoring their sites up into several WAP projects all building into the same bin.  Each project is a seperate assembly.  While not an assembly per page is does give you the ablity to factor you site into seperate serviceable units.  The other nice thing is that each project could be in a different language from the others.  While not mixing languages within a project you are using multiple projects within a Site.

    Hope this helps,
    Brad.

  • Re: With Web Deployment Project

    05-23-2006, 1:37 AM
    • Loading...
    • maharik
    • Joined on 02-03-2006, 1:50 AM
    • Posts 6

    Bradley,

    How does the build process get affected when using a Web Deployment Project with the Web Application Project in a team build environment?

    I am choosing the option of merging all the dlls into one in the web deployment project (which I believe is supported for the WAP?) but I am having a weird error related to type loading when trying to run a standard team build for the WDP project. In visual studio, the solution builds fine and the WDP does seem to play well with the WAP. Based on the errors, it seems that the WDP AspNetCompiler target is having problems loading user controls used on my pages. User controls are defined in a separate folder and namespace in the WAP.

    Here is a sample ascx heading of one of my controls:

    <%

    @ Control Language="C#" AutoEventWireup="true" Inherits="Corp.Security.Web.Controls.ApplicationsCombo" Codebehind="ApplicationsCombo.ascx.cs" %>

    And a sample registration from one of the pages that use the control:

    <%

    @ Register TagName="ApplicationsCombo" TagPrefix="local" Src="~/Controls/ApplicationsCombo.ascx" %>

    The errors from the team build are below. I would really appreciate any help on this.

    Thanks

    Mario

     

    The errors I get when doing a team build are:


    Target AspNetCompiler:
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /Corp.Security.Web.csproj -p c:\TFSBuilds\Corp.SecIt\Corp.Security.WeeklyDevTestBuild\Sources\Applications\Corp.Security\Corp.Security.Web -u -f c:\TFSBuilds\Corp.SecIt\Corp.Security.WeeklyDevTestBuild\Binaries\Release\_PublishedWebsites\Corp.Security.Web.Deploy\
    /Corp.Security.Web.csproj/SecurityLogin.aspx(1): error ASPPARSE: Could not load type 'SecurityLogin'.
    /Corp.Security.Web.csproj/Controls/CompaniesCombo.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.CompaniesCombo'.
    /Corp.Security.Web.csproj/Controls/ApplicationsCombo.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.ApplicationsCombo'.
    /Corp.Security.Web.csproj/Controls/WebsiteVersion.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.WebsiteVersion'.
    /Corp.Security.Web.csproj/SecurityLogin.aspx(46): error ASPPARSE: Unknown server tag 'local:WebsiteVersion'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(1): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/Controls/WebsiteVersion.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.WebsiteVersion'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(30): error ASPPARSE: Unknown server tag 'local:WebsiteVersion'.
    /Corp.Security.Web.csproj/Applications/EditApplication.aspx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Applications.EditApplication'.
    /Corp.Security.Web.csproj/Applications/EditApplication.aspx(3): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(1): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/Controls/WebsiteVersion.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.WebsiteVersion'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(30): error ASPPARSE: Unknown server tag 'local:WebsiteVersion'.
    /Corp.Security.Web.csproj/Applications/CreateApplication.aspx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Applications.CreateApplication'.
    /Corp.Security.Web.csproj/Applications/CreateApplication.aspx(3): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(1): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/Controls/WebsiteVersion.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.WebsiteVersion'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(30): error ASPPARSE: Unknown server tag 'local:WebsiteVersion'.
    /Corp.Security.Web.csproj/Applications/AddUsersToApplication.aspx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Applications.AddUsersToApplication'.
    /Corp.Security.Web.csproj/Applications/AddUsersToApplication.aspx(5): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(1): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/Controls/WebsiteVersion.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.WebsiteVersion'.
    /Corp.Security.Web.csproj/CorpSecurityMasterPage.master(30): error ASPPARSE: Unknown server tag 'local:WebsiteVersion'.
    /Corp.Security.Web.csproj/Applications/Applications.aspx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Applications.Applications'.
    /Corp.Security.Web.csproj/Applications/Applications.aspx(2): error ASPPARSE: Could not load type 'CorpSecurityMasterPage'.
    /Corp.Security.Web.csproj/Controls/ApplicationsCombo.ascx(1): error ASPPARSE: Could not load type 'Corp.Security.Web.Controls.ApplicationsCombo'.
    /Corp.Security.Web.csproj/Applications/Applications.aspx(18): error ASPPARSE: Unknown server tag 'local:ApplicationsCombo'.
    Done building target "AspNetCompiler" in project "Corp.Security.Web.Deploy.wdproj" -- FAILED.

    Done building project "Corp.Security.Web.Deploy.wdproj" -- FAILED.

     

     

  • Re: With Web Deployment Project

    05-23-2006, 9:23 PM
    • Loading...
    • BradleyB
    • Joined on 11-06-2002, 3:53 PM
    • Posts 225

    WAP and WDP don't quite work together in a Team Build environment.   This is because the OutDir is redirected during a Team Build run.  Consequently the WAP .dll is not in the projects ~/bin folder and WDP which is just using the aspnet_compiler.exe can't find the expected .dlls in the ~/bin.

    I did a quick test and you can fix this by modifying your WDP project file.  Let's say you have a WDP project building a WAP project named WebApplication1.  In the WDP project file you will find a property defined as follows:

    <SourceWebPhysicalPath>..\WebApplication1</SourceWebPhysicalPath>

    This is the path that will be passed to the aspnet_compiler.  When OutDir is redefined then this path won't work.  Instead you'll need to build agains the WAP output path.  That property is not available to WDP  but you can compute it.

    Replace the line above with this new defination for <SourceWebPhysicalPath>

    <SourceWebPhysicalPath Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)_PublishedWebsites\WebApplication1</SourceWebPhysicalPath>
    <SourceWebPhysicalPath Condition="'$(OutDir)' == '$(OutputPath)'">..\WebApplication1</SourceWebPhysicalPath>

    What this is doing is saying if the OutDir no longer matches the OutputPath, ie. it was redefined then set the SourceWebPhysicalPath to be where the WAP proejct is going to copy its files.

    If OutDir was not renamed then the above code will set it to the origional value.

    Hope this helps,
    Brad.

  • Re: With Web Deployment Project

    05-23-2006, 11:24 PM
    • Loading...
    • maharik
    • Joined on 02-03-2006, 1:50 AM
    • Posts 6

    Bradley,

    Thank you for your response; this seems to be a much better solution than the hack I had figured out; which is to add the following to the WAP's after build target:

    <Target Name="AfterBuild">

    <Exec Command="xcopy /y &quot;$(TargetDir)*.dll&quot; &quot;$(ProjectDir)bin\&quot;" />

    </Target>

    The problem with my approach is that it relies on changing the WAP's csproj which I don't like doing as it is the project other developers work with.

    I like your approach since I can only change the WDP which is in an isolated build solution.

    I still have a problem though, whenever I replace the line of code you indicated, the build fails complaining about: _PublishedWebsites\Corp.Security.Web not existing.

    ASPNETCOMPILER : error 1003: The directory 'c:\TFSBuilds\Corp.Security\Corp.Security.WeeklyDevTestBuild\Binaries\Release\_PublishedWebsites\Corp.Security.Web' doesn't exist.

    So I tried to compile the WAP project by itself (without building the WDP) and it seems the WAP doesn't copy all its files to \_PublishedWebsites\ with a successful install. Is that supposed to be its normal behavior? can you think of any reason why it is not copying the contents to the _PublishedWebsites folder although the build is successful? I can see the .dlls build by WAP in the Binaries\Release folder. Please let me know if this question has to go to the WAP forum.

    Once again, thank you for your help.

    Mario

     

     

  • Re: With Web Deployment Project

    05-24-2006, 12:42 PM
    • Loading...
    • BradleyB
    • Joined on 11-06-2002, 3:53 PM
    • Posts 225

    Take a look at Microsoft.WebApplication.targets.

    You should the following PropertyGroup.

     <PropertyGroup>
      <WebProjectOutputDir Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)_PublishedWebsites\$(MSBuildProjectName)</WebProjectOutputDir>
      <WebProjectOutputDir Condition="'$(OutDir)' == '$(OutputPath)'">$(MSBuildProjectDirectory)</WebProjectOutputDir>
     </PropertyGroup>

    If you don't have this then you somehow have an old targets file.  Be sure to check both your dev machine .targets file and the Team Build server .targets file.  It's possible that the .targets file on your Team Build machine could be from one of the Betas.

     

     

  • Re: With Web Deployment Project

    05-25-2006, 1:52 AM
    • Loading...
    • maharik
    • Joined on 02-03-2006, 1:50 AM
    • Posts 6

    Thanks Bradley; it seems I had an older version of WAP or the targets were just not installed. WAP now compiles properly

    I am still getting a few errors regarding loading server controls that are available in separate assemblies though; I have these registered in the web.config:

    <

    pages theme="StandardTheme">

    <

    controls>

    <

    add tagPrefix="data" namespace="Corp.Security.WebUtilities.Data" assembly="Corp.Security.WebUtilities"/>

    <

    add tagPrefix="ui" namespace="Corp.Security.WebUtilities.UI" assembly="Corp.Security.WebUtilities"/>

    <

    add tagPrefix="corpgrid" assembly="Corp.Common.WebControls" namespace="Corp.Common.WebControls.MultiCheckGridView"/>

    <

    add tagPrefix="corp" assembly="Corp.Common.WebControls" namespace="Corp.Common.WebControls" />

    </controls>

    </

    pages>

    And the errors I get are all related to these controls:

    /Oakleaf.Security.Web.csproj/OakleafSecurityMasterPage.master(51): error ASPPARSE: Unknown server tag 'oakleaf:OakleafNotificationLabel'.

    /Oakleaf.Security.Web.csproj/Applications/AddUsersToApplication.aspx(28): error ASPPARSE: Unknown server tag 'oakleafgrid:MultiCheckGridView'.

    /Oakleaf.Security.Web.csproj/Applications/AddUsersToApplication.aspx(53): error ASPPARSE: Unknown server tag 'data:EntityDataSource'.

    Is there a reason why this would happen? do you recommend a better way of referencing these server controls?

    Thanks

     
  • Re: With Web Deployment Project

    08-22-2006, 12:01 PM
    • Loading...
    • MDang
    • Joined on 08-22-2006, 3:37 PM
    • Posts 1
    Hi Bradley,
     
    I found this thread and it's related to the same problem i experienced.  I added the <SourceWebPhysicalPath> lines of code mentioned to my wdproj file and made sure my Microsoft.WebApplication.targets file had the propertygroup mentioned.
     
    My soln contains a Web Application Project and a web deployment project.
     
    I followed the recommended build strategy when using web deployment projects to not build the WAP project and only the web deployment project (via configuration mgr).
     
    I still encounter the same error.
    ASPNETCOMPILER : error 1003: The directory 'F:\TeamBuilds\Builds\Nirvana\Nirvana\TestWAP Build\Binaries\Dev Release\_PublishedWebsites\TestWebApp' doesn't exist.

    My WAP Project is named "TestWebApp"

    My WDproj is named "TestWebApp_Deploy"

    My Sln is named "TestWap"

    I am using Team Build to build.

    When including both projects in the Team Build it works fine.

    Do you have any ideas on what might cause this to still occur?  Do I still need to include a WAP project?

    THanks

     

    Mike

  • Re: With Web Deployment Project

    08-22-2006, 6:21 PM
    • Loading...
    • BradleyB
    • Joined on 11-06-2002, 3:53 PM
    • Posts 225

    When using WDP you can exclude Website projects from the build but you can not exclude WAP projects.  A WAP project is explicitly compiling the code behind files into a separate assembly just like VS03.  The WDP is an msbuild project that runs the aspnet_compiler.exe.  If your code behind files are in a separate assembly, (such as with WAP) that assembly must be in bin before running the aspnet_compiler.  Thus you must build the WAP project to do this.

    Hope this helps,
    Brad.

     

     

  • Re: With Web Deployment Project

    09-04-2006, 10:00 PM
    • Loading...
    • mikbyrne
    • Joined on 05-23-2006, 5:59 AM
    • Melbourne
    • Posts 13

    This is a great thread and has helped to confirm and clarify my understanding of how web deployments work. I'm currently facing a challenge in a similar vein, and was hoping that I'd be able to get some direction on how to best tweak my web deployment project to get it all working.

    I have a solution that includes a number of separate website projects, with one project at the root and then a couple of other projects configured as separate projects (and corresponding to seprate applications within IIS). The complication arises out of a need to share a common set of user controls across these three website projects. I have been able to get this working on my local machine for development purposes by setting up a virtual directory within each of the website projects (which is not a separate application in IIS) which points to the directory which holds all the user controls  (which themselves exist in a separate website project, perhaps this should be a web application?). This solution allows each of the websites to build and run successfully off my local machine.

    Anyway, when I try to create a WDP for any of these websites I run into an error at the Target AspNetCompiler stage. It seems that the web deployment project does not follow the virtual directories and throws errors because the .ascx files in the <@Register ... > directives at the top of the page cannot be found. An example of the output from the WDP is:

     Target AspNetCompiler:
        C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /mick.wvecho.roadhouse.com.au -p "C:\Inetpub\World Vision" -u -f -d "C:\Documents and Settings\mick\My Documents\Visual Studio 2005\Projects\mick.worldvision.roadhouse.com.au\Deployment\WebsiteDeploy\Debug\\"
        /mick.wvecho.roadhouse.com.au/appeals/growfood/Donate.aspx(3): error ASPPARSE: The file '/mick.wvecho.roadhouse.com.au/FormSections/FormIntroduction.ascx' does not exist.

    Now, I have found a clunky way to get around this by setting up things within the WDP project file to actually copy all the .ascx and .ascx.cs files from the original directory to the website project at the BeforeBuild target (I've found I also need to exclude the directories which contain the other website projects). However, there are stacks of files in this website and the copying process takes a while to complete. I can't help thinking that there's a much more elegant solution to this problem, but which I just haven't found yet.

     
    Any advice would be greatly appreciated

     

    Mick Byrne
    Web Projects Director
  • Re: With Web Deployment Project

    09-04-2007, 10:31 AM