views:

104

answers:

2

I'm trying to use the AspNetCompiler task within a custom msbuild file to precompile an asp .net 4.0 website. However, when i run:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe custom.msbuild /t:PrecompileWeb

it uses the v2.0.50727 aspnet_compiler. Is there a way to force it to use the v4.0.30319 aspnet_compiler? The reason I am asking is because I am getting this error:

ASPCONFIG: Unrecognized configuration section system.web.extensions.

However, if I run:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -p .\My.Web.Site -f .\.PRECOMPILATION -v /

It runs fine which makes sense because I am using system.web.extensions in the web.config and the 2.0 aspnet_compiler doesn't know what that is.

A: 

Well I happened to be searching around some more and found the answer to my own question here:

http://blogs.msdn.com/b/webdevtools/archive/2010/05/14/the-aspnet-compiler-build-task-in-visual-studio-2010-asp-net-mvc-2-projects.aspx

What I ended up using was the ToolPath property for the AspNetCompiler task like so:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    <Target Name="PrecompileWeb">
        <AspNetCompiler
            VirtualPath="/MyWebSite"
            PhysicalPath="c:\inetpub\wwwroot\MyWebSite\"
            TargetPath="c:\precompiledweb\MyWebSite\"
            Force="true"
            Debug="true"
            ToolPath="C:\Windows\Microsoft.NET\Framework\v4.0.30319\"
        />
    </Target>
</Project>
smoak
A: 

ToolPath works for the AspNetCompiler task, but the right thing to do is just set the ToolsVersion="4.0" attribute on your Project element- this will cause all built-in tools to use the correct version and doesn't require the hardcoding of paths.

nitzmahone
Ah yes. That's even better. Thank you!
smoak