문제

As outlined in Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005, the "Build Page" command available within Visual Studio web site projects does the following:

the solution will compile all of the class library projects like before, then compile the /app_code directory and Global.asax file, and then instead of re-verifying all pages within the web-site it will only verify the current page you are working on, and any user controls that the page references.

Is there a way to access this functionality from msbuild and / or the command line?

I am setting up an automated build of a large Visual Studio web site project (based on Kentico CMS), which consists of:

  • a large number of CMS-related pages and user controls that we do not change
  • a small number of custom "web part" user controls that we are actively developing, all within a CMSWebParts/Custom directory within the web site

Pre-compiling the entire site using aspnet_compiler takes up to 10 minutes, which is too slow for a commit build. Ideally, I'd like to introduce a step that pre-compiles just our custom code. Note that we don't actually deploy the pre-compiled output (not recommended for Kentico sites), this step is intended only to validate the code in the .ascx files.

도움이 되었습니까?

해결책

The best way I've found to reduce the pre-compile time for small changes to large web sites is to use the ASP.Net Compilation Tool (aspnet_compiler.exe) with in-place compilation.

Our build script runs the tool using the following command:

aspnet_compiler.exe -v / -p C:\path\to\MyWebSite

This command specifies the physical path to the web site but does not set the targetDir option, which results in the application being compiled in-place.

The benefit of in-place compilation is that aspnet_compiler will by default only compile files that have changed since the web site was last compiled (you can force it to recompile everything with the -c option). For example, when I run the above command against the web site for the first time, it takes about 10 mins to run. If I then change a single file and run it again, it only takes 30 seconds or so.

You may be curious as to how the compilation tool "knows" which files have changed. Compiling in-place doesn't modify the application being compiled, i.e., you won't end up with files like App_Web_xdqqvn5q.dll and default.aspx.cdcab7d2.compiled in the bin folder of your web application. The output is actually generated within the "Temporary ASP.NET Files" folder. When you specify a physical path (rather than an IIS metabase), a folder within your profile is used, e.g. C:\Users\your.name\AppData\Local\Temp\Temporary ASP.NET Files. Your web application source code is cross-referenced with data stored in Temporary ASP.NET Files to work out what has changed.

다른 팁

I think this might be of help for what you need to accomplish:

http://msdn.microsoft.com/en-us/library/dd293881.aspx

From what I read you can run the build from Visual Studio Command Prompt or from the windows command prompt.

Update:

I couldn't find anything on the internet relating to building only one page but using aspnet_compiler without -c parameter should speed up the compiling process since it will only recompile what has changed. If only thing that has changed since last build was the content of one .aspx page then running the compiler should act similar to Build Page.

-c

Specifies that the application to be compiled should be fully rebuilt. Components that have already been compiled are compiled again. If this option is omitted, the tool builds only those parts of the application that have been modified since compilation was last performed.

aspnet_compiler usage is explained on this page:

http://msdn.microsoft.com/en-us/library/ms229863.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top