Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong version of aspnetcompiler when using msbuild 4.0

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.

like image 879
smoak Avatar asked Dec 05 '22 02:12

smoak


2 Answers

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.

like image 164
nitzmahone Avatar answered Mar 31 '23 13:03

nitzmahone


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">
    <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>
like image 29
smoak Avatar answered Mar 31 '23 11:03

smoak